X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eebe1f1d3ed885e94725c07d24e0483f603f03da..c3cdd4b5d732ae6ea7a65490ed6797190f3f4330:/app/assets/javascripts/leaflet.layers.js
diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js
index bbc84701c..80613a5d9 100644
--- a/app/assets/javascripts/leaflet.layers.js
+++ b/app/assets/javascripts/leaflet.layers.js
@@ -16,12 +16,13 @@ L.OSM.layers = function(options) {
.appendTo($container);
var $ui = $('
')
- .attr('class', 'layers-ui')
- .appendTo(options.uiPane);
+ .attr('class', 'layers-ui');
- $('
')
- .text(I18n.t('javascripts.map.layers.header'))
- .appendTo($ui);
+ $('')
+ .appendTo($ui)
+ .append(
+ $('')
+ .text(I18n.t('javascripts.map.layers.header')));
if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
var overlaySection = $('')
@@ -90,19 +91,30 @@ 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);
+ .addLayer(new layer.constructor());
miniMap.dragging.disable();
miniMap.touchZoom.disable();
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);
- div.data('map', miniMap);
+ function shown() {
+ miniMap.invalidateSize();
+ setView();
+ map.on('moveend', setView);
+ }
+
+ function hide() {
+ map.off('moveend', setView);
+ }
+
+ function setView() {
+ miniMap.setView(map.getCenter(), Math.max(map.getZoom() - 2, 0));
+ }
});
var label = $('