Restricting map zoom levels in Maplibre

  • How can I restrict the zoom levels in my Maplibre map using Wikiocity Maps JS? I want to prevent users from zooming in too close or zooming out too far.

  • You can set the min and max zoom either before or after initializing the map.


    use the minZoom and maxZoom options while initializing the Maplibre map through the MglOptions global variable. More information in the docs at Map Settings - MapLibre.


    MglOptions = {

    minZoom: 5,

    maxZoom: 18


    //initialize map code

    var map = ...


    Another option is to use map.setMinZoom(minZoomLevel) and map.setMaxZoom(maxZoomLevel) methods after initializing the map. For example:

    //after map initialization



    This way, you can dynamically update the allowed zoom levels during runtime if needed.

    Hope this helps!

Register or Login to Post