[英]Overlaying a text box on a leaflet.js map
This might seem a very simple question, but I've searched elsewhere for the answer with no luck!这似乎是一个非常简单的问题,但我在其他地方寻找答案却没有运气!
How do I overlay a simple text box on to a Leaflet map that loads when the map loads (not fixed to any point on a map) - for example, to give a title and more information within the actual map object.如何将一个简单的文本框叠加到在地图加载时加载的 Leaflet 地图上(不固定到地图上的任何点) - 例如,在实际地图对象中提供标题和更多信息。 Nothing fancy.
没有什么花哨。
I know this is old, but here's some sample code, CSS as necessary:我知道这是旧的,但这里有一些示例代码,必要时使用 CSS:
L.Control.textbox = L.Control.extend({ onAdd: function(map) { var text = L.DomUtil.create('div'); text.id = "info_text"; text.innerHTML = "<strong>text here</strong>" return text; }, onRemove: function(map) { // Nothing to do here } }); L.control.textbox = function(opts) { return new L.Control.textbox(opts);} L.control.textbox({ position: 'bottomleft' }).addTo(map);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.