function gmap_map_cleanup in GMap Module 7.2
Same name and namespace in other branches
- 5 gmap.module \gmap_map_cleanup()
- 6.2 gmap.module \gmap_map_cleanup()
- 6 gmap.module \gmap_map_cleanup()
- 7 gmap.module \gmap_map_cleanup()
Perform some normalization on the map object to prevent errors.
@todo move this to GmapToolbox
1 call to gmap_map_cleanup()
- theme_gmap in ./
gmap.module - Gmap element theme hook.
File
- ./
gmap.module, line 917 - GMap -- Routines to use the Google Maps API in Drupal.
Code
function gmap_map_cleanup(&$map) {
// Google is picky about this one.
$map['zoom'] = (int) $map['zoom'];
// Normalize latitude / longitude.
if ($map['latlong']) {
$map['latlon'] = $map['latlong'];
unset($map['latlong']);
}
// Normalize extent.
if (isset($map['extent']) && is_string($map['extent'])) {
$tmp = explode(',', $map['extent']);
if (count($tmp) == 4) {
// String form of extent has x,y, but native array
// form is lat,lon, so need to flip them a bit.
$map['extent'] = array(
array(
$tmp[1],
$tmp[0],
),
array(
$tmp[3],
$tmp[2],
),
);
}
else {
// Extent was unparseable, don't pass it.
unset($map['extent']);
}
}
if (isset($map['latlon']) && (!isset($map['latitude']) || !isset($map['longitude']))) {
list($map['latitude'], $map['longitude']) = explode(',', $map['latlon']);
}
unset($map['latlon']);
foreach ($map['baselayers'] as $k => $v) {
if (!$v) {
unset($map['baselayers'][$k]);
}
}
}