My django web application should do the following: pass the Geojson object to the view, display the elevator points and display additional information when the user clicks on the point marker. I am not very familiar with js, so I got attached to the correct data type for the click event. Here is an example geojson object. How can I access the "id" with my click event?
var geojsonFeature = {'geometry': {'type': 'MultiPoint', 'coordinates': [[4.939, 52.33], [4.9409, 52.33]] }, 'type': 'Feature', 'properties': {'id': '52','popupContent': 'id=52'} };
Adding a geojson object to the map.
var gj = L.geoJson(geojsonFeature, { pointToLayer: function (feature, latlng) { return L.circleMarker(latlng, geojsonMarkerOptions); }}).addTo(map);
And on() -click ....
gj.on('click', function(evt) { alert(id)
NOTE. I don't want to use something like bindPopup(feature.properties.popupContent) , because I want to open a new window that brings up another django view with some extra data from the database.
Larsvegas
source share