django-map-widgets


Namedjango-map-widgets JSON
Version 0.5.1 PyPI version JSON
download
home_pagehttps://github.com/erdem/django-map-widgets
SummaryConfigurable and user-friendly map widgets for GeoDjango fields
upload_time2024-07-09 17:37:50
maintainerNone
docs_urlNone
authorErdem Ozkol
requires_pythonNone
licenseMIT
keywords django map-widgets geodjango geolocation mapbox google map leaflet interactive-maps
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://badge.fury.io/py/django-map-widgets.svg
   :target: https://badge.fury.io/py/django-map-widgets

Django Map Widgets
==================

Django Map Widgets is a package that provides highly configurable, pluggable, and user-friendly map widgets for
GeoDjango form fields. It simplifies the integration of interactive maps into GeoDjango applications, enhancing the
overall development experience.

The primary goal of Django Map Widgets is to bridge the gap between powerful GeoDjango functionality and user-friendly
map interactions, creating a more accessible and enjoyable experience for both developers and end-users of
GeoDjango-powered applications. Currently, the package supports Google, Mapbox, and Leaflet mapping platforms.

.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/f2df8654-b29a-4d64-9159-87a3790ede0b
   :alt: Mapbox Interactive Widget



- `Documentation <http://django-map-widgets.readthedocs.io/>`_
- `Demo Project <https://github.com/erdem/django-map-widgets/tree/main/demo>`_
- `Home Page <https://github.com/erdem/django-map-widgets/>`_

Installation
~~~~~~~~~~~~

.. code-block:: shell

    pip install django-map-widgets

Add 'mapwidgets' to your ``INSTALLED_APPS`` in settings.py

.. code-block:: python

    INSTALLED_APPS = [
        ...
        'django.contrib.sessions',
        'django.contrib.staticfiles',

        'mapwidgets',
    ]

Ensure ``collectstatic`` Django admin command is run before using the widgets in production.

.. code-block:: shell

    python manage.py collectstatic

Usage
~~~~~

**Django Admin Usage**

.. code-block:: python

    from django.contrib.gis.db import models
    import mapwidgets


    class CityAdmin(admin.ModelAdmin):
        formfield_overrides = {
            models.PointField: {"widget": mapwidgets.GoogleMapPointFieldWidget}
        }

**Django Forms Usage**

.. code-block:: python

    from mapwidgets.widgets import GoogleMapPointFieldWidget, MapboxPointFieldWidget


    class CityForm(forms.ModelForm):
        class Meta:
            model = City
            fields = ("coordinates", "city_hall")
            widgets = {
                'coordinates': GoogleMapPointFieldWidget,
                'city_hall': MapboxPointFieldWidget,
            }

When the map widgets are used in Django web views with forms, Remember to include ``{{ form.media }}`` template tag in the
view templates.

Settings
~~~~~~~~

The JavaScript map rendering behavior of the widgets can be customized by providing ``MAP_WIDGETS`` config in the
project's settings file. For detailed guidance on map customization options, check
the `settings guide <http://django-map-widgets.readthedocs.io/settings>`_.

.. code-block:: python

    GOOGLE_MAP_API_KEY = os.getenv("GOOGLE_MAP_API_KEY")
    MAPBOX_ACCESS_TOKEN = os.getenv("MAPBOX_ACCESS_TOKEN")

    MAP_WIDGETS = {
        "GoogleMap": {
            "apiKey": GOOGLE_MAP_API_KEY,
            "PointField": {
                "interactive": {
                    "mapOptions": {
                        "zoom": 15,  # set initial zoom
                        "streetViewControl": False,
                    },
                    "GooglePlaceAutocompleteOptions": {
                        "componentRestrictions": {"country": "uk"}
                    },
                }
            }
        },
        "Mapbox": {
            "accessToken": MAPBOX_ACCESS_TOKEN,
            "PointField": {
                "interactive": {
                    "mapOptions": {"zoom": 12, "center": (51.515618, -0.091998)},
                    "markerFitZoom": 14,
                }
            },
        },
        "Leaflet": {
            "PointField": {
                "interactive": {
                    "mapOptions": {
                        "zoom": 12,
                        "scrollWheelZoom": False
                    }
                }
            },
            "markerFitZoom": 14,
        }
    }

JQuery Requirement
~~~~~~~~~~~~~~~~~~

jQuery is required for Django Map Widgets to function in regular Django views. However, if the widgets is being used
within the Django Admin, jQuery does not need to be provided separately. Any map widget class can be configured as
described in the documentation, and they will work out of the box.

Preferable jQuery version is ``3.7-slim``.

Support
~~~~~~~

Django Map Widgets offers two types of widgets:

1. **Interactive (Dynamic) Widgets**: These widgets allow users to interact with the map, such as clicking to set a
   location or dragging a marker. They are ideal for data input and editing scenarios.

2. **Static (Read-only) Widgets**: These widgets display map data in a non-interactive format. They are useful for
   presenting location information without allowing modifications.

**Widget Support Matrix**

+------------------------+-------------+--------+-------------+--------+-------------+--------+
| **GeoDjango Field**    | **GoogleMap**        | **Mapbox**           | **Leaflet**          |
+------------------------+-------------+--------+-------------+--------+-------------+--------+
|                        | Interactive | Static | Interactive | Static | Interactive | Static |
+========================+=============+========+=============+========+=============+========+
| *PointField*           | ✅          | ✅     | ✅          | ✅     | ✅          | N/A    |
+------------------------+-------------+--------+-------------+--------+-------------+--------+
| *LineStringField*      | ✖️          | ✖️     | ✖️          | ✖️     | ✖️          | N/A    |
+------------------------+-------------+--------+-------------+--------+-------------+--------+
| *PolygonField*         | ✖️          | ✖️     | ✖️          | ✖️     | ✖️          | N/A    |
+------------------------+-------------+--------+-------------+--------+-------------+--------+
| *MultiPointField*      | ✖️          | ✖️     | ✖️          | ✖️     | ✖️          | N/A    |
+------------------------+-------------+--------+-------------+--------+-------------+--------+
| *MultiLineStringField* | ✖️          | ✖️     | ✖️          | ✖️     | ✖️          | N/A    |
+------------------------+-------------+--------+-------------+--------+-------------+--------+
| *MultiPolygonField*    | ✖️          | ✖️     | ✖️          | ✖️     | ✖️          | N/A    |
+------------------------+-------------+--------+-------------+--------+-------------+--------+

Contribution
~~~~~~~~~~~~

Currently, the package supports Google, Mapbox, and Leaflet mapping platforms. If you have ideas for additional map
providers or new features, or even if you want to help extend support to other GeoDjango form fields, feel free to do
so. We would be happy to review and merge your contributions.

For more info how to contribute, please check out
the `contribution guidelines <http://django-map-widgets.readthedocs.io/contribution>`_.

Screenshots
~~~~~~~~~~~

MapBox Interactive Point Field Widget
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/e6e454f0-6486-4fe7-a0b3-712b9371030a
   :alt: MapBox Interactive Point Field Widget

MapBox Static Point Field Widget
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/491f2091-5620-4a50-9ed8-d63ddba3a88b
   :alt: MapBox Static Point Field Widget

GoogleMap Interactive Point Field Widget
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/4da33221-20f6-4c44-875c-f1d4b0f98e5a
   :alt: GoogleMap Interactive Point Field Widget

Leaflet Interactive Point Field Widget
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/a45158f7-2ec0-4e1a-8dfa-8da0442b832f
   :alt: Leaflet Interactive Point Field Widget

and more...

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/erdem/django-map-widgets",
    "name": "django-map-widgets",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django map-widgets geodjango geolocation mapbox google map leaflet interactive-maps",
    "author": "Erdem Ozkol",
    "author_email": "mapwidgets@erdemozkol.com",
    "download_url": "https://files.pythonhosted.org/packages/78/50/651dae7335fc9c6df7b1ab27c49b1cc98245ac0d61750538a192da19e671/django_map_widgets-0.5.1.tar.gz",
    "platform": null,
    "description": ".. image:: https://badge.fury.io/py/django-map-widgets.svg\n   :target: https://badge.fury.io/py/django-map-widgets\n\nDjango Map Widgets\n==================\n\nDjango Map Widgets is a package that provides highly configurable, pluggable, and user-friendly map widgets for\nGeoDjango form fields. It simplifies the integration of interactive maps into GeoDjango applications, enhancing the\noverall development experience.\n\nThe primary goal of Django Map Widgets is to bridge the gap between powerful GeoDjango functionality and user-friendly\nmap interactions, creating a more accessible and enjoyable experience for both developers and end-users of\nGeoDjango-powered applications. Currently, the package supports Google, Mapbox, and Leaflet mapping platforms.\n\n.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/f2df8654-b29a-4d64-9159-87a3790ede0b\n   :alt: Mapbox Interactive Widget\n\n\n\n- `Documentation <http://django-map-widgets.readthedocs.io/>`_\n- `Demo Project <https://github.com/erdem/django-map-widgets/tree/main/demo>`_\n- `Home Page <https://github.com/erdem/django-map-widgets/>`_\n\nInstallation\n~~~~~~~~~~~~\n\n.. code-block:: shell\n\n    pip install django-map-widgets\n\nAdd 'mapwidgets' to your ``INSTALLED_APPS`` in settings.py\n\n.. code-block:: python\n\n    INSTALLED_APPS = [\n        ...\n        'django.contrib.sessions',\n        'django.contrib.staticfiles',\n\n        'mapwidgets',\n    ]\n\nEnsure ``collectstatic`` Django admin command is run before using the widgets in production.\n\n.. code-block:: shell\n\n    python manage.py collectstatic\n\nUsage\n~~~~~\n\n**Django Admin Usage**\n\n.. code-block:: python\n\n    from django.contrib.gis.db import models\n    import mapwidgets\n\n\n    class CityAdmin(admin.ModelAdmin):\n        formfield_overrides = {\n            models.PointField: {\"widget\": mapwidgets.GoogleMapPointFieldWidget}\n        }\n\n**Django Forms Usage**\n\n.. code-block:: python\n\n    from mapwidgets.widgets import GoogleMapPointFieldWidget, MapboxPointFieldWidget\n\n\n    class CityForm(forms.ModelForm):\n        class Meta:\n            model = City\n            fields = (\"coordinates\", \"city_hall\")\n            widgets = {\n                'coordinates': GoogleMapPointFieldWidget,\n                'city_hall': MapboxPointFieldWidget,\n            }\n\nWhen the map widgets are used in Django web views with forms, Remember to include ``{{ form.media }}`` template tag in the\nview templates.\n\nSettings\n~~~~~~~~\n\nThe JavaScript map rendering behavior of the widgets can be customized by providing ``MAP_WIDGETS`` config in the\nproject's settings file. For detailed guidance on map customization options, check\nthe `settings guide <http://django-map-widgets.readthedocs.io/settings>`_.\n\n.. code-block:: python\n\n    GOOGLE_MAP_API_KEY = os.getenv(\"GOOGLE_MAP_API_KEY\")\n    MAPBOX_ACCESS_TOKEN = os.getenv(\"MAPBOX_ACCESS_TOKEN\")\n\n    MAP_WIDGETS = {\n        \"GoogleMap\": {\n            \"apiKey\": GOOGLE_MAP_API_KEY,\n            \"PointField\": {\n                \"interactive\": {\n                    \"mapOptions\": {\n                        \"zoom\": 15,  # set initial zoom\n                        \"streetViewControl\": False,\n                    },\n                    \"GooglePlaceAutocompleteOptions\": {\n                        \"componentRestrictions\": {\"country\": \"uk\"}\n                    },\n                }\n            }\n        },\n        \"Mapbox\": {\n            \"accessToken\": MAPBOX_ACCESS_TOKEN,\n            \"PointField\": {\n                \"interactive\": {\n                    \"mapOptions\": {\"zoom\": 12, \"center\": (51.515618, -0.091998)},\n                    \"markerFitZoom\": 14,\n                }\n            },\n        },\n        \"Leaflet\": {\n            \"PointField\": {\n                \"interactive\": {\n                    \"mapOptions\": {\n                        \"zoom\": 12,\n                        \"scrollWheelZoom\": False\n                    }\n                }\n            },\n            \"markerFitZoom\": 14,\n        }\n    }\n\nJQuery Requirement\n~~~~~~~~~~~~~~~~~~\n\njQuery is required for Django Map Widgets to function in regular Django views. However, if the widgets is being used\nwithin the Django Admin, jQuery does not need to be provided separately. Any map widget class can be configured as\ndescribed in the documentation, and they will work out of the box.\n\nPreferable jQuery version is ``3.7-slim``.\n\nSupport\n~~~~~~~\n\nDjango Map Widgets offers two types of widgets:\n\n1. **Interactive (Dynamic) Widgets**: These widgets allow users to interact with the map, such as clicking to set a\n   location or dragging a marker. They are ideal for data input and editing scenarios.\n\n2. **Static (Read-only) Widgets**: These widgets display map data in a non-interactive format. They are useful for\n   presenting location information without allowing modifications.\n\n**Widget Support Matrix**\n\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n| **GeoDjango Field**    | **GoogleMap**        | **Mapbox**           | **Leaflet**          |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n|                        | Interactive | Static | Interactive | Static | Interactive | Static |\n+========================+=============+========+=============+========+=============+========+\n| *PointField*           | \u2705          | \u2705     | \u2705          | \u2705     | \u2705          | N/A    |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n| *LineStringField*      | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | N/A    |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n| *PolygonField*         | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | N/A    |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n| *MultiPointField*      | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | N/A    |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n| *MultiLineStringField* | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | N/A    |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n| *MultiPolygonField*    | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | \u2716\ufe0f     | \u2716\ufe0f          | N/A    |\n+------------------------+-------------+--------+-------------+--------+-------------+--------+\n\nContribution\n~~~~~~~~~~~~\n\nCurrently, the package supports Google, Mapbox, and Leaflet mapping platforms. If you have ideas for additional map\nproviders or new features, or even if you want to help extend support to other GeoDjango form fields, feel free to do\nso. We would be happy to review and merge your contributions.\n\nFor more info how to contribute, please check out\nthe `contribution guidelines <http://django-map-widgets.readthedocs.io/contribution>`_.\n\nScreenshots\n~~~~~~~~~~~\n\nMapBox Interactive Point Field Widget\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/e6e454f0-6486-4fe7-a0b3-712b9371030a\n   :alt: MapBox Interactive Point Field Widget\n\nMapBox Static Point Field Widget\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/491f2091-5620-4a50-9ed8-d63ddba3a88b\n   :alt: MapBox Static Point Field Widget\n\nGoogleMap Interactive Point Field Widget\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/4da33221-20f6-4c44-875c-f1d4b0f98e5a\n   :alt: GoogleMap Interactive Point Field Widget\n\nLeaflet Interactive Point Field Widget\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. image:: https://github.com/erdem/django-map-widgets/assets/1518272/a45158f7-2ec0-4e1a-8dfa-8da0442b832f\n   :alt: Leaflet Interactive Point Field Widget\n\nand more...\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Configurable and user-friendly map widgets for GeoDjango fields",
    "version": "0.5.1",
    "project_urls": {
        "Demo Project": "https://github.com/erdem/django-map-widgets/tree/main/demo",
        "Documentation": "https://django-map-widgets.readthedocs.io/",
        "Homepage": "https://github.com/erdem/django-map-widgets",
        "Source": "https://github.com/erdem/django-map-widgets"
    },
    "split_keywords": [
        "django",
        "map-widgets",
        "geodjango",
        "geolocation",
        "mapbox",
        "google",
        "map",
        "leaflet",
        "interactive-maps"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e757f1782c9fa3c07c2ca63ce7b65c4838afb568a5ea71aa119aaa9dc456d8b",
                "md5": "80bf68b0314a2d47be53623a80098b7a",
                "sha256": "7307935163b46c6a2a225c85c91c7262a8b47a5c3aefbbc6d8fc7a5fda53b7cd"
            },
            "downloads": -1,
            "filename": "django_map_widgets-0.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80bf68b0314a2d47be53623a80098b7a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 256008,
            "upload_time": "2024-07-09T17:37:48",
            "upload_time_iso_8601": "2024-07-09T17:37:48.941663Z",
            "url": "https://files.pythonhosted.org/packages/6e/75/7f1782c9fa3c07c2ca63ce7b65c4838afb568a5ea71aa119aaa9dc456d8b/django_map_widgets-0.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7850651dae7335fc9c6df7b1ab27c49b1cc98245ac0d61750538a192da19e671",
                "md5": "0ce7d8da6b0a5f27022c46a5f252c6c7",
                "sha256": "68e81f9c58c1cd6d180421220a4d100a185c8062ae0ca7be790658fcfd4eda1d"
            },
            "downloads": -1,
            "filename": "django_map_widgets-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0ce7d8da6b0a5f27022c46a5f252c6c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 160819,
            "upload_time": "2024-07-09T17:37:50",
            "upload_time_iso_8601": "2024-07-09T17:37:50.717546Z",
            "url": "https://files.pythonhosted.org/packages/78/50/651dae7335fc9c6df7b1ab27c49b1cc98245ac0d61750538a192da19e671/django_map_widgets-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-09 17:37:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "erdem",
    "github_project": "django-map-widgets",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-map-widgets"
}
        
Elapsed time: 4.62004s