vue2-leaflet-draw
vue2-leaflet-draw copied to clipboard
On draw:created event for a polygon does not provide its coordinates.
Unlike happens when you create a rectangle, circle or a line you are not being provided with the polygon coordinates in the corresponding event.
{layer: NewClass, layerType: "polygon", type: "draw:created", target: NewClass, sourceTarget: NewClass}
layer: NewClass
layerType: "polygon"
sourceTarget: NewClass
target: NewClass
type: "draw:created"
I did not want to use the standard leaflet plugin for enable the draw functionality given that I have been able to get the most out of this project except for this little detail that is preventing me from deploying my app.
Can you point me in the right direction for overcoming this issue?
@fdvsilva - you should be able to get to coordinates from layer
with getLatLngs()
.
Assuming that your l-map
component has ref:"map"
on it, try this:
mounted() {
this.map = this.$refs.map;
this.map.mapObject.on('draw:created', (e) => {
console.log(e.layer.getLatLngs());
});
},
};
@trevelyanuk , thank you! It worked ;)