Giter VIP home page Giter VIP logo

django-leaflet-storage's Introduction

Django-Leaflet-Storage

Provide collaborative maps for your Django project.

Django-Leaflet-Storage is a backend for Leaflet.Storage, built on top of Geodjango and Leaflet.

Check the demo here

Maintained repositories

Installation

Note

You will need a geo aware database. See Geodjango doc for backend installation.

Then you can pip install the app:

pip install django-leaflet-storage

Add leaflet_storage to you apps:

INSTALLED_APPS = (
    ...
    "leaflet_storage",
)

Include leaflet_storage urls:

(r'', include('leaflet_storage.urls')),

Create tables (add --migrate if you are using South:

python manage.py syncdb --migrate

Basic usage

From the Django admin (for now), you need to create at least:

  • one TileLayer instance
  • one Licence instance

Then, go to the map front page (something like http://localhost:8017/map/my-map-slug), and you will be able to add features (Marker, Polygon...).

Advanced configuration

Use your own models

Sometimes, you will need to add specific properties to the Marker, Polyline or Polygon. Its easy to do so with leaflet_storage.

Create a model that inherit from AbstractMarker (for Marker example):

from leaflet_storage.base_models import AbstractMarker


class MyMarker(AbstractMarker):
    # your fields here

Then, in your settings, add:

LEAFLET_STORAGE_MODELS = {
    "Marker": ('my_app', 'MyModel'),
}

Warning

Of course, you will need to do this before running the initial syncdb.

Decide which features are editable

For now, only Marker, Polyline and Polygon features are supported. Maybe you just want for example the Marker to be editable. For this, you will need to override the map configuration in JavaScript. You will have to explicity prevent the Polyline and Polygon editing, doing so:

<script>
    // create map_settings like the default template does
    map_settings.editOptions = {
            "polyline": null,
            "polygon": null
        }
    // Create the map like the default template does
</script>

Disabling totally inplace editing

Again, this have to be done in JavaScript:

<script>
    map_settings.allowEdit = false;
</script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.