Skip to content

josihoppe/django-mapengine

 
 

Repository files navigation

Django-Mapengine

django-mapengine is a Django app to provide library for maplibre in backend. This includes

  • html templates and JS files for maplibre
  • creation of maplibre sources and layers including choropleths,
  • provision of multi-vector-tiles from django models,
  • distilling of map source views
  • basic popups

Requirements

Maplibre must be installed (i.e. via npm) and provided as JS framework

Quick start

  1. Add "django_mapengine" to your INSTALLED_APPS setting like this::
    INSTALLED_APPS = [
        "...",
        'django_mapengine',
    ]
  1. Include URLs from django_mapengine to your project:
    urlpatterns = [
        "...",
        path("map/", include("django_mapengine.urls")),
    ]
  1. Configure map engine by setting zoom levels, regions and styles folder in project settings.py. You can see all possible settings by looking into django_mapengine.settings.py. Example settings:
    from django_mapengine import setup

MAP_ENGINE_CENTER_AT_STARTUP = [12.537917858911896, 51.80812518969171]
MAP_ENGINE_ZOOM_AT_STARTUP = 9
MAP_ENGINE_MAX_BOUNDS = [[11.280733017118229, 51.22918643452503], [13.616574868700604, 52.35515806663738]]

MAP_ENGINE_IMAGES = [core.MapImage("wind", "images/icons/i_wind.png")]

MAP_ENGINE_API_MVTS = {
    "municipality":
        [
            setup.MVTAPI("municipality", "map", "Municipality"),
            setup.MVTAPI("municipalitylabel", "map", "Municipality", "label_tiles"),
        ],
    "results": [setup.MVTAPI("results", "map", "Municipality")]
}

MAP_ENGINE_API_CLUSTERS = [
    setup.ClusterAPI("wind", "map", "WindTurbine"),
    setup.ClusterAPI("pvroof", "map", "PVroof"),
    setup.ClusterAPI("pvground", "map", "PVground"),
    setup.ClusterAPI("hydro", "map", "Hydro"),
    setup.ClusterAPI("biomass", "map", "Biomass"),
    setup.ClusterAPI("combustion", "map", "Combustion"),
]

MAP_ENGINE_STYLES_FOLDER = "digiplan/static/config/"
MAP_ENGINE_ZOOM_LEVELS = {
   "municipality": core.Zoom(8, 12),
}

MAP_ENGINE_POPUPS = ["results"]

About

Map engine for maplibre in django

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 64.0%
  • JavaScript 32.2%
  • HTML 3.8%