Added static link to support non-compatible browsers.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 21 Dec 2008 15:13:57 +0000 (15:13 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 21 Dec 2008 15:13:57 +0000 (15:13 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/extensions/wrmap@361 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.body.php

index 4a0ac323332da668cfb88db17395aefd248cfac1..528d921e1c5ad71e66575f832ffc95d5d0e4ed5e 100644 (file)
@@ -96,6 +96,8 @@ class WrGoogleMaps {
                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
+               $staticSizeX = 600;
+               $staticSizeY = 450;
 
                // Query database
                $dbr = wfGetDB(DB_SLAVE);
@@ -111,6 +113,16 @@ class WrGoogleMaps {
                        $output .= WRGMAPJSFUNCTIONS;
                }
                        
+               // Create static map image link
+               $staticLink = "http://maps.google.com/staticmap?center=$latitude,$longitude&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);
+               }
+               if (count($staticMarkers) > 0) $staticLink .= '&' . implode('|', $staticMarkers);
+
                // 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>';
@@ -126,7 +138,11 @@ class WrGoogleMaps {
                        if (!$lat || !$lon) continue;
                        $output .= $this->addJsMarker($lat, $lon, $pageTitle);
                }
+               $output .= "} else {\n"; // browser not compatible -> create static map
+               $output .= "\tdocument.write(\"<img alt=\\\"Landkarte mit Rodelbahnen\\\" src=\\\"" . htmlspecialchars($staticLink) . "\\\" width=\\\"$staticSizeX\\\" height=\\\"$staticSizeY\\\" />\");\n";
                $output .= "}\n//]]>\n</script>\n";
+               $output .= '<noscript><img alt="Landkarte mit Rodelbahnen" src="' . htmlspecialchars($staticLink) . "\" width=\"$staticSizeX\" height=\"$staticSizeY\" /></noscript>\n";
+
                return wrMapReplaceByMarker($output);
        }