I try to load geoJson data in Mapbox and edit it with the plugin Leaflet.Draw When i click to the edit button, i have an error : Cannot set property 'original' of undefined
Layer is on the map, but I can't edit it.
Here is the code:
var map = L.map('map').setView( [40, 40], 2);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: '*******'
}).addTo(map);
// Initialise the FeatureGroup to store editable layers
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
L.geoJson(<%=RGeo::GeoJSON.encode(@field.shape).to_json.html_safe%>,
{
onEachFeature: function (feature, layer) {
drawnItems.addLayer(layer);
}
}).addTo(map);
// Initialise the draw control and pass it the FeatureGroup of editable layers
var drawControl = new L.Control.Draw({
draw : {
position : 'topleft',
polygon : true,
polyline : false,
rectangle : false,
circle : false,
marker: false
},
edit: {
featureGroup: drawnItems
},
}).addTo(map);
So, I found an answer. I'm trying to edit multipolygon, but leaflet.draw dont support them.
I switched to leaflet.editable