Whether to create a L.Editable instance at map init.
editOptions
hash
{}
Options to pass to L.Editable when instanciating.
EditableMixin
EditableMixin is included to L.Polyline, L.Polygon, L.Rectangle, L.Circle
and L.Marker. It adds some methods to them.
When editing is enabled, the editor is accessible on the instance with the
editor property.
Methods
Method
Returns
Description
enableEdit(<L.Map> map?)
this.editor
Enable editing, by creating an editor if not existing, and then calling enable on it.
editEnabled()
boolean
Return true if current instance has an editor attached, and this editor is enabled.
disableEdit()
Disable editing, also remove the editor property reference.
toggleEdit()
Enable or disable editing, according to current status.
Editable
Main edition handler. By default, it is attached to the map
as map.editTools property.
Leaflet.Editable is made to be fully extendable. You have three ways to customize
the behaviour: using options, listening to events, or extending.
Options
Option
Type
Default
Description
zIndex
int
1000
The default zIndex of the editing tools.
polygonClass
class
L.Polygon
Class to be used when creating a new Polygon.
polylineClass
class
L.Polyline
Class to be used when creating a new Polyline.
markerClass
class
L.Marker
Class to be used when creating a new Marker.
rectangleClass
class
L.Rectangle
Class to be used when creating a new Rectangle.
circleClass
class
L.Circle
Class to be used when creating a new Circle.
drawingCSSClass
string
'leaflet-editable-drawing'
CSS class to be added to the map container while drawing.
drawingCursor
const
'crosshair'
Cursor mode set to the map while drawing.
editLayer
Layer
new L.LayerGroup()
Layer used to store edit tools (vertex, line guide…).
featuresLayer
Layer
new L.LayerGroup()
Default layer used to store drawn features (Marker, Polyline…).
polylineEditorClass
class
PolylineEditor
Class to be used as Polyline editor.
polygonEditorClass
class
PolygonEditor
Class to be used as Polygon editor.
markerEditorClass
class
MarkerEditor
Class to be used as Marker editor.
rectangleEditorClass
class
RectangleEditor
Class to be used as Rectangle editor.
circleEditorClass
class
CircleEditor
Class to be used as Circle editor.
lineGuideOptions
hash
{}
Options to be passed to the line guides.
skipMiddleMarkers
boolean
false
Set this to true if you don't want middle markers.
vertexMarkerClass
class
VertexMarker
Class to be used as vertex, for path editing.
middleMarkerClass
class
VertexMarker
Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path.
Fired after a new shape is deleted in a multi (Polygon or Polyline).
Methods
Public methods
You will generally access them by the map.editTools
instance:
map.editTools.startPolyline();
Method
Returns
Description
drawing()
boolean
Return true if any drawing action is ongoing.
stopDrawing()
When you need to stop any ongoing drawing, without needing to know which editor is active.
commitDrawing()
When you need to commit any ongoing drawing, without needing to know which editor is active.
startPolyline(<L.LatLng> latlng, <hash> options)
L.Polyline
Start drawing a Polyline. If latlng is given, a first point will be added. In any case, continuing on user click.
If options is given, it will be passed to the Polyline class constructor.
startPolygon(<L.LatLng> latlng, <hash> options)
L.Polygon
Start drawing a Polygon. If latlng is given, a first point will be added. In any case, continuing on user click.
If options is given, it will be passed to the Polygon class constructor.
startMarker(<L.LatLng> latlng, <hash> options)
L.Marker
Start adding a Marker. If latlng is given, the Marker will be shown first at this point.
In any case, it will follow the user mouse, and will have a final latlng on next click (or touch).
If options is given, it will be passed to the Marker class constructor.
startRectangle(<L.LatLng> latlng, <hash> options)
L.Rectangle
Start drawing a Rectangle. If latlng is given, the Rectangle anchor will be added. In any case, continuing on user drag.
If options is given, it will be passed to the Rectangle class constructor.
startCircle(<L.LatLng> latlng, <hash> options)
L.Circle
Start drawing a Circle. If latlng is given, the Circle anchor will be added. In any case, continuing on user drag.
If options is given, it will be passed to the Circle class constructor.
BaseEditor
When editing a feature (Marker, Polyline…), an editor is attached to it. This
editor basically knows how to handle the edition.
Methods
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
MarkerEditor
Editor for Marker.
Methods
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
PathEditor
Base class for all path editors.
Methods
Method
Returns
Description
reset()
Rebuild edit elements (Vertex, MiddleMarker, etc.).
push()
Programmatically add a point while drawing.
pop()
L.LatLng or null
Programmatically remove last point (if any) while drawing.
newShape(<L.LatLng> latlng?)
Add a new shape (Polyline, Polygon) in a multi, and setup up drawing tools to draw it;
if optional latlng is given, start a path at this point.
deleteShapeAt(<L.LatLng> latlng)
Array
Remove a path shape at the given latlng.
appendShape(<Array> shape)
Append a new shape to the Polygon or Polyline.
prependShape(<Array> shape)
Prepend a new shape to the Polygon or Polyline.
insertShape(<Array> shape, <int> index)
Insert a new shape to the Polygon or Polyline at given index (default is to append).
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
PolylineEditor
Methods
Method
Returns
Description
continueBackward(<Array> latlngs?)
Set up drawing tools to continue the line backward.
continueForward(<Array> latlngs?)
Set up drawing tools to continue the line forward.
splitShape(<Array> latlngs?, <int> index)
Split the given latlngs shape at index index and integrate new shape in instance latlngs.
Method
Returns
Description
reset()
Rebuild edit elements (Vertex, MiddleMarker, etc.).
push()
Programmatically add a point while drawing.
pop()
L.LatLng or null
Programmatically remove last point (if any) while drawing.
newShape(<L.LatLng> latlng?)
Add a new shape (Polyline, Polygon) in a multi, and setup up drawing tools to draw it;
if optional latlng is given, start a path at this point.
deleteShapeAt(<L.LatLng> latlng)
Array
Remove a path shape at the given latlng.
appendShape(<Array> shape)
Append a new shape to the Polygon or Polyline.
prependShape(<Array> shape)
Prepend a new shape to the Polygon or Polyline.
insertShape(<Array> shape, <int> index)
Insert a new shape to the Polygon or Polyline at given index (default is to append).
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
PolygonEditor
Methods
Method
Returns
Description
newHole(<L.LatLng> latlng?, <int> index)
Set up drawing tools for creating a new hole on the Polygon. If the latlng param is given, a first point is created.
Method
Returns
Description
reset()
Rebuild edit elements (Vertex, MiddleMarker, etc.).
push()
Programmatically add a point while drawing.
pop()
L.LatLng or null
Programmatically remove last point (if any) while drawing.
newShape(<L.LatLng> latlng?)
Add a new shape (Polyline, Polygon) in a multi, and setup up drawing tools to draw it;
if optional latlng is given, start a path at this point.
deleteShapeAt(<L.LatLng> latlng)
Array
Remove a path shape at the given latlng.
appendShape(<Array> shape)
Append a new shape to the Polygon or Polyline.
prependShape(<Array> shape)
Prepend a new shape to the Polygon or Polyline.
insertShape(<Array> shape, <int> index)
Insert a new shape to the Polygon or Polyline at given index (default is to append).
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
RectangleEditor
Methods
Method
Returns
Description
reset()
Rebuild edit elements (Vertex, MiddleMarker, etc.).
push()
Programmatically add a point while drawing.
pop()
L.LatLng or null
Programmatically remove last point (if any) while drawing.
newShape(<L.LatLng> latlng?)
Add a new shape (Polyline, Polygon) in a multi, and setup up drawing tools to draw it;
if optional latlng is given, start a path at this point.
deleteShapeAt(<L.LatLng> latlng)
Array
Remove a path shape at the given latlng.
appendShape(<Array> shape)
Append a new shape to the Polygon or Polyline.
prependShape(<Array> shape)
Prepend a new shape to the Polygon or Polyline.
insertShape(<Array> shape, <int> index)
Insert a new shape to the Polygon or Polyline at given index (default is to append).
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
CircleEditor
Methods
Method
Returns
Description
reset()
Rebuild edit elements (Vertex, MiddleMarker, etc.).
push()
Programmatically add a point while drawing.
pop()
L.LatLng or null
Programmatically remove last point (if any) while drawing.
newShape(<L.LatLng> latlng?)
Add a new shape (Polyline, Polygon) in a multi, and setup up drawing tools to draw it;
if optional latlng is given, start a path at this point.
deleteShapeAt(<L.LatLng> latlng)
Array
Remove a path shape at the given latlng.
appendShape(<Array> shape)
Append a new shape to the Polygon or Polyline.
prependShape(<Array> shape)
Prepend a new shape to the Polygon or Polyline.
insertShape(<Array> shape, <int> index)
Insert a new shape to the Polygon or Polyline at given index (default is to append).
Method
Returns
Description
enable()
this
Set up the drawing tools for the feature to be editable.
disable()
this
Remove the drawing tools for the feature.
drawing()
boolean
Return true if any drawing action is ongoing with this editor.
VertexMarker
Handler for dragging path vertices.
Methods
Public methods
The marker used to handle path vertex. You will usually interact with a VertexMarker
instance when listening for events like editable:vertex:ctrlclick.
Method
Returns
Description
delete()
Delete a vertex and the related LatLng.
getIndex()
int
Get the index of the current vertex among others of the same LatLngs group.
getLastIndex()
int
Get last vertex index of the LatLngs group of the current vertex.