전단지 geoJSON.onEachFeature는 함수가 아닌가요? (leaflet geoJSON.onEachFeature is not a function?)


문제 설명

전단지 geoJSON.onEachFeature는 함수가 아닌가요? (leaflet geoJSON.onEachFeature is not a function?)

img src="https://i.stack.imgur.com/ngbxs.png" alt="enter image description here"></a></p>

저는 아직 전단지를 처음 접하고 문제의 출처를 파악하는 데 어려움을 겪습니다. 내가 놓치고 있는 것이 분명합니까?


참조 솔루션

방법 1:

You get undefined because your layer has no leaflet_id, because the layer is not already added to the map.

Change your code to:

geojson = L.geoJSON(pointfixed, {
        pointToLayer: function (feature, latlng){
            return L.circleMarker(latlng, {
                radius: 3,
                fillColor: getColor(feature.properties.Coordinate),
                color: "#000",
                fillOpacity: 1,
                weight: 1
                }); 
        },
}).addTo(map);

geojson.eachLayer(function(layer){
     layer.bindPopup("<button type='button' onclick = 'addToCart(" + layer._leaflet_id +")'>Add to Cart</button>");
});

(by Ryan Falke Design)

참조 문서

  1. leaflet geoJSON.onEachFeature is not a function? (CC BY‑SA 2.5/3.0/4.0)

#geojson #function #leaflet






관련 질문

Geodjango GeoJSON 직렬 변환기 기하학은 항상 'null'입니다. (Geodjango GeoJSON Serializer geometry always 'null')

전단지에서 레이어 켜기/끄기(더 복잡한 시나리오) (Toggle layers on and off in Leaflet (more complex scenario))

RethinkDB r.polygon() - GeoJSON LinearRing에는 최소 4개의 위치가 있어야 합니까? (RethinkDB r.polygon() - GeoJSON LinearRing must have at least four positions?)

Leaflet : GeoJSON 속성에서 GeoJSON 레이어 설정 아이콘 (Leaflet : setting icon for GeoJSON layer from GeoJSON property)

'GeoJsonLayer' 기호를 확인할 수 없습니다. (Cannot resolve symbol 'GeoJsonLayer ')

스키마의 mongoose geojson, "지역 키를 추출할 수 없습니다" 오류 (mongoose geojson in schema, "Can't extract geo keys" error)

Android Google 지도는 GeoJSON을 사용하여 마커를 설정합니다. (Android Google Maps set marker using GeoJSON)

GraphQl로 geojson 포인트를 쿼리하는 방법은 무엇입니까? (How to query a geojson point with GraphQl?)

geojson 포인트 데이터 마커가 전단지 맵에서 클러스터링되지 않습니다. (The geojson point data markers are not clustering in leaflet map)

전단지 geoJSON.onEachFeature는 함수가 아닌가요? (leaflet geoJSON.onEachFeature is not a function?)

Folium에서 특정 국가 강조 표시 (Highlight one specific country in Folium)

RGeo 및 Geojson으로 면적 계산 (Calculating area with RGeo and Geojson)







코멘트