2016-04-07 14 views

答えて

2

map.eachLayerではなく、L.geoJson自体で.eachLayer methodを使用する必要があります。たとえば:

var geoJsonLayer = L.geoJson(myGeoJson).addTo(map); 

geoJsonLayer.eachLayer(function(layer) { 
    layer.bindPopup(feature.properties.name); 
}); 

またonEachFeature optionを使用して、あなたはL.geoJsonの作成時に各機能に適用される関数を指定することができます。

+0

あなたの例では小さなバグ: 'layer.bindPopup(feature.properties.name);' は次のようになります。 'layer.bindPopup(layer.feature.properties.name);' – PauliusZ

関連する問題