Metadata-Version: 2.4
Name: django-easy-maps
Version: 1.1.4
Summary: This app makes it easy to display a map for a given address
Author-email: Mikhail Korobov <kmike84@gmail.com>
Maintainer-email: Basil Shubin <basil.shubin@gmail.com>
License-Expression: MIT
Project-URL: download, https://github.com/bashu/django-easy-maps/zipball/master
Project-URL: homepage, https://github.com/bashu/django-easy-maps/
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Framework :: Django :: 6.1
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: django>=5.2
Requires-Dist: django-appconf
Requires-Dist: django-classy-tags>=0.6.2
Requires-Dist: geopy>=0.96
Dynamic: license-file

django-easy-maps
================

.. image:: https://badge.fury.io/py/django-easy-maps.svg
    :target: https://badge.fury.io/py/django-easy-maps

.. image:: https://img.shields.io/pypi/pyversions/django-easy-maps.svg
    :target: https://pypi.python.org/pypi/django-easy-maps/

.. image:: https://img.shields.io/pypi/djversions/django-easy-maps.svg
    :target: https://pypi.python.org/pypi/django-easy-maps/

.. image:: https://github.com/bashu/django-easy-maps/actions/workflows/test.yml/badge.svg
    :target: https://github.com/bashu/django-easy-maps/actions/workflows/test.yml

This app makes it easy to display a map for any given address in
django_ templates. No manual geocoding, html/js copy-pasting or Django
model changes are needed.

Maintained by `Basil Shubin <https://github.com/bashu/>`_, and some great
`contributors <https://github.com/kmike/django-easy-maps/contributors>`_.

Installation
------------

First install the module, preferably in a virtual environment. It can be installed from PyPI:

.. code-block:: shell

    pip install django-easy-maps

Setup
-----

You'll need to add ``easy_maps`` to ``INSTALLED_APPS`` in your project's ``settings.py`` file:

.. code-block:: python

    INSTALLED_APPS += [
        'easy_maps',
    ]

Then run ``./manage.py migrate`` to create the required database tables.

Configuration
-------------

The only mandatory configuration is the ``EASY_MAPS_GOOGLE_KEY`` variable:

.. code-block:: python

    EASY_MAPS_GOOGLE_KEY = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___0123456789'

If you need a place to center the map at when no address is inserted
yet, add the latitude and longitude to the ``EASY_MAPS_CENTER`` variable in
your ``settings.py`` like the following:

.. code-block:: python

    EASY_MAPS_CENTER = (-41.3, 32)

Other optional settings:

.. code-block:: python

    # Optional
    EASY_MAPS_ZOOM = 8  # Default zoom level, see https://developers.google.com/maps/documentation/javascript/tutorial#MapOptions for more information.
    EASY_MAPS_LANGUAGE = 'ru'  # See https://developers.google.com/maps/faq#languagesupport for supported languages.

Please see the ``example`` application. This application is used to
manually test the functionalities of this package. This also serves as
a good example.

You need Django 1.8 or above to run that. It might run on older versions but that is not tested.

Usage
-----

First of all, load the ``easy_map_tags`` in every template where you want to use it:

.. code-block:: html+django

    {% load easy_maps_tags %}

Use:

.. code-block:: html+django

    {% easy_map <address> [<width> <height>] [<zoom>] [using <template_name>] %}

For example:

.. code-block:: html+django

    {% load easy_maps_tags %}

    <!-- Default map with 300x400 dimensions -->
    {% easy_map "Russia, Ekaterinburg, Mira 32" 300 400 %}

    <!-- Variable address, custom detail level and custom template -->
    {% easy_map address 200 200 5 using "map.html" %}

The coordinates for map will be obtained using google geocoder on first
access. Then they'll be cached in DB. Django's template caching can be used
later in order to prevent DB access on each map render:

.. code-block:: html+django

    {% load easy_maps_tags cache %}

    {% cache 600 my_map firm.address %}
        {% easy_map firm.address 300 400 %}
    {% endcache %}

Templates
~~~~~~~~~

If the default map template is not sufficient then a custom map template can be
used. For example:

.. code-block:: html+django

    {% easy_map address using "map.html" %}
    {% easy_map address 200 300 5 using "map.html" %}

The template will have ``map`` (``easy_maps.Address`` instance
auto-created for passed address on first access), ``width``, ``height``
and ``zoom`` variables. The outer template context is passed to the rendered
template as well.

You can start your own template from scratch or just override some blocks in the
default template.

Please refer to https://developers.google.com/maps/documentation/javascript/ for
detailed Google Maps JavaScript API help.

Widgets
~~~~~~~

``django-easy-maps`` provides a basic widget that displays a map under the address
field. It can be used in the admin for map previews. For example:

.. code-block:: python

    from django import forms
    from django.contrib import admin

    from easy_maps.widgets import AddressWithMapWidget

    from .models import Firm

    class FirmAdmin(admin.ModelAdmin):
        class form(forms.ModelForm):
            class Meta:
                widgets = {
                    'address': AddressWithMapWidget({'class': 'vTextField'})
                }

    admin.site.register(Firm, FirmAdmin)

``address`` field should be either a ``CharField`` or ``TextField``.

Contributing
------------

