2016-11-07 2 views
0

Ich habe eine Ebene, die mehrere circleMarker von einem GeoJSON haben.Leaflet: Fügen Sie Popup auf eine Ebene mit GeoJSON

var geojsonMarkerOptions = { 
    radius: 8, 
    fillColor: "#ff7800", 
    color: "#000", 
    weight: 1, 
    opacity: 1, 
    fillOpacity: 0.8 
}; 

L.geoJSON(someGeojsonFeature, { 
    pointToLayer: function (feature, latlng) { 
     return L.circleMarker(latlng, geojsonMarkerOptions); 
    } 
}).addTo(map); 

Wie kann ich auf ein Pop-up in den einzelnen circleMarker wo Benutzer auf jedem Kreis klicken können, um ein Popup zu bekommen?

+1

Sie können die .bindPopup() Funktion in der Broschüre [Dokumentation] beschrieben verwenden (http://leafletjs.com/examples/quick-start/). – Felix

+0

Wie man die .bindPopup() an der richtigen Stelle setzt? – Tenz

Antwort

0

dieses Probieren Sie:

var geojsonMarkerOptions = { 
    radius: 8, 
    fillColor: "#ff7800", 
    color: "#000", 
    weight: 1, 
    opacity: 1, 
    fillOpacity: 0.8 
}; 

L.geoJSON(someGeojsonFeature, { 
    pointToLayer: function (feature, latlng) { 
     var mypopup = L.popup().setContent("latlng: " + latlng); 
     var mymarker = L.circleMarker(latlng, geojsonMarkerOptions); 

     mymarker.bindPopup(mypopup); 
     return mymarker;    
    } 
}).addTo(map); 
Verwandte Themen