簡體   English   中英

添加新控件后,傳單地圖不起作用

[英]Leaflet map doesn’t work after adding a new control

添加Leaflet.MousePosition 后,我的地圖不顯示。

var lmap = new L.map("lmap", {
  zoomControl: false,
  maxZoom: 11,
  minZoom: 3,
}).setView([34.543896, 63.160652], 6);
L.control.zoom({
  position: 'topright'
}).addTo(lmap);
lmap.addControl(new L.Control.Fullscreen({position: 'bottomleft'}));
L.control.mousePosition({position: 'bottomright'}).addTo(lmap);

噸

您正在使用map但您必須使用lmap

L.control.mousePosition({position: 'bottomright'}).addTo(lmap);

此外,您必須將庫 src 添加到您的項目中。

將以下內容添加到您的 html 文件中:

<script src="https://cdn.jsdelivr.net/npm/leaflet-mouse-position@1.2.0/src/L.Control.MousePosition.min.js"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM