function theme_location_cck_field_map in Location 7.5
Same name and namespace in other branches
- 6.3 contrib/location_cck/location_cck.module \theme_location_cck_field_map()
- 7.3 contrib/location_cck/location_cck.module \theme_location_cck_field_map()
- 7.4 contrib/location_cck/location_cck.module \theme_location_cck_field_map()
Generate a GMap map for one or more location field values.
Mostly just cut and paste from gmap_location block view.
2 calls to theme_location_cck_field_map()
- theme_location_cck_field_all in contrib/
location_cck/ location_cck.module - Return both an address and a map for an individual item.
- theme_location_cck_formatter_combined in contrib/
location_cck/ location_cck.module - Alternate function to return a map with all multiple values in the same map.
File
- contrib/
location_cck/ location_cck.module, line 456 - Defines location field type.
Code
function theme_location_cck_field_map($variables) {
$locations = $variables['locations'];
$field = $variables['field'];
$instance = $variables['instance'];
$count = 0;
$content = '';
foreach ($locations as $location) {
if (location_has_coordinates($location)) {
$count++;
$markername = isset($field['settings']['gmap_marker']) ? $field['settings']['gmap_marker'] : 'drupal';
$markers[] = array(
'latitude' => $location['latitude'],
'longitude' => $location['longitude'],
'markername' => $markername,
'offset' => $count - 1,
'text' => theme('location_cck_field_popup', array(
'location' => $location,
'instance' => $instance,
)),
);
}
}
if (!empty($markers)) {
$macro = !empty($field['settings']['gmap_macro']) ? $field['settings']['gmap_macro'] : '[gmap ]';
$map = array_merge(gmap_defaults(), gmap_parse_macro($macro));
$map['latitude'] = $markers[0]['latitude'];
$map['longitude'] = $markers[0]['longitude'];
$map['markers'] = $markers;
$map['id'] = gmap_get_auto_mapid();
// Render a map element.
$location_map = array(
'#type' => 'gmap',
'#gmap_settings' => $map,
);
$content = drupal_render($location_map);
}
return $content;
}