Greatwon
Greatwon

Reputation: 123

In mapbox can you only disable the ability to zoom in?

Im writing a map where the user can only zoom in to a specific level before having to click on a marker, I know you can disable zooming in and out with:

    // Disable drag and zoom handlers.
    map.touchZoom.disable();
    map.doubleClickZoom.disable();
    map.scrollWheelZoom.disable();

    // Disable tap handler, if present.
    if (map.tap) map.tap.disable();

but I would like the user to still be able to zoom out once they hit the specific zoom level. Is there a way to only disable zoom in?

Upvotes: 2

Views: 798

Answers (1)

NSTR
NSTR

Reputation: 81

You can take advantage of the minZoom and maxZoom options when you create your map. This way the user can only zoom in so far but can still zoom out.

L.mapbox.accessToken = 'accessToken';
L.mapbox.map('map', 'mapId', {zoomControl: false, attributionControl: false, minZoom: 5});

Upvotes: 2

Related Questions