LeafletJS: How to remove the zoom control(LeafletJS:如何删除缩放控件)
问题描述
我正在尝试删除 LeafletJS 地图上的缩放控件 (+/-).
I'm trying to remove the zoom controls (+/-) on a LeafletJS map.
我正在使用 MapBox.js 版本的 Leaflet,但大多数的操作与 Leaflet 相同.我这样实现我的地图:
I'm using the MapBox.js version of Leaflet but most of the operations are the same as Leaflet. I implement my map like this:
var map = L.mapbox.map('map');
var layer = L.mapbox.tileLayer('MAPBOX-ID', {
format: 'jpg70',
minZoom: 13,
maxZoom: 15,
reuseTiles: true,
unloadInvisibleTiles: true
});
map.addLayer(layer);
map.setView([40.73547,-73.987856]);
文档说有一个 zoomControl 选项可以从地图中删除缩放控件但我没有让它工作.
The documentation says there's a zoomControl option that will remove the zoom control from the map but I've had no luck in getting it to work.
如何使用此实现删除缩放控件?
How can I remove the zoom control with this implementation?
谢谢!
推荐答案
这对我有用:
var map = new L.map('map', { zoomControl: false });
用 mapbox 试试:
With mapbox try:
var map = L.mapbox.map('map', { zoomControl: false });
参见地图创建和zoomControl 选项在 Leaflet 文档中.
See map creation and the zoomControl option in the Leaflet documentation.
这篇关于LeafletJS:如何删除缩放控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:LeafletJS:如何删除缩放控件
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
- Flexslider 箭头未正确显示 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01