问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/22325460/how-can-i-add-a-north-arrow-to-a-leaflet-js-map