++$this->mapsCount;
// Decode data
- if (isset($args['lat'])) $latitude = floatval($args['lat']); else $latitude = 47.267648;
- if (isset($args['lon'])) $longitude = floatval($args['lon']); else $longitude = 11.404655;
+ if (isset($args['lat'])) $latitude = floatval($args['lat']); else $latitude = 47.267648; // latitude as float value
+ if (isset($args['lon'])) $longitude = floatval($args['lon']); else $longitude = 11.404655; // longitude as float value
if (isset($args['zoom'])) $zoom = intval($args['zoom']); else $zoom = 10; // Google Zoom Level
$staticSizeX = 600;
$staticSizeY = 450;
+ $latitude_s = sprintf('%.6F', $latitude);
+ $longitude_s = sprintf('%.6F', $longitude);
// Query database
$dbr = wfGetDB(DB_SLAVE);
}
// Create static map image link
- $staticLink = "http://maps.google.com/staticmap?center=$latitude,$longitude&zoom=$zoom&size=${staticSizeX}x$staticSizeY&key=$this->apiKey";
+ $staticLink = "http://maps.google.com/staticmap?center=$latitude_s,$longitude_s&zoom=$zoom&size=${staticSizeX}x$staticSizeY&key=$this->apiKey";
$staticMarkers = array();
foreach ($sleddingRoutes as $s) {
- $lat = $s['position_latitude'];
- $lon = $s['position_longitude'];
- $staticMarkers[] = sprintf('%.3f,%.3f,bluer', $lat, $lon);
+ $lat = $s['position_latitude']; // this is a string
+ $lon = $s['position_longitude']; // this is a string
+ $staticMarkers[] = sprintf('%s,%s,bluer', $lat, $lon);
}
if (count($staticMarkers) > 0) $staticLink .= '&markers=' . implode('|', $staticMarkers);
}
// returns a string that creates a map object called 'map'
+ // $latitude, $longitude and $zoom have to be float/integer values.
private function addMap($mapName, $latitude, $longitude, $zoom) {
return "\tvar map = new GMap2(document.getElementById('$mapName'), {'mapTypes': [G_NORMAL_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_SATELLITE_MAP]});\n" .
"\tmap.addControl(new GLargeMapControl());\n" .
"\tmap.addControl(new GMapTypeControl());\n" .
"\tmap.addControl(new GScaleControl());\n" .
- "\tmap.setCenter(new GLatLng($latitude, $longitude), $zoom);\n" .
+ sprintf("\tmap.setCenter(new GLatLng(%.6F, %.6F), %d);\n", $latitude, $longitude, $zoom) .
"\tmap.setMapType(G_PHYSICAL_MAP);\n";
// "\tmap.enableScrollWheelZoom();\n";
}
// returns a string with a add marker javascript call
+ // $latitude and $longitude are expected as string
private function addJsMarker($latitude, $longitude, $pageTitle) {
return "\tmap.addOverlay(wrCreateMarker($latitude, $longitude, \"" . htmlspecialchars(addslashes($pageTitle)) . "\", wrSleddingIcon));\n";
}