django-location-field
django-location-field copied to clipboard
Support centered map without marker
The location field might seem currently required, as there is always a marker on the map. It can be difficult so to track when the address has not been found for example, or when the user didn't touch the marker.
This tries to surround that by introducing a new option: map.center
. If the field has no value, instead of using 0,0
as default - or setting an initial value which can disturb the user - the marker is hidden and the map is panned to this position. As soon as the user click on the map or a location is found, the marker is shown. However, if the field has a value, the current behavior is kept and map.center
is not taken into account.
What do you think? If you approve that, my next plan is to allow one to override this value at model, form or widget level...
Note that there will be a conflict if #117 is merged that I will fix.
I'm wondering if we should use what's defined in field's default value, for example:
location = LocationField(based_fields=['city'], zoom=7, default=Point(1.0, 1.0))
The problem I see with default value is that it prevent to have an empty one. I have several cases where I want to keep an empty value if the user didn't set the marker on the map - or if no position has been found for based_fields
- to prevent to have wrong geolocalization... So I think about this solution instead of always overriding clean()
method to empty the value if it's the same as the default. Do you see any other way to do that?
@jeromelebleu can you please provide a video/gif on how this works?
Also it would need a rebase, thanks!
@caioariede I have rebased and fix the conflict! I am not sure to find the time at the moment to provide a video/gif, but I could at least document it a bit more and maybe add it to the example application? By the way, did you succeed to try it?
@jeromelebleu yes, if you could add it to the example application would be great!
btw, the gif can be easily created using LICEcap (just a tip)