Search code examples
leaflet

Leaflet disable vertical dragging out of bounds


Is it possible to only have vertical bounds in leaflet to remove grey bands above and below the leaflet map?

Grey bands around map

I still want to keep horizontal wrap but just want to remove the grey areas.


Solution

  • you can simply use the minZoom option, and set it to 3, that's what I do ;)

    this.map.setView(new L.LatLng(31.585692323629303, 35.19333585601518), 2);
        L.tileLayer(`https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png`, {
          maxZoom: 20,
          minZoom: 3,
          attribution: 'HOT'
        }).addTo(this.map);
    

    in my case using angular, hope it help