X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/078059b76b8304368fd7ddac2dd563470e83472e..e7ef10d4289501a04045e01ecf7fe9202c09eb4f:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index ddec2bffe..54ccb88ed 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -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); + }); } }); }