X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a6ac56c5e510395d160cdb7ccc7a88d87403e687..6f102f2726ad73c4c5f90bda1e7ec5f74774a7bb:/app/assets/javascripts/leaflet.layers.js diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index 2bc538798..ea0bf63a0 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -89,7 +89,6 @@ L.OSM.layers = function(options) { map.whenReady(function() { var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false}) - .setView(map.getCenter(), Math.max(map.getZoom() - 2, 0)) .addLayer(new layer.constructor); miniMap.dragging.disable(); @@ -97,11 +96,23 @@ L.OSM.layers = function(options) { miniMap.doubleClickZoom.disable(); miniMap.scrollWheelZoom.disable(); - map.on('moveend', function() { - miniMap.setView(map.getCenter(), Math.max(map.getZoom() - 2, 0)); - }); + $ui + .on('show', shown) + .on('hide', hide); + + function shown() { + miniMap.invalidateSize(); + setView(); + map.on('moveend', setView); + } - div.data('map', miniMap); + function hide() { + map.off('moveend', setView); + } + + function setView() { + miniMap.setView(map.getCenter(), Math.max(map.getZoom() - 2, 0)); + } }); var label = $('