All Projects → bashu → Django Easy Maps

bashu / Django Easy Maps

Licence: mit
🗺 Google Maps with easy!

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Easy Maps

Django Fields
Fields pack for django framework.
Stars: ✭ 124 (-3.88%)
Mutual labels:  django
Django Structlog
Structured Logging for Django
Stars: ✭ 127 (-1.55%)
Mutual labels:  django
Simple Signup
Code samples used in the blog post "How to Create User Sign Up View"
Stars: ✭ 128 (-0.78%)
Mutual labels:  django
Wagtail
A Django content management system focused on flexibility and user experience
Stars: ✭ 11,387 (+8727.13%)
Mutual labels:  django
Screenshots
Simple Website Screenshots as a Service (Django, Selenium, Docker, Docker-compose)
Stars: ✭ 126 (-2.33%)
Mutual labels:  django
Vms
THIS PROJECT IS ARCHIVED. Volunteer Management System.
Stars: ✭ 127 (-1.55%)
Mutual labels:  django
Django Jsoneditor
Django JSONEditor input widget to provide javascript online JSON Editor
Stars: ✭ 124 (-3.88%)
Mutual labels:  django
Docker Jenkins Django Tutorial
實戰 Docker + Jenkins + Django + Postgres 📝
Stars: ✭ 129 (+0%)
Mutual labels:  django
Dialogue.moe
Stars: ✭ 127 (-1.55%)
Mutual labels:  django
Dailyfresh
Django-天天生鲜电商学习项目
Stars: ✭ 127 (-1.55%)
Mutual labels:  django
Elasticstack
📇 Configurable indexing and other extras for Haystack (with ElasticSearch biases)
Stars: ✭ 125 (-3.1%)
Mutual labels:  django
Djangocms Text Ckeditor
Text Plugin for django CMS using CKEditor 4
Stars: ✭ 126 (-2.33%)
Mutual labels:  django
Djng
Turtles all the way down
Stars: ✭ 127 (-1.55%)
Mutual labels:  django
Python Resources 2019
A curated list of Python 3 resources, books, websites, tutorials, code challenges
Stars: ✭ 125 (-3.1%)
Mutual labels:  django
Snippod Starter Demo App
A full stack 'Hacker News' style demo web application built with React + Redux (Front) and django REST Framework (Server).
Stars: ✭ 128 (-0.78%)
Mutual labels:  django
Impostor
Django app that enables staff to log in as other users using their own credentials.
Stars: ✭ 124 (-3.88%)
Mutual labels:  django
Timestrap
Time tracking you can host anywhere. Full export support in multiple formats and easily extensible.
Stars: ✭ 1,607 (+1145.74%)
Mutual labels:  django
Django Defectdojo
DefectDojo is an open-source application vulnerability correlation and security orchestration tool.
Stars: ✭ 1,926 (+1393.02%)
Mutual labels:  django
Wagtailmedia
A Wagtail module for managing video and audio files within the admin
Stars: ✭ 128 (-0.78%)
Mutual labels:  django
Django Slick Reporting
Powerful and Efficient reporting engine with Charting capabilities
Stars: ✭ 123 (-4.65%)
Mutual labels:  django

django-easy-maps

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.

Authored by Mikhail Korobov <http://kmike.ru/>, and some great contributors <https://github.com/kmike/django-easy-maps/contributors>.

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

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

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

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

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)

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!

License

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].