]> git.openstreetmap.org Git - rails.git/commitdiff
Zoom out when switching to a layer with a lower maxZoom
authorTom Hughes <tom@compton.nu>
Mon, 23 Sep 2013 16:29:07 +0000 (17:29 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 23 Sep 2013 16:29:07 +0000 (17:29 +0100)
app/assets/javascripts/index.js

index 5f6a4efb729b15690b5f6971126e924b82d081c6..7f4887469c6c8f13ef8702430792446ced01d954 100644 (file)
@@ -73,6 +73,12 @@ $(document).ready(function () {
     updateLayers(OSM.mapParams());
   });
 
+  map.on("baselayerchange", function (e) {
+    if (map.getZoom() > e.layer.options.maxZoom) {
+      map.setView(map.getCenter(), e.layer.options.maxZoom, { reset: true });
+    }
+  });
+
   map.noteLayer = new L.LayerGroup();
   map.noteLayer.options = {code: 'N'};