0

I cant seem to get my map to set a max zoom level.

Here is a snippit of my code -

var map = new mapboxgl.Map({
container: 'map', 
style: 'mapbox://styles/cdickinson11/cjg49l1f305ou2rls3hd65a6s', 
center: [-77.034084142948, 38.909671288923], 
zoom: 10
options.maxZoom: 13
});

I also tried this, adapted from here. It did not work either, I'm guessing because it is from mapbox js instead of mapbox gl js.

var options = {
maxZoom: 13
};
mapObject = L.mapbox.map('mapDiv', undefined, options);

I'm fairly new to this type of thing. I'm pretty sure my issue lies in a lack of basic understanding about javascript, and about the difference between mapbox gl js and mapbox js. Any help?

1

Did you try just (edit: I missed a comma, fixed it now)

var map = new mapboxgl.Map({
container: 'map', 
style: 'mapbox://styles/cdickinson11/cjg49l1f305ou2rls3hd65a6s', 
center: [-77.034084142948, 38.909671288923], 
zoom: 10,
maxZoom: 13
});

Here is a JSBin demonstrating it: https://jsbin.com/qodovogevi/1/edit?html,output

  • yes I did and it did not work. not sure why? – StupidQuestionGuy Apr 18 '18 at 21:26
  • 1
    Oops, I forgot there should be a comma after the zoom option! I'll edit that into the answer. – cmrRose Apr 18 '18 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.