Skip to main content

Google Maps widget for django-fluent-contents

Project description

fluentcms-googlemaps

A plugin for django-fluent-contents to show a Google Maps widget on a website.

This plugin is a work in progress. It’s already used in production, just know that there are two main area’s that need improval:

  • Use a better GeoPosition widget (e.g. by using a lightbox/popup)

  • Make cluster icons configurable.

Installation

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

pip install fluentcms-googlemaps

Backend Configuration

First make sure the project is configured for django-fluent-contents.

Then add the following settings:

INSTALLED_APPS += (
    'fluentcms_googlemaps',
)

Add the following to urls.py:

urlpatterns = [
    ...

    url(r'^api/googlemaps/', include('fluentcms_googlemaps.urls')),
]

The database tables can be created afterwards:

./manage.py migrate

Now, the MapPlugin can be added to your PlaceholderField and PlaceholderEditorAdmin admin screens.

Frontend Configuration

Make sure that all plugin media files are exposed by django-fluent-contents:

{% load frontend_contents_tags %}

{% render_content_items_media %}

This tag should be placed at the bottom of the page, after all plugins are rendered. For more configuration options - e.g. integration with django-compressor - see the template tag documentation.

CSS Code

The stylesheet code is purposefully left out, since authors typically like to provide their own styling.

JavaScript Code

No configuration is required for the JavaScript integration.

By default, the plugin includes all required JavaScript code.

If needed, the includes resources can be changed by using the following settings:

MAP_MARKERWITHLABEL_JS = "fluentcms_googlemaps/vendor/markerwithlabel.js"
MAP_MARKERCLUSTERER_JS = "fluentcms_googlemaps/vendor/markerclusterer_compiled.js"
MAPPLUGIN_JS = "fluentcms_googlemaps/js/mapplugin.js"
MAPSEARCH_JS = "fluentcms_googlemaps/js/mapsearch.js"

FLUENTCMS_GOOGLEMAPS_JS = (
    MAP_MARKERWITHLABEL_JS,
    MAP_MARKERCLUSTERER_JS,
    MAPPLUGIN_JS,
)

FLUENTCMS_GOOGLEMAPS_CSS = {}

If a value is defined as None, it will be excluded from the frontend media.

HTML code

If needed, the HTML code can be overwritten by redefining fluentcms_googlemaps/maps/default.html. Also, you can create additional map styles and define these in FLUENTCMS_GOOGLEMAPS_STYLES. The default is:

FLUENTCMS_GOOGLEMAPS_STYLES = (
    ('default', {
        'title': _("Default"),
        'template': "fluentcms_googlemaps/maps/default.html",
    }),
    ('search', {
        'title': _("Search field"),
        'template': "fluentcms_googlemaps/maps/search.html",
        'extra_js': (
            MAPSEARCH_JS,   # = "fluentcms_googlemaps/js/mapsearch.js" unless MAPSEARCH_JS is redefined
        ),
    }),
)

By default, the following templates are looked up:

  • A explicitly defined template option in the FLUENTCMS_GOOGLEMAPS_STYLES.

  • A template named: fluentcms_googlemaps/maps/{style}.html.

  • The default; fluentcms_googlemaps/maps/default.html.

Importing data

Marker data can be imported from CSV files, and receive geocoding too. The import_markers command can be called with custom templates to map the CSV file data to marker fields. For example:

manage.py import_markers /stores.csv  --title='{{Name}}' --group=1 --geocode='{{Address}} {{Zipcode}} {{City}} {{County}}' --geocoder=google --description="<p>{{Address}}<br>{{Zipcode}} {{City}}<br>{% if County == 'NL'%}The Netherlands{% else %}{{County}}{% endif %}</p>"

It’s recommended to add --dry-run first until all fields are properly filled. The markers are created in a single transaction at the end of all parsing.

Contributing

If you like this module, forked it, or would like to improve it, please let us know! Pull requests are welcome too. :-)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluentcms-googlemaps-1.2.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

fluentcms_googlemaps-1.2-py2.py3-none-any.whl (53.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fluentcms-googlemaps-1.2.tar.gz.

File metadata

File hashes

Hashes for fluentcms-googlemaps-1.2.tar.gz
Algorithm Hash digest
SHA256 6083783beda6adaa66e3471557b43b560728372a9716b42d1c633aa5f4fefefd
MD5 658912d2a5f63d3eb552debf6a0eefdf
BLAKE2b-256 dc16a6a6899bc3322ee174a51306a2a3fcb39d75ee548705472874ebd4340c4a

See more details on using hashes here.

File details

Details for the file fluentcms_googlemaps-1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for fluentcms_googlemaps-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a56829502c16c8862126c855e019585a4b86a43a9f4b20fb81b47440f15ac4d7
MD5 15fd2e7441ee46d3bf8ce133ef4d1087
BLAKE2b-256 194d72f94d30374439f5785dc7a69b625c8b5ffe0f6b18dcd21cd81a9dbab03c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page