Does someone know a simple way to set the default zoom and latitude/longitude with floppyforms.gis.BaseGMapWidget ? And additionally, when creating an entry set panning as default tool.
In the form i define:
class PointWidget(floppyforms.gis.PointWidget, floppyforms.gis.BaseGMapWidget):
map_width = 690
map_height = 300
class EventForm(ModelForm):
class Meta:
model = Event
widgets = {
'coordinates': PointWidget(),
}
This perfectly shows the map widget and i can set a point. It also nicely centers & zooms the point when loading the form for an existing entry.
But when displaying the form to create a new entry it centers at the west-cost of africa..
Is there a way to achieve this (preferably by defining in the form/widget-class and not using additional javascript).
First, override
get_context_data()on your widget class and point itto a custom template:
Then create the
custom_lonlat.htmltemplate:If you want to make the default lon/lat dynamic, you can set them directly on the form instance from your views code:
I’m the author of floppyforms and I’ve seen this question a couple of times… I’ll add this answer to the official docs soon.