2017-01-18 27 views
1

我是新手册,我想将标签添加到从geojson格式派生的点图功能中。传单.bindLabel使用geojson功能

我得到的错误:类型错误:layer.bindLabel是不是在这个脚本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); 
    } 
}); 

回答

1

从文档Leaflet.label

NOTE: starting with Leaflet 1.0, L.Label is added to Leaflet core as L.Tooltip and this plugin is deprecrated.

您应该使用bindTooltip代替:

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