define(WRGMAPJSFUNCTIONS, <<<JAVASCRIPT
<script type="text/javascript">
//<![CDATA[
-var wrSleddingIcon = new GIcon();
-/*
-wrSleddingIcon.image = "bahn.png";
-wrSleddingIcon.shadow = "bahns.png";
+var wrSleddingIcon = new GIcon(G_DEFAULT_ICON);
+wrSleddingIcon.image = "/vorlagen/gmap_rodelbahn_c.png";
+wrSleddingIcon.shadow = "/vorlagen/gmap_rodelbahn_c_s.png";
wrSleddingIcon.iconSize = new GSize(17, 17);
wrSleddingIcon.shadowSize = new GSize(23, 23);
wrSleddingIcon.iconAnchor = new GPoint(9, 9);
wrSleddingIcon.infoWindowAnchor = new GPoint(9, 9);
-*/
function wrCreateMarker(latitude, longitude, name, icon) {
var point = new GLatLng(latitude, longitude);
var marker = new GMarker(point, icon);
- GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml("<strong>" + name + "</strong>");});
+ var articlePath = "$wgArticlePath";
+ var p = articlePath.replace("\$1", name.replace(' ', '_'));
+ GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml("<strong><a href='" + p + "'>" + name+ "</a></strong>");});
return marker;
}
//]]>
/// @param $content string - the content of the <wrgmap> tag
/// @param $args array - the array of attribute name/value pairs for the tag
/// @param $parser Parser - the MW Parser object for the current page
- /// @param $localParser Parser - the parser for parsing local content
///
/// @return string - the html for rendering the map
function render($content, $args, &$parser) {
++$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['zoom'])) $zoom = intval($args['zoom']); else $zoom = 10; // Google Zoom Level
// Query database
$dbr = wfGetDB(DB_SLAVE);
// 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" />' . "\n";
+ $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: 700px; height: 450px; border-style:solid; border-width:medium; border-color:blue;"></div>';
+ $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);
+ $output .= $this->addMap($mapName, $latitude, $longitude, $zoom);
foreach ($sleddingRoutes as $s) {
$lat = $s['position_latitude'];
$lon = $s['position_longitude'];
}
// returns a string that creates a map object called 'map'
- private function addMap($mapName) {
- return "\tmap = new GMap2(document.getElementById($mapName));\n" .
+ 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(47.267648, 11.404655), 10);\n" .
- "\tmap.setMapType(G_SATELLITE_MAP);\n" .
+ "\tmap.setCenter(new GLatLng($latitude, $longitude), $zoom);\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";
+ return "\tmap.addOverlay(wrCreateMarker($latitude, $longitude, \"" . htmlspecialchars(addslashes($pageTitle)) . "\", wrSleddingIcon));\n";
}
}