1
我需要在我的Leaflet地图上使用GeoJSON
图层。以下是我的代码示例:Leaflet:如何在GeoJSON图层上添加属性?
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.popupContent) {
layer.bindPopup(feature.properties.popupContent);
}
}
myGeoJsonLayer = L.geoJson(data, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
},
onEachFeature: onEachFeature
});
myGeoJsonLayer.addTo(map);
TOC.addOverlay(myGeoJsonLayer, "My GeoJSON Layer");
所有工作正常。
现在我想在我的图层上添加一个属性,但是如何?
任何建议表示赞赏。
你是什么意思与层的“归属”?请举个例子。 – 2014-09-04 12:58:03
Hi Marko!我的意思是这个http://leafletjs.com/reference.html#control-attribution。例如,您可以在地图右下角http://leafletjs.com/附近看到该属性。如果您在地图下的代码中看到,您会看到....归属地:'© OpenStreetMap贡献者'我很清楚如何为基于图块(Tilelayer)的图层添加归因,但我不知道如何使用一个GeoJson层。谢谢! – Cesare 2014-09-04 13:21:22