Fixed locale problem: "$float" was sometimes rendered with "," as comma.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Fri, 20 Mar 2009 15:54:38 +0000 (15:54 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Fri, 20 Mar 2009 15:54:38 +0000 (15:54 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/extensions/wrmap@429 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.body.php

index cddf4f1986f5082ad451e0ab462264192687ea42..3fa14785effb4be5a595230cf2a357df5e641b70 100644 (file)
@@ -64,11 +64,13 @@ class WrGoogleMaps {
                ++$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);
@@ -85,12 +87,12 @@ class WrGoogleMaps {
                }
                        
                // 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);
 
@@ -119,17 +121,19 @@ class WrGoogleMaps {
        }
        
        // 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";
        }