Reputation: 11
I need to add a name and ID to the properties of a GeoJSON object when drawing a shape with Leaflet Geoman.
I'm writing the layers to a custom layer group:
map.pm.setGlobalOptions({
layerGroup: stand_geojson_layer
});
I can successfully convert the drawn layer into GeoSON and console log it out. And even add to the properties in the resulting feature.
map.on('pm:create', (e) => {
var layer = e.layer;
var feature = layer.toGeoJSON();
feature.properties.name = 'Test Name';
console.log(feature);
});
The problem is that those properties aren't actually written to the layer it seems because when I get the whole FeatureSet into GeoJson the properties aren't there. I need to either add the properties to the layer itself before converting to GeoJSON or save / convert the added properties back into the layer somehow.
console.log(stand_geojson_layer.toGeoJSON());
Could anyone help as to how to get the properties into the layer or write them back?
Upvotes: 1
Views: 516