Skip to content

Pluggable map widgets for Django Postgis fields

License

Notifications You must be signed in to change notification settings

HaylLtd/django-map-widgets

 
 

Repository files navigation

Coverage Status Build Status PyPI version

Django Map Widgets

Configurable, pluggable and more user friendly map widgets for Django PostGIS fields.

Achievements

The aim of the Django map widgets is to make all Geo Django widgets more user-friendly and configurable.

Django map widgets package has support for Mapbox and Google Map services currently, if you want to see more widgets and think you can help, feel free to contribute to the project.
We would be happy to review and merge your contributions. :)

Installation

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>

Requirements

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 add map widgets to your django admin forms.

Screenshots

Google Map Point Field Widget

MapBox Map Point Field Widget

Google Map Static Overlay Widget

This widget is working with Magnific Popup jQuery plugin.

Release Notes

0.4.2

  • GooglePointFieldInlineWidget bug fixes for Django 4.2.x (#142), thanks for @isarota.
  • Added .readthedocs.yaml to cover new Read the Docs updates.

0.4.1

  • Added scroll wheel zooming functionality switch to Google Point Map Settings. (#134)
  • Added Chinese(ZH) localisation support. (#133)

0.4.0

  • Supported MapBox Map for Django Geo Point Field.
  • Fixed undefined place object binding issue in javascript triggers. (#125)
  • Documented MapBox point field map widget features.
  • Updated various localize files.

0.3.3

0.3.2

0.3.1

  • Removed six package usages. (#117)
  • Added a new general widget setting in order to specify Google JS libraries. (#119)
  • Implemented some improvements for the demo project.

0.3.0

  • Implemented a new demo project with Django 2.x.
  • Fixed Django Admin jQuery conflicts. (#100)
  • Fixed a new widget JS instance initialising issue for Django Admin Inlines. (#84)
  • Added Python 3.8 env settings to TravisCI configuration.

See release notes for all versions.

About

Pluggable map widgets for Django Postgis fields

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 43.1%
  • Python 34.9%
  • CSS 11.9%
  • HTML 8.9%
  • Other 1.2%