【问题标题】:leaflet .bindLabel using geojson feature使用geojson功能的传单.bindLabel
【发布时间】:2017-01-18 18:29:03
【问题描述】:

我是传单的新手,我想为从 geojson 格式派生的点图特征添加标签。

我收到错误:TypeError: layer.bindLabel is not a function in this script https://jsfiddle.net/gfiske/ksx600sn/35/(取消注释第 129 行)

任何人都可以提出解决方法或更好的方法吗?

谢谢。

geojsonLayer = L.geoJson(geojson, {


style: function(feature) {
    return {
      color: feature.properties.GPSUserColor
    };
  },
  pointToLayer: function(feature, latlng) {
    return new L.CircleMarker(latlng, {
      radius: 7,
      fillOpacity: 0.75
    });
  },
  onEachFeature: function(feature, layer) {
    layer.bindPopup(feature.properties.MAP_LABEL);
    layer.bindLabel(feature.properties.MAP_LABEL);
    }
});

【问题讨论】:

    标签: leaflet


    【解决方案1】:

    来自Leaflet.label 的文档:

    注意:从 Leaflet 1.0 开始,L.Label 作为 L.Tooltip 添加到 Leaflet 核心中,并且此插件已被弃用。

    你应该改用bindTooltip

    onEachFeature: function(feature, layer) {
      layer.bindPopup(feature.properties.MAP_LABEL);
      layer.bindTooltip(feature.properties.MAP_LABEL);
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-11
      • 2020-02-01
      • 2019-07-20
      相关资源
      最近更新 更多