传单地图是否具有标签功能? [英] Do leaflet maps have a label function?

查看:55
本文介绍了传单地图是否具有标签功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道是否可以在我的反应传单地图上的标记旁边添加标签吗?

Anyone know whether it is possible to add a label beside my markers on my react-leaflet map?

推荐答案

FrankerZ发送给您的链接非常有用,一定要检查一下.

The link FrankerZ sent you to is pretty helpful, definitely check that out.

如果您的意思是当您将鼠标悬停在标记(或折线等)上时会显示一个弹出标签,那么从Leaflet 1.0开始,您可以使用

If you mean a little popup label that shows up when you hover over a marker (or Polyline, etc.) then as of Leaflet 1.0, you can use Tooltip. I've found that it works much more smoothly than making a Popup, and uses less code, especially if you're just opening the popup on hover. It might look like:

 var Marker = L.marker...
 Marker.bindTooltip('HI').openPopup();

如果需要,可以使用永久布尔标志保持打开状态.

And you can use the permanent boolean flag if you want to keep it open.

如果您想要一个弹出式窗口,则较少选择 DivIcon .始终保持在特定位置的文本标签.请参见 SO帖子.基本上,您可以添加与地理位置相关联的div,然后将div设置为所需的格式,使其显示为text-y或text box-y.

A less popup-y option is DivIcon, if you want a text label that stays at a certain position always. See this SO post. Basically you can add a div that is associated with a geographical position, then format the div to look as text-y or text box-y as you want.

这篇关于传单地图是否具有标签功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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