Django-locpick is a project mainly written in PYTHON and JAVASCRIPT, based on the BSD-3-Clause license.
Point to a location on Google Maps in your Django projects.
Show where your business, venue, party, etc. is on Google Maps.
LocationField
to hold a location plus a color marker in the database.Install from here using pip
::
pip install -e git+git://github.com/comoga/django-locpick#egg=django-locpick
With django.contrib.staticfiles
(from Django 1.3)::
INSTALLED_APPS = (
...
'django.contrib.staticfiles',
'locpick',
)
STATIC_URL = ... # see staticfiles documentation
Without django.contrib.staticfiles
::
INSTALLED_APPS = (
...
'locpick',
)
LOCPICK_STATIC_URL = ... # 'LOCPICK_CHECKOUT_DIR/locpick/static/locpick/'
Add LocationField
to your models.py
::
from locpick.field import LocationField
class Place(models.Model)
...
location = LocationField()
To display the map on the frontend, include this javascript code::
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
Then, use LocationField.render_map()
::
{{ place.location.render_map }}
Or use the template tag gmap
to display and specify the map's size::
{% load gmap %}
{% gmap place.location WIDTH HEIGHT %}
Display an external link (Google Maps) to the map::
<a href="{{ place.location.external_url }}">Map</a>
Customize the default configuration in your settings.py
::
LOCPICK_STATIC_URL
- URL that handles locpick static directory, defaults to STATIC_URL + 'locpick/'.LOCPICK_DEFAULT_MAP_WIDTH
- Default frontend map width, defaults to 200 (rendered by location.render_map()
)LOCPICK_DEFAULT_MAP_HEIGHT
- Default frontend map height, defaults to 200 (rendered by location.render_map()
).. figure:: https://github.com/aleszoulek/django-locpick/raw/master/doc/screenshot_admin.png
The admin's changeform.
.. figure:: https://github.com/aleszoulek/django-locpick/raw/master/doc/screenshot_frontend.png
A map rendered on the frontend.
gmap
external_url
field property