I have a Leaflet based map on which a user can click to create a marker. Then, if one clicks on the marker a popup is opening, where one can change text in a textarea, activate the camera of the mobile device and save all markers with feature properties into a geoJSON.
I initialize an empty L.featureGroup()
, generate dynamic HTML popupContent inside an addMarker(e){}
function and add all this data to an object, that is being created via .toGeoJSON()
, where I can access feature.properties
. Because it is overwritten each time, I have to write all properties into another array infoTextArray
Is there a efficent way to directly write a feature's properties on creation?
edit: to further specify my question:
I want to assign my geoJSON features properties when they're created. I tried something like:
let layerGroup = L.geoJSON([], {
pointToLayer: function (feature) {
feature.properties.infoText='';
feature.properties.imageURL='';
},
onEachFeature: function (feature) {
feature.properties.infoText='';
feature.properties.imageURL='';
}
}).addTo(map);
layerGroup.toGEOJSON()
still returns an empty feature properties object. I'm guessing my functions aren't triggered, when a new features is added to the layer.