Handling Leaflet Delete and Edit Event #2422
joseph-fidelis
started this conversation in
Ideas / Feature Requests
Replies: 2 comments 6 replies
-
Hi @joseph-fidelis, As far as I can tell, editing and deleting map objects is currently not supported. I just couldn't figure out how to add new layers so that the draw control knows they are editable. Here is what we've got so far: def handle_draw(e: events.GenericEventArguments):
if e.args['layerType'] == 'marker':
m.marker(latlng=(e.args['layer']['_latlng']['lat'],
e.args['layer']['_latlng']['lng']))
if e.args['layerType'] == 'polygon':
m.generic_layer(name='polygon', args=[e.args['layer']['_latlngs']])
draw_control = {
'draw': {
'polygon': True,
'marker': True,
'circle': False,
'rectangle': False,
'polyline': False,
'circlemarker': False,
},
'edit': False,
}
m = ui.leaflet(center=(51.505, -0.09), zoom=13, draw_control=draw_control)
m.on('draw:created', handle_draw) But in the official Leaflet example they work with a var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, { maxZoom: 18, attribution: osmAttrib }),
map = new L.Map('map', { center: new L.LatLng(51.505, -0.04), zoom: 13 }),
drawnItems = L.featureGroup().addTo(map);
L.control.layers({
'osm': osm.addTo(map),
"google": L.tileLayer('http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}', {
attribution: 'google'
})
}, { 'drawlayer': drawnItems }, { position: 'topleft', collapsed: false }).addTo(map);
map.addControl(new L.Control.Draw({
edit: {
featureGroup: drawnItems,
poly: {
allowIntersection: false
}
},
draw: {
polygon: {
allowIntersection: false,
showArea: true
}
}
}));
map.on(L.Draw.Event.CREATED, function (event) {
var layer = event.layer;
drawnItems.addLayer(layer);
}); Not sure how to do that in NiceGUI. But any ideas and suggestions are very welcome! |
Beta Was this translation helpful? Give feedback.
3 replies
-
@falkoschindler |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I currently can not handle editing and deleting of draw control items. The Draw-Control edit and delete button shows, but I they are disabled by default. Maybe I am doing something wrong
Beta Was this translation helpful? Give feedback.
All reactions