If you've found a bug, implemented a feature or customized the template and
think it is useful then please consider contributing. Patches, pull requests or
just suggestions are welcome!

Credits
-------

`django-easy-maps <https://github.com/bashu/django-easy-maps/>`_ was originally started by `Mikhail Korobov <http://kmike.ru/>`_ who has now unfortunately abandoned the project.

License
-------

``django-easy-maps`` is released under the MIT license.

.. _django: https://www.djangoproject.com

Changes
-------

1.1.4 (2026-08-16)
~~~~~~~~~~~~~~~~~~

* Dropped support for Python < 3.10 and Django < 5.2; added support for
  Python 3.10-3.14 and Django 5.2, 6.0 and 6.1.
* Fixed ``Address`` using the legacy ``AutoField`` instead of
  ``BigAutoField`` for its primary key (#84).

1.1.3 (2021-10-09)
~~~~~~~~~~~~~~~~~~

* Removed deprecaded code, various bugfixes.

1.1.2 (2020-10-02)
~~~~~~~~~~~~~~~~~~

* Added support for Python 3.9

1.1.1 (2020-07-04)
~~~~~~~~~~~~~~~~~~

* Dropped support for Python 2.x

1.1.0 (2020-02-29)
~~~~~~~~~~~~~~~~~~

* Added support for Django 3.x.

1.0.2 (2019-05-28)
~~~~~~~~~~~~~~~~~~

* Check is EASY_MAPS_GOOGLE_MAPS_API_KEY is not None before raising warning.

1.0.1 (2019-04-21)
~~~~~~~~~~~~~~~~~~

* Fixed using callback for a non computed address

1.0.0 (2019-03-29)
~~~~~~~~~~~~~~~~~~

* Added new option EASY_MAPS_ZOOM (16 by default).
* Added new option EASY_MAPS_LANGUAGE ('en' by default).
* EASY_MAPS_GOOGLE_MAPS_API_KEY deprecated in favor of historical
  EASY_MAPS_GOOGLE_KEY option.

0.9.4 (2019-03-28)
~~~~~~~~~~~~~~~~~~

* Added support for Django 2.x, dropped support for Django < 1.11. It may
  still work with Django 1.8, but this is no longer tested.
* Make sure GoogleV3 geocoder respect API key.

0.9.3 (2016-11-11)
~~~~~~~~~~~~~~~~~~

* Google Maps API key configuration.
* Revert from setuptools back to distutils.
* Russian translation is added.

0.9.2 (2015-07-12)
~~~~~~~~~~~~~~~~~~

* Replacing broken 0.9.1 release, back to setuptools.

0.9.1 (2015-07-02)
~~~~~~~~~~~~~~~~~~

* Resolve the 500 error when google send a no results info.
* Resolving width / height and other variables in template.

0.9.0 (2014-02-11)
~~~~~~~~~~~~~~~~~~

* Backwards incompatible: added support for geopy >= 0.96,
  dropped support for geopy < 0.96.
* Added support for Django 1.6, dropped support for Django 1.3. It may
  still work with Django 1.3, but this is no longer tested.
* Experimental Python 3.3 support (no code changes - app seems to work as-is).

0.8.4 (2013-08-27)
~~~~~~~~~~~~~~~~~~

* fix bad 0.8.3 release

0.8.3 (2013-08-27)
~~~~~~~~~~~~~~~~~~

* ``easy_map`` tag now works when address is None.

0.8.2 (2013-07-02)
~~~~~~~~~~~~~~~~~~

* Unique constraint is added to Address.address field (to prevent
  MultipleObjectsReturned exceptions).

  In order to upgrade, run

      python manage.py migrate easy_maps

* German translation is added.

0.8.1 (2013-03-25)
~~~~~~~~~~~~~~~~~~

* Fix regressions in geocoding errors handling introduced in 0.8.

0.8.0 (2013-03-24)
~~~~~~~~~~~~~~~~~~

* Testing improvements;
* EASY_MAPS_CENTER setting for default map coordinates;
* allow to pass an Address instance as argument of easy_map tag;
* better error handling;
* switch to GoogleV3 geocoder;
* customization hook: it is now possible to use a custom geocoding method;
* EASY_MAPS_GOOGLE_KEY now does nothing (it is not a meaningful option
  for V3 Geocoding API).

Minimum required Django version is 1.3 since this release.
It may work with older versions, but this is untested.

0.7.4 (2013-01-03)
~~~~~~~~~~~~~~~~~~

* switch to https;
* make example settings Django 1.4 compatible;

0.7.3 (2012-09-21)
~~~~~~~~~~~~~~~~~~

* use only first placemark from geocoder.

0.7.2 (2012-01-07)
~~~~~~~~~~~~~~~~~~

* static fallback for map.html;
* fix localization of floats.

0.7.1 (2011-01-31)
~~~~~~~~~~~~~~~~~~

* better error handling;
* EASY_MAPS_GOOGLE_KEY setting.

0.7.0 (2010-12-24)
~~~~~~~~~~~~~~~~~~

* longtitude -> longitude;
* display is fixed for comma-delimited float locales.

0.6.0 (2010-12-02)
~~~~~~~~~~~~~~~~~~

* admin preview widget;
* bugfixes.

0.5.0 (2010-12-01)
~~~~~~~~~~~~~~~~~~

* Initial release
