如何将一个北箭头添加到leaflet.js地图? [英] How can I add a north arrow to a leaflet.js map?
本文介绍了如何将一个北箭头添加到leaflet.js地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一个简单的方法来将一个北箭头添加到leaflet.js地图?我已经搜索了一下在线,但我找不到很多。
Is there an easy way to add a north arrow to a leaflet.js map? I have searched a bit online but I cannot find much.
推荐答案
你可以添加一个包含一个div与你的北箭头的控件image:
You can add a control that contains a div with your north arrow image:
var north = L.control({position: "bottomright"});
north.onAdd = function(map) {
var div = L.DomUtil.create("div", "info legend");
div.innerHTML = '<img src="your-north-arrow.png">';
return div;
}
north.addTo(map);
请参阅传单的控制文档,以获取有关定位和其他选项的更多信息。
See Leaflet's control documentation for more info on positioning and other options.
这篇关于如何将一个北箭头添加到leaflet.js地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文