Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I limit the Zoom level of my map, Mapbox

Hey,

I am currently using mapbox www.livehazards.com. It is a live earthquake map

I am getting 7x mapviews vs adviews and if my website was to become successful it would be financially unsustainable.

I think the problem could be that when a person zooms in that is counting as 4-6 new mapviews?? Do you think this is correct

....How do I limit the zoom level to 3 (Current Default) so users cannot zoom in any further

Thanks

like image 823
Charles Harrison Avatar asked Dec 24 '22 11:12

Charles Harrison


1 Answers

If by "mapbox" you mean Mapbox-GL-JS, you can specify zoom limits when you create the map with maxZoom and minZoom:

var map = new mapboxgl.Map({
  container: 'map',
  center: [-122.420679, 37.772537],
  zoom: 13,
  maxZoom: 15,
  minZoom: 13
});
like image 80
Steve Bennett Avatar answered Jan 08 '23 02:01

Steve Bennett