Friday, July 8, 2011

Drupal 6 - Display a GMAP for a Location CCK field custom

My cck location filed is $node_details->field_map_location;
$lid = $node_details->field_map_location['0']['lid'];

if (is_numeric($lid)) {
$loc = location_load_location($lid);
$markertypes = variable_get('gmap_node_markers', array());
$markers = array();
$count = 0;
if (location_has_coordinates($loc)) {
$count++;
$markername = isset($markertypes[$node_details->type]) ? $markertypes[$node_details->type] : 'drupal';
if (module_exists('gmap_taxonomy')) {
$t = db_result(db_query('SELECT marker FROM {gmap_taxonomy_node} WHERE vid = %d', $node->vid));
if (!empty($t)) {
$markername = $t;
}
}

$markertitle = $node_details->title;
if (!empty($loc['name'])) {
$markertitle = $loc['name'];
}

$markers[] = array(
'latitude' => $loc['latitude'],
'longitude' => $loc['longitude'],
'markername' => $markername,
'offset' => $count-1,
'opts' => array('title' => $markertitle),
);
}

if (!empty($markers)) {
$macro = variable_get('gmap_location_block_macro_'. $node_details->type, '');
if (empty($macro)) {
$macro = variable_get('gmap_location_block_macro', '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]');
}
$map = gmap_parse_macro($macro);

$map['width'] = '100%';
$map['height'] = '300px';
$map['latitude'] = $node_details->location['latitude'];
$map['longitude'] = $node_details->location['longitude'];
$map['markers'] = $markers;
}
}
theme('gmap', array('#settings' => $map));
This will return the gmap with location marker.

2 comments:

  1. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.It can be helpful for people who wants to know more about app Modernization services.

    ReplyDelete