Configurable, pluggable and more user friendly map widgets for Django PostGIS fields.
- Documentation: http://django-map-widgets.readthedocs.io/
- Project Home Page: https://github.com/erdem/django-map-widgets/
The aim of the Django map widgets is to make all Geo Django widgets more user friendly and configurable. Map widgets support major map services (GoogleMaps, OpenStreetMap) for your geoDjango fields.
pip install django-map-widgets
Add ‘map_widgets’ to your INSTALLED_APPS
in settings.py
INSTALLED_APPS = [
...
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mapwidgets',
]
Collects the static files into STATIC_ROOT
.
python manage.py collectstatic
Django Admin
from django.contrib.gis.db import models
from mapwidgets.widgets import GooglePointFieldWidget
class CityAdmin(admin.ModelAdmin):
formfield_overrides = {
models.PointField: {"widget": GooglePointFieldWidget}
}
Django Forms
from mapwidgets.widgets import GooglePointFieldWidget, GoogleStaticOverlayMapWidget
class CityForm(forms.ModelForm):
class Meta:
model = City
fields = ("coordinates", "city_hall")
widgets = {
'coordinates': GooglePointFieldWidget,
'city_hall': GoogleStaticOverlayMapWidget,
}
...and your template should look something like this
<form method="POST" action="">
{% csrf_token %}
{{form.media}}
{{form.as_p}}
</form>
Django Map Widgets needs Jquery dependency to work in your regular views. In Django Admin case, you don't need to provide the jQuery just because it's already available on django.jQuery
namespace.
This widget is working with Magnific Popup jQuery plugin.
- Google Place Autocomplete object binding to jQuery triggers.
- Implemented Google Geocoding support for the marker coordinates.
- Added custom widget settings feature for each widget.
- Added Portuguese localisation support.
- Fixed Google Place Autocomplete widget bugs in Django Admin Inlines.
- Fixed Python 3.6 errors.
- Fixed Javascript bugs.
- The GitHub repository Integrated with Travis CI.
- Implemented unit tests for backend code. (%100 code coverage)
- Change development environment from Vagrant to Docker.
- Full documentation integrated to readthedocs.org.
- Fixed Google Map static widget issues.
- Added Russian localisation support.
- Added [Google Places Autocomplete] options support.
- Fixed CSS issues.