From 9551dacee39c2bc9b5757f4304b015f7fda99856 Mon Sep 17 00:00:00 2001 From: Alex Visser Date: Wed, 17 Sep 2014 23:49:00 +1000 Subject: [PATCH] Fix precision error in google map widget --- src/Wt/WGoogleMap.C | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Wt/WGoogleMap.C b/src/Wt/WGoogleMap.C index ab8f78d..4a3bc11 100644 --- a/src/Wt/WGoogleMap.C +++ b/src/Wt/WGoogleMap.C @@ -286,11 +286,11 @@ void WGoogleMap::addMarker(const Coordinate& pos) std::stringstream strm; if (apiVersion_ == Version2) { - strm << "var marker = new google.maps.Marker(new google.maps.LatLng(" + strm << std::setprecision(15) << "var marker = new google.maps.Marker(new google.maps.LatLng(" << pos.latitude() << ", " << pos.longitude() << "));" << jsRef() << ".map.addOverlay(marker);"; } else { - strm << "var position = new google.maps.LatLng(" + strm << std::setprecision(15) << "var position = new google.maps.LatLng(" << pos.latitude() << ", " << pos.longitude() << ");" << "var marker = new google.maps.Marker({" << "position: position," @@ -311,7 +311,7 @@ void WGoogleMap::addIconMarker(const Coordinate &pos, throw std::logic_error("WGoogleMap::addIconMarker is not supported " "in the Google Maps API v2."); } else { - strm << "var position = new google.maps.LatLng(" + strm << std::setprecision(15) << "var position = new google.maps.LatLng(" << pos.latitude() << ", " << pos.longitude() << ");" << "var marker = new google.maps.Marker({" @@ -342,7 +342,7 @@ void WGoogleMap::addCircle(const Coordinate& center, double radius, double strokeOpacity = strokeColor.alpha() / 255.0; double fillOpacity = fillColor.alpha() / 255.0; - strm << "var mapLocal = " << jsRef() + ".map;" + strm << std::setprecision(15) << "var mapLocal = " << jsRef() + ".map;" << "var latLng = new google.maps.LatLng(" << center.latitude() << "," << center.longitude() << ");" << "var circle = new google.maps.Circle( " @@ -374,7 +374,7 @@ void WGoogleMap::addPolyline(const std::vector& points, std::stringstream strm; strm << "var waypoints = [];"; for (size_t i = 0; i < points.size(); ++i) - strm << "waypoints[" << i << "] = new google.maps.LatLng(" + strm << std::setprecision(15) << "waypoints[" << i << "] = new google.maps.LatLng(" << points[i].latitude() << ", " << points[i].longitude() << ");"; if (apiVersion_ == Version2) { @@ -400,7 +400,7 @@ void WGoogleMap::openInfoWindow(const Coordinate& pos, const WString& myHtml) { std::stringstream strm; - strm << "var pos = new google.maps.LatLng(" + strm << std::setprecision(15) << "var pos = new google.maps.LatLng(" << pos.latitude() << ", " << pos.longitude() << ");"; if (apiVersion_ == Version2) { @@ -421,7 +421,7 @@ void WGoogleMap::openInfoWindow(const Coordinate& pos, void WGoogleMap::setCenter(const Coordinate& center) { std::stringstream strm; - strm << jsRef() << ".map.setCenter(new google.maps.LatLng(" + strm << std::setprecision(15) << jsRef() << ".map.setCenter(new google.maps.LatLng(" << center.latitude() << ", " << center.longitude() << "));"; doGmJavaScript(strm.str()); @@ -430,7 +430,7 @@ void WGoogleMap::setCenter(const Coordinate& center) void WGoogleMap::setCenter(const Coordinate& center, int zoom) { std::stringstream strm; - strm << jsRef() << ".map.setCenter(new google.maps.LatLng(" + strm << std::setprecision(15) << jsRef() << ".map.setCenter(new google.maps.LatLng(" << center.latitude() << ", " << center.longitude() << ")); " << jsRef() << ".map.setZoom(" << zoom << ");"; @@ -440,7 +440,7 @@ void WGoogleMap::setCenter(const Coordinate& center, int zoom) void WGoogleMap::panTo(const Coordinate& center) { std::stringstream strm; - strm << jsRef() << ".map.panTo(new google.maps.LatLng(" + strm << std::setprecision(15) << jsRef() << ".map.panTo(new google.maps.LatLng(" << center.latitude() << ", " << center.longitude() << "));"; doGmJavaScript(strm.str()); @@ -476,7 +476,7 @@ void WGoogleMap::savePosition() doGmJavaScript(jsRef() + ".map.savePosition();"); } else { std::stringstream strm; - strm + strm << std::setprecision(15) << jsRef() << ".map.savedZoom = " << jsRef() << ".map.getZoom();" << jsRef() << ".map.savedPosition = " << jsRef() << ".map.getCenter();"; doGmJavaScript(strm.str()); @@ -489,7 +489,7 @@ void WGoogleMap::returnToSavedPosition() doGmJavaScript(jsRef() + ".map.returnToSavedPosition();"); } else { std::stringstream strm; - strm + strm << std::setprecision(15) << jsRef() << ".map.setZoom(" << jsRef() << ".map.savedZoom);" << jsRef() << ".map.setCenter(" << jsRef() << ".map.savedPosition);"; doGmJavaScript(strm.str()); @@ -601,13 +601,13 @@ void WGoogleMap::zoomWindow(const Coordinate& topLeft, Coordinate(std::max(topLeft.latitude(), rightBottom.latitude()), std::max(topLeft.longitude(), rightBottom.longitude())); std::stringstream strm; - strm << "var bbox = new google.maps.LatLngBounds(new google.maps.LatLng(" + strm << std::setprecision(15) << "var bbox = new google.maps.LatLngBounds(new google.maps.LatLng(" << topLeftC.latitude() << ", " << topLeftC.longitude() << "), " << "new google.maps.LatLng(" << rightBottomC.latitude() << ", " << rightBottomC.longitude() << "));"; if (apiVersion_ == Version2) { - strm + strm << std::setprecision(15) << "var zooml = " << jsRef() << ".map.getBoundsZoomLevel(bbox);" << jsRef() << ".map.setCenter(new google.maps.LatLng(" << center.latitude() << ", " << center.longitude() << "), zooml);"; -- 1.8.3.2