- // Load Google Maps Script and define functions
- $output = '';
- if ($this->mapsCount == 1) {
- $output .= '<script src="http://maps.google.com/maps?file=api&v=2&key=' . htmlspecialchars($this->apiKey) . '" type="text/javascript"></script>' . "\n";
- $output .= WRGMAPJSFUNCTIONS;
- }
-
- // Create <div/> element where the map is placed in
- $mapName = 'wrgmap' . $this->mapsCount;
- $output .= '<div id="' . $mapName . '" style="width: 100%; height: 450px; border-style:none;"></div>';
-
- // Return output
- $output .= '<script type="text/javascript">' . "\n//<![CDATA[\n";
- $output .= 'if (GBrowserIsCompatible()) {' . "\n";
- $output .= $this->addMap($mapName);
- foreach ($sleddingRoutes as $s) {
- $lat = $s['position_latitude'];
- $lon = $s['position_longitude'];
- $pageTitle = $s['page_title'];
- if (!$lat || !$lon) continue;
- $output .= $this->addJsMarker($lat, $lon, $pageTitle);
- }
- $output .= "}\n//]]>\n</script>\n";
- return wrMapReplaceByMarker($output);
- }
-
- // returns a string that creates a map object called 'map'
- private function addMap($mapName) {
- 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(47.267648, 11.404655), 10);\n" .
- "\tmap.setMapType(G_PHYSICAL_MAP);\n" .
- "\tmap.enableScrollWheelZoom();\n";
- }
-
- // returns a string with a add marker javascript call
- private function addJsMarker($latitude, $longitude, $pageTitle) {
- return "\tmap.addOverlay(wrCreateMarker($latitude, $longitude, \"" . htmlspecialchars(addslashes($pageTitle)) . "\", wrSleddingIcon));\n";
- }
-
-}