2014-09-04 442 views
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"); 

所有工作正常。

現在我想在我的圖層上添加一個屬性,但是如何?

任何建議表示讚賞。

+0

你是什麼意思與層的「歸屬」?請舉個例子。 – 2014-09-04 12:58:03

+0

Hi Marko!我的意思是這個http://leafletjs.com/reference.html#control-attribution。例如,您可以在地圖右下角http://leafletjs.com/附近看到該屬性。如果您在地圖下的代碼中看到,您會看到....歸屬地:'© OpenStreetMap貢獻者'我很清楚如何爲基於圖塊(Tilelayer)的圖層添加歸因,但我不知道如何使用一個GeoJson層。謝謝! – Cesare 2014-09-04 13:21:22

回答

相關問題