<NME> README.rst
<BEF> django-easy-maps
================
================

This app makes it easy to display a map for given address in django templates.
The license is MIT.

Installation

.. image:: https://img.shields.io/travis/bashu/django-easy-maps.svg
    :target: https://travis-ci.com/github/bashu/django-easy-maps/

    pip install geopy
    pip install django-easy-maps

Usage
=====

1. Add 'easy_maps' to INSTALLED_APPS

2. Run ``./manage.py syncdb`` (or ``./manage.py migrate easy_maps``
   if south is in use)

3. Use the ``easy_map`` templatetag::

       {% 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' %}

   It has the following signature::

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

   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::

       {% load easy_maps_tags cache %}

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

That's all! No API keys, manual geocoding, html/js copy-pasting or
django model changes is needed.

Customization
=============

    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)

'width', 'height' and 'zoom' variables. The outer template context is passed
to 'map.html' as well.

Address model
=============

easy_maps.models.Address model has the following fields:

* address
* computed address
* longtitude
* latitude
* geocode_error

Contributing
============

Use:

.. code-block:: html+django

Source code: https://bitbucket.org/kmike/django-easy-maps/

Bug tracker: https://bitbucket.org/kmike/django-easy-maps/issues/new


.. 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

<MSG> Reorganized README

<DFF> @@ -3,6 +3,9 @@ django-easy-maps
 ================
 
 This app makes it easy to display a map for given address in django templates.
+No API keys, manual geocoding, html/js copy-pasting or django model
+changes is needed.
+
 The license is MIT.
 
 Installation
@@ -13,40 +16,35 @@ Installation
     pip install geopy
     pip install django-easy-maps
 
+Then add 'easy_maps' to INSTALLED_APPS and run ``./manage.py syncdb``
+(or ``./manage.py migrate easy_maps`` if South is in use)
+
 Usage
 =====
 
-1. Add 'easy_maps' to INSTALLED_APPS
-
-2. Run ``./manage.py syncdb`` (or ``./manage.py migrate easy_maps``
-   if south is in use)
-
-3. Use the ``easy_map`` templatetag::
+This app provides an ``easy_map`` template tag::
 
-       {% load easy_maps_tags %}
+    {% easy_map <address> [<width> <height>] [<zoom>] [using <template_name>] %}
 
-       <!-- Default map with 300x400 dimensions -->
-       {% easy_map "Russia, Ekaterinburg, Mira 32" 300 400 %}
+Examples::
 
-       <!-- Variable address, custom detail level and custom template -->
-       {% easy_map address 200 200 5 using 'map.html' %}
+    {% load easy_maps_tags %}
 
-   It has the following signature::
+    <!-- Default map with 300x400 dimensions -->
+    {% easy_map "Russia, Ekaterinburg, Mira 32" 300 400 %}
 
-       {% easy_map <address> [<width> <height>] [<zoom>] [using <template_name>] %}
+    <!-- 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::
+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::
 
-       {% load easy_maps_tags cache %}
+    {% load easy_maps_tags cache %}
 
-       {% cache 600 my_map firm.address %}
-           {% easy_map firm.address 300 400 %}
-       {% endcache %}
-
-That's all! No API keys, manual geocoding, html/js copy-pasting or
-django model changes is needed.
+    {% cache 600 my_map firm.address %}
+        {% easy_map firm.address 300 400 %}
+    {% endcache %}
 
 Customization
 =============
@@ -64,16 +62,22 @@ The template will have 'map' (it is the ``easy_maps.models.Address`` instance),
 'width', 'height' and 'zoom' variables. The outer template context is passed
 to 'map.html' as well.
 
+The default template can be found here:
+https://bitbucket.org/kmike/django-easy-maps/src/tip/easy_maps/templates/easy_maps/map.html
+
+You can start your own template from scratch or just override some blocks in the
+default template.
+
 Address model
 =============
 
 easy_maps.models.Address model has the following fields:
 
-* address
-* computed address
+* address - the requested address
+* computed_address - address returned by geocoder
 * longtitude
 * latitude
-* geocode_error
+* geocode_error - True if geocoder wasn't able to handle the address
 
 Contributing
 ============
@@ -85,4 +89,3 @@ just suggestions are welcome!
 Source code: https://bitbucket.org/kmike/django-easy-maps/
 
 Bug tracker: https://bitbucket.org/kmike/django-easy-maps/issues/new
-

Reorganized README