django-leaflet
                                
                                 django-leaflet copied to clipboard
                                
                                    django-leaflet copied to clipboard
                            
                            
                            
                        Show other objects in widget
It should be really useful to show objects based on custom filter when creating/editing a geometry in the map. I've been looking for a long time to manage it without success.
Could you give us some details about what you are trying to achieve (with a concrete example or some code) ? It looks like it could be done but not sure if we have the same idea in mind...
Yes of course. Imagine I have two classes: PolygonField and PointField. I would like when creating/editing one of them that all the other objects could be showed in the map widget (for example in order to not overlap two regions). I imagine it can be certainly achieved but can't figure it out.
I hope you all understand, thanks a lot, and thanks for django leaflet it's amazing.
Thanks for the positive feedback !
I see what you would like to do. We did those things in django-mapentity, using custom leafletwidget javascript classes. https://github.com/makinacorpus/django-mapentity/blob/master/mapentity/static/mapentity/mapentity.forms.js#L68-L117
But it looks like a custom use case, and maybe it should be adressed by django-lealfet directly. If you have an idea of how you would like to use this kind of extra layers options, don't hesitate to comment.
Currently you can also use the load event of the widget and add stuff there (like a GeoJSON layer rendered by the server on this model):
         map.on('map:loadfield', function (e) {
                    // e.target : map
                    // e.field
                    // e.fieldid
                });
Thanks for the answer, I was trying to offload the js side from some logic and wanted to achieve all I wanted to do in plain Django. I will try to see if mapentity suits my needs. However, it should be really amazing if one could override the form widget queryset (I know it's not the case but just to render the idea) in order to display not only the things you are editing but all of them.
If I will find a solution with low impact I will submit you a pull request. Thanks a lot ;)
On Thu, May 7, 2015 at 10:49 PM, Mathieu Leplatre [email protected] wrote:
Thanks for the positive feedback !
I see what you would like to do. We did those things in django-mapentity, using custom leafletwidget javascript classes. https://github.com/makinacorpus/django-mapentity/blob/master/mapentity/static/mapentity/mapentity.forms.js#L68-L117
But it looks like a custom use case, and maybe it should be adressed by django-lealfet directly. If you have an idea of how you would like to use this kind of extra layers options, don't hesitate to comment.
Currently you can also use the load event of the widget and add stuff there (like a GeoJSON layer rendered by the server on this model):
map.on('map:loadfield', function (e) { // e.target : map // e.field // e.fieldid });— Reply to this email directly or view it on GitHub https://github.com/makinacorpus/django-leaflet/issues/104#issuecomment-100014829 .
Alessandro Bucciarelli
Any news to share ? :)