我有使用單張顯示geoJson數據。標記出現在地圖上,因爲它們應該是這樣,但我無法將彈出框綁定到它。如果我直接將它附加到標記上,則不會顯示任何內容。如果我將它附加到圖層上,它不會顯示,但標記會顯示。請看看並提出問題是什麼!geojson單張彈出不會出現或打破標記
function playgroundMarker(feature, layer){
var popupOptions = {width: 200};
var popupContent = "This is some content";
var marker = new L.icon({iconUrl: "lib/leaflet/images/play_icon.png"});
//L.marker.bindPopup(popupContent, popupOptions); - This breaks it
//layer.bindPopup(popupContent, popupOptions); - This just doesn't appear
layer.setIcon(marker);
};
var playground = L.geoJson(playgrounds, {
onEachFeature: playgroundMarker
}).addTo(map);
我對某事有點困惑 - 你是建議使用pointToLayer而不是onEachFeature或使用它們兩個嗎?謝謝你的答覆btw –