简体   繁体   English

添加新控件后,传单地图不起作用

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

After adding Leaflet.MousePosition my map doesn't show.添加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);

吨

You are using map but you have to use lmap您正在使用map但您必须使用lmap

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

Also you have to add the library src to your project.此外,您必须将库 src 添加到您的项目中。

Add following to your html file:将以下内容添加到您的 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