Package: django-tiles-gl
Django Tiles GLIntegrated Django Vector Tile Server based on mbtiles.DescriptionSimple app to serveMabpox Vector Tilesdirectly fromMBTiles filesvia Django views.Django Tiles has a minimal dependencies. It does not require GeoDjano or any other libraries. Its only dependency is Django itself.Django Tiles GLdoes not create raster tiles. It may only be used with map libraries that support to render vector tiles likeMapLibreorOpenLayers.Django Tiles GL contains theOSM Bright map stylewhich can be used to render Vector Tiles following theOpenMapTiles vector tile  schema.Note that this default style is usingOpenSans fontswhich does only contain Latin, Greek and Cyrillic alphabets.Other tile schemes are possible by creating a custommap style specificationand referencing Django Tiles GLTileJSON endpointas a source.UsageSee thedemoDjango application for a simple usage example.SetupAdddjango_tiles_glto youINSTALLED_APPSsetting.Adddjango_tiles_gl.urlsto your url patterns.
For example with thetilesprefix:urlpatterns=[...path("tiles/",include("django_tiles_gl.urls")),]Set path to your MBTiles files in you application settings.MBTILES_DATABASE=BASE_DIR/"demo"/"data"/"berlin.mbtiles"Optionally set the default center to be set on the default map style.MBTILES_CENTER=[13.4,52.5,13]# [longitude, latitude, zoom]Optionally force absolute urls to use SSL by prefixing them with "https://".
This might be required if you app is running behind a reverse proxy and you
are not able to setSECURE_PROXY_SSL_HEADERfrom the SSL enabled proxy server.MBTILES_FORCE_SSL=TrueViewsTo render a map you have to include a JavaScript mapping library and refer to thetileendpoint or the default integrated style.Django Tiles GL provides the following endpoints:{% url 'django_tiles_gl:openmaptiles_style' %}- DefaultOpenMapTiles style defintionusing theOSM Bright map style.{% url 'django_tiles_gl:tilejson' %}-TileJSONdescribing the configured MBTiles files and providing the correct tile urls.{% url 'django_tiles_gl:tile' x y z %}- Actual tile endpoint, returning vector data in thePBF format.Django Tiles GL is bundles withMapLibreand provides a template tag for easy inclusion. A minimal working example has to contain the following defintions:{% load tiles_gl_tags %}<!DOCTYPE html><html><head>{% maplibre_head %}<style>body{margin:0;padding:0;}#map{position:absolute;top:0;bottom:0;width:100%;}</style></head><body><divid='map'></div><script>varmap=newmaplibregl.Map({container:'map',style:'{% url 'django_tiles_gl:openmaptiles_style' %}',});</script></body></html>Data / MBTiles generationThere are mutiple tools to generate valid MBTiles databases. The easiest to use with Django Tiles GL isOpenMapTilesas it is compatible with the bundled default style.For a quickstart you may generate the MbTiles for an area with the following commands:gitclonehttps://github.com/openmaptiles/openmaptiles.gitcdopenmaptiles
./quickstart.sh<area>Fo further information and optiones seehttps://github.com/openmaptiles/openmaptilesFurther TopicsCachingIt is advised setup a caching proxy for thetileendpoint. Please refer to you HTTP servers documentation. For example thenginx proxy cache configOther Django tile server solutionsdjango-geojson-tiles- Generates GeoJSON tiles from a GeoDjango model. No MBTiles support.  Not to be used as a base layer.django-vectortiles- Generates Vector Tile layers from GeoDjango. No MBTiles support. Not to be used as a base layer.django-mbtiles- Uses MBTiles to generate rastered tiles andUTFGrid. Does not support modern vector tiles. Strong inspiration for this project.