• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 13 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ—บ Google Maps with easy!

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.

Maintained by Basil Shubin, and some great contributors.

Installation

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

pip install django-easy-maps

Setup

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

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:

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:

EASY_MAPS_CENTER = (-41.3, 32)

Other optional settings:

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

{% load easy_maps_tags %}

Use:

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

For example:

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

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

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

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 was originally started by Mikhail Korobov who has now unfortunately abandoned the project.

License

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

More Repositories

1

django-tracking

Simple attempt at keeping track of visitors to django-powered web sites
Python
228
star
2

django-secretballot

๐Ÿ—ณ Django voting application that allows semi-anonymous voting
Python
209
star
3

django-maintenancemode

๐Ÿ›  django-maintenancemode allows you to temporary shutdown your site for maintenance work
Python
178
star
4

django-watermark

๐Ÿ’‹ Quick and efficient way to apply watermarks to images in django
Python
75
star
5

django-airports

โœˆ๏ธ It's like django-cities, but django-airports
Python
55
star
6

wagtail-embedvideos

๐ŸŽฌ Integration of django-embed-video for Wagtail CMS
Python
54
star
7

wagtail-metadata-mixin

๐Ÿ” OpenGraph, Twitter Card and Schema.org snippet tags for Wagtail CMS pages
Python
47
star
8

django-birthday

๐ŸŽ‚ django-birthday is a helper library to work with birthdays in models
Python
24
star
9

monit.conf.d

โฐ Monit configuration files / recipes supporting many programs and processes
23
star
10

django-filters-mixin

django-filter meets django-pagination
Python
19
star
11

django-cached-modelforms

๐ŸŒŸ ModelChoiceField implementation that can accept lists of objects, not just querysets
Python
14
star
12

django-addthis

๐Ÿ‘ A simple integration of the AddThis social sharing widget for Django projects
Python
10
star
13

django-popularity-mixin

๐Ÿคฉ Simple integration between django-cacheback and django-hitcount
Python
9
star
14

django-easy-seo

๐Ÿ” SEO fields for objects of any model registered in admin
Python
9
star
15

django-fineuploader

โฌ†๏ธ Simple Fine Uploader integration for Django
JavaScript
8
star
16

django-fancybox

๐ŸŽ Simple fancybox modal for Django
Python
8
star
17

django-uncharted

๐Ÿ“Š๐Ÿ“ˆ Simple amCharts integration for Django
Python
8
star
18

django-unitology

๐Ÿ“ Custom model fields to store, retrieve and convert measurements of height, weight and more...
Python
7
star
19

django-simple-currencies

Currency, exchange rate and conversions support for django projects
Python
5
star
20

django-facebox

Simple facebox modal for Django
JavaScript
5
star
21

django-charsleft-widget

๐Ÿ‘ป Custom widget that limits the number of characters that can be entered in a textarea field
Python
4
star
22

django-taggit-anywhere

๐Ÿ”– django-taggit with easy!
Python
4
star
23

fluentcms-filer

๐Ÿ—„ django-filer content plugins for django-fluent-contents
Python
3
star
24

fluentcms-forms-builder

๐Ÿ›  django-forms-builder plugin for django-fluent-contents
Python
3
star
25

django-permanent-helpers

๐ŸงŸโ€โ™‚๏ธ django admin helper classes for django-permanent models
Python
3
star
26

django-ckeditor-filer

A django-filer based CKEditor filebrowser
JavaScript
2
star
27

fluentcms-suit

๐Ÿฆ django-fluent-pages meets django-suit
HTML
2
star
28

awesome-fluentcms

A curated list of awesome Fluent CMS add-ons, projects and resources
2
star
29

fluentcms-publishing

django-fluent-pages meets django-model-publisher
Python
2
star
30

django-smileys

Python
1
star
31

vagrant-dev-box

๐Ÿ›  Vagrant configuration for a base box for Django site development
Shell
1
star
32

django-crumbs-mixin

Python
1
star
33

fluentcms-link

๐Ÿ”— Link plugin for django-fluent-contents
Python
1
star
34

django-sitecats-helpers

๐Ÿ˜น django admin helper classes for django-sitecats categories
Python
1
star
35

django-clearable-widget

๐Ÿ‘ป Custom widget to add a (x) clear button to your input fields
Python
1
star