简体   繁体   English

传单标记禁用悬停或悬停时不显示任何内容

[英]Leaflet marker disable hover or show nothing on hover

I am using Leaflet API to draw some markers on the map. 我正在使用Leaflet API在地图上绘制一些标记。 My marker data is populated using HTML which displays fine when clicked on. 我的标记数据是使用HTML填充的,单击该HTML可以正常显示。 The problem is when hovered on top of the marker it displays the html tags also. 问题是,将鼠标悬停在标记上方时,它还会显示html标记。 Either I want to disable the hover entirely OR show the data only on hover also excluding the Html tags OR show empty string on hover which ever is easier. 我想完全禁用悬停,或者仅在悬停时显示数据,还要排除Html标记,或者在悬停时显示空字符串,这会更容易。

My code (JS): 我的代码(JS):

for (var i = 0; i < arr.length; i++) {
     var a = arr[i];
     var title = a[2];

     var marker = new L.Marker(new L.LatLng(a[0], a[1]), { title: title });
     marker.bindPopup(title);
     layer.markers.addLayer(marker);
}

map.addLayer(layer.markers);

You have to remove the option title 您必须删除选项标题

var marker = new L.Marker(new L.LatLng(a[0], a[1]));

instead of 代替

var marker = new L.Marker(new L.LatLng(a[0], a[1]), { title: title });

Ref: http://leafletjs.com/reference.html#marker 参考: http : //leafletjs.com/reference.html#marker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM