Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableEdit is not a function with L.Layer class #191

Open
Milkker opened this issue Aug 26, 2019 · 1 comment
Open

enableEdit is not a function with L.Layer class #191

Milkker opened this issue Aug 26, 2019 · 1 comment

Comments

@Milkker
Copy link

Milkker commented Aug 26, 2019

I am try to add Leaflet layer from well know text(wkt).
I found it does not include EditableMixin cause that layer.enableEdit is not a function error.

if (L.Polyline) {
L.Polyline.include(EditableMixin);
L.Polyline.include(PolylineMixin);
L.Polyline.addInitHook(keepEditable);
}
if (L.Polygon) {
L.Polygon.include(EditableMixin);
L.Polygon.include(PolygonMixin);
}
if (L.Marker) {
L.Marker.include(EditableMixin);
L.Marker.include(MarkerMixin);
L.Marker.addInitHook(keepEditable);
}
if (L.Rectangle) {
L.Rectangle.include(EditableMixin);
L.Rectangle.include(RectangleMixin);
}
if (L.Circle) {
L.Circle.include(EditableMixin);
L.Circle.include(CircleMixin);
}

How can I use enableEdit method with layer class?
Sample code:http://jsfiddle.net/Lhq0ance/8

@charlieforward9
Copy link
Sponsor

Make sure you are importing leaflet-editable AFTER leaflet & react-leaflet. This import augments the leaflet module with the editable fields.

import { ... } from "leaflet";
import { ... } from "react-leaflet";
import "leaflet-editable"; //Imports the augmented Leaflet module

Ref: https://stackoverflow.com/questions/40136890/this-props-enableedit-is-not-a-function-error-while-executing-function/78531060#78531060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants