简体   繁体   English

如何限制地图的缩放级别Mapbox

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

Hey, 嘿,

I am currently using mapbox www.livehazards.com. 我目前正在使用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. 我的地图浏览量和广告浏览量是7倍,如果我的网站取得成功,那将在财务上不可持续。

I think the problem could be that when a person zooms in that is counting as 4-6 new mapviews?? 我认为问题可能在于当一个人放大时,它会算作4-6个新的mapview? Do you think this is correct 你认为这是正确的吗

....How do I limit the zoom level to 3 (Current Default) so users cannot zoom in any further ....如何将缩放级别限制为3(当前默认值),以使用户无法进一步放大

Thanks 谢谢

If by "mapbox" you mean Mapbox-GL-JS, you can specify zoom limits when you create the map with maxZoom and minZoom : 如果用“ mapbox”表示Mapbox-GL-JS,则可以使用maxZoomminZoom 创建地图时指定缩放限制:

var map = new mapboxgl.Map({
  container: 'map',
  center: [-122.420679, 37.772537],
  zoom: 13,
  maxZoom: 15,
  minZoom: 13
});

I think the problem could be that when a person zooms in that is counting as 4-6 new mapviews?? 我认为问题可能在于当一个人放大时,它会算作4-6个新的mapview? Do you think this is correct 你认为这是正确的吗

In the context of GL JS a "map view" is defined as 4 tiles. 在GL JS的上下文中,“地图视图”定义为4个图块。 See this page for more details: https://www.mapbox.com/help/define-map-view/ 有关更多详细信息,请参见此页面: https : //www.mapbox.com/help/define-map-view/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM