在Leaflet中更改缩放级别时的工具提示移动

时间:2019-03-01 22:33:41

标签: javascript leaflet gis

我在地图中使用的标签为“永久工具提示”,如下所示:

tf.reduce_mean

如您在此处看到的那样,结果很好:

enter image description here

但是,当我更改缩放级别时,它的混乱情况如下:

enter image description here

有什么想法要解决吗?

1 个答案:

答案 0 :(得分:0)

解决此问题的唯一方法是创建一个新的点层(标记),该层指向每条线的末端。然后将工具提示分配给这些点。像这样:

post

请注意,您应该分配一个HTML类(即AAAA)来更改工具提示的格式(删除背景颜色,..)。另外,要删除工具提示方向的小三角形,还应添加新的CSS语句,如下所示:

$.ajax({
dataType: "json",
url: "...",
success: function (earthquake) {
    PointLayer= L.geoJSON(earthquake, {
        style: function (feature) {
            return {
                color: '#000',
                opacity: 1
            };
        },
        pointToLayer: function (feature, latlong) {
            return L.circle(latlong, 0);
        },
        onEachFeature: function (feature, layer) {
            layer.bindTooltip(layer.feature.properties.PanelName, { offset: L.point(0, 0), direction: 'bottom', permanent: true, className: 'AAAA', direction:'left' }).openTooltip();
        }
    }).addTo(map);