]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Merge branch 'master' into overpass
[rails.git] / app / assets / javascripts / index.js
index ddec2bffe9824d143fd2994e1d93de9032a56c72..236ed44fc190de0410a0145fb0cfddd6d1b6ad13 100644 (file)
@@ -271,10 +271,11 @@ $(document).ready(function () {
 
     function addObject(type, id, center) {
       var bounds = map.addObject({type: type, id: parseInt(id)}, function(bounds) {
-        if (!window.location.hash && bounds.isValid()) {
-          OSM.router.moveListenerOff();
-          map.once('moveend', OSM.router.moveListenerOn);
-          if (center || !map.getBounds().contains(bounds)) map.fitBounds(bounds);
+        if (!window.location.hash && bounds.isValid() &&
+            (center || !map.getBounds().contains(bounds))) {
+          OSM.router.withoutMoveListener(function () {
+            map.fitBounds(bounds);
+          });
         }
       });
     }
@@ -341,9 +342,10 @@ $(document).ready(function () {
 
   $(".describe_location").on("click", function(e) {
     e.preventDefault();
-    var precision = OSM.zoomPrecision(map.getZoom());
+    var center = map.getCenter().wrap(),
+      precision = OSM.zoomPrecision(map.getZoom());
     OSM.router.route("/search?query=" + encodeURIComponent(
-      map.getCenter().lat.toFixed(precision) + "," +
-      map.getCenter().lng.toFixed(precision)));
+      center.lat.toFixed(precision) + "," + center.lng.toFixed(precision)
+    ));
   });
 });