問題描述
我正在嘗試刪除 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:如何刪除縮放控件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!