在leaflet.js地图上覆盖一个文本框 [英] Overlaying a text box on a leaflet.js map

查看:575
本文介绍了在leaflet.js地图上覆盖一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个非常简单的问题,但是我在其他地方搜索了答案,但是没有运气!

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. Nothing fancy.

推荐答案

您有两个简单的选择,扩展一个新的 L.Control 并将其放置在地图窗口的四个角之一中,其中内容在 L.DivIcon 放置在通过地理坐标或基于容器尺寸的坐标在L.Marker旁边进行地图绘制.使它像盒子"一样,仅包含少量您认为合适的CSS,例如某些paddingbackground-color,等

You have two simple options, extend a new L.Control and place it in one of the four corners of the map window with content created inside the onAdd method, or place a L.DivIcon anywhere on the map alongside a L.Marker, by either geographical coordinates or coordinates based upon the dimensions of the container.Making it "box" like would just include a small bit of CSS as you see fit, like some padding,background-color, etc.

这篇关于在leaflet.js地图上覆盖一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