Closed jmoe closed 6 years ago
Hi @jmoe, no that's not possible right now. I'll mark it as a feature request and close the issue. If more upvotes are on this I will consider implementing it.
Function for L.PM.Edit.Line
:
continueDrawing(){
if(!this._map){
this._map = this._layer._map;
}
this._map.pm.enableDraw(this._shape);
this._layer.getLatLngs().flat(999).forEach((latlng)=>{
this._map.pm.Draw[this._shape]._createVertex({latlng});
});
this._layer.remove();
}
But a few things:
pm:vertexadded
is called when we move the currently available latlngs to the draw modeThis would be useful for me too, or is there another option to continue drawing a line?
This would be useful for me too, I'd like to upvote this request, or is there another option to continue drawing a line?
If anyone needs a quick fix for this I managed to plug into the existing event system to return a layer into draw mode. In my case I was targeting the polyline shape, but you can modify it to your needs:
// Listen for the Draw Line event
this.map.on("pm:drawstart", e => {
if (e.shape == "Line") {
// Find the first layer that was a line and also drawn by geoman
// This code assumes you only want one line drawn
// if you had multiple lines, you'll need to pass in the layer you're attempting to renenable
var existingLine = this.map.pm.getGeomanDrawLayers().find(layer => {
return layer.pm._shape == "Line"
});
if (existingLine !== undefined) {
// set the templayer as done in L.Draw.Line
existingLine._pmTempLayer = true;
// set the working layer to our existing layer
this.map.pm.Draw.Line._layer = existingLine;
existingLine.getLatLngs().forEach(latLng => this.map.pm.Draw.Line._createMarker(latLng));
// When geoman finishes drawing a line it will create a *new* polyline and add it to the map
// our existing layer will still exist on the map on top of the new polyline that geoman just added
// so add an event listener to remove our existing layer when we're done drawing to prevent duplicates
this.map.once("pm:drawend", finishEvent => {
this.map.removeLayer(existingLine);
});
}
}
});
Working for the latest leaflet version: 2.1.5. Note that it relies on "private" properties and those can be subject to change.
Would like to toggle the draw mode on an existing line object. Like toggleEdit expect putting it into draw mode with snapping and the cursor and hint line, etc.. Is this possible?