django-tiles-gl


Namedjango-tiles-gl JSON
Version 0.3.7 PyPI version JSON
download
home_pagehttps://github.com/kleingeist/django-tiles-gl
SummaryIntegrated Django Vector Tile Server based on mbtiles
upload_time2022-12-03 11:52:09
maintainer
docs_urlNone
authorJohannes Dillmann
requires_python>=3.8,<4.0
licenseBSD-3-Clause
keywords django map mbtiles
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Tiles GL

Integrated Django Vector Tile Server based on mbtiles.


## Description

Simple app to serve [Mabpox Vector Tiles](https://docs.mapbox.com/data/tilesets/guides/vector-tiles-standards/) directly from [MBTiles files](https://github.com/mapbox/mbtiles-spec) via 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 GL **does not create raster tiles**. It may only be used with map libraries that support to render vector tiles like  [MapLibre](https://maplibre.org/) or [OpenLayers](https://openlayers.org/).

Django Tiles GL contains the [OSM Bright map style](https://openmaptiles.org/styles/#osm-bright) which can be used to render Vector Tiles following the [OpenMapTiles vector tile  schema](https://openmaptiles.org/schema).

Note that this default style is using [OpenSans fonts](https://github.com/openmaptiles/fonts) which does only contain Latin, Greek and Cyrillic alphabets.

Other tile schemes are possible by creating a custom [map style specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/) and referencing Django Tiles GL [TileJSON endpoint](https://github.com/mapbox/tilejson-spec) as a source.

## Usage

See the [`demo`](https://github.com/kleingeist/django-tiles-gl/tree/main/demo) Django application for a simple usage example.


### Setup

- Add `django_tiles_gl` to you `INSTALLED_APPS` setting.
- Add `django_tiles_gl.urls` to your url patterns.
  For example with the `tiles` prefix:
  ```python
  urlpatterns = [
      ...
      path("tiles/", include("django_tiles_gl.urls")),
  ]
  ```
- Set path to your MBTiles files in you application settings.
  ```python
  MBTILES_DATABASE = BASE_DIR / "demo" / "data" / "berlin.mbtiles"
  ```
- Optionally set the default center to be set on the default map style.
  ```python
  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 set [`SECURE_PROXY_SSL_HEADER`](https://docs.djangoproject.com/en/4.0/ref/settings/#secure-proxy-ssl-header)
  from the SSL enabled proxy server.
  ```python
  MBTILES_FORCE_SSL = True
  ```

### Views
To render a map you have to include a JavaScript mapping library and refer to the `tile` endpoint or the default integrated style.

Django Tiles GL provides the following endpoints:

- `{% url 'django_tiles_gl:openmaptiles_style' %}` - Default [OpenMapTiles style defintion](https://openmaptiles.org) using the [OSM Bright map style](https://openmaptiles.org/styles/#osm-bright).
- `{% url 'django_tiles_gl:tilejson' %}` - [TileJSON](https://github.com/mapbox/tilejson-spec) describing 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 the [PBF format](https://wiki.openstreetmap.org/wiki/PBF_Format).


Django Tiles GL is bundles with [MapLibre](https://maplibre.org/) and provides a template tag for easy inclusion. A minimal working example has to contain the following defintions:

```html
{% 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>

<div id='map'></div>

<script>
var map = new maplibregl.Map({
	container: 'map',
	style: '{% url 'django_tiles_gl:openmaptiles_style' %}',
});
</script>

</body>
</html>
```

## Data / MBTiles generation

There are mutiple tools to generate valid MBTiles databases. The easiest to use with Django Tiles GL is [OpenMapTiles](https://github.com/openmaptiles/openmaptiles) as it is compatible with the bundled default style.

For a quickstart you may generate the MbTiles for an area with the following commands:
```sh
git clone https://github.com/openmaptiles/openmaptiles.git
cd openmaptiles
./quickstart.sh <area>
```

Fo further information and optiones see [https://github.com/openmaptiles/openmaptiles](https://github.com/openmaptiles/openmaptiles)



## Further Topics

### Caching

It is advised setup a caching proxy for the `tile` endpoint. Please refer to you HTTP servers documentation. For example the [nginx proxy cache config](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache)



## Other Django tile server solutions

- [django-geojson-tiles](https://github.com/glenrobertson/django-geojson-tiles) - Generates GeoJSON tiles from a GeoDjango model. No MBTiles support.  Not to be used as a base layer.

- [django-vectortiles](https://github.com/submarcos/django-vectortiles) - Generates Vector Tile layers from GeoDjango. No MBTiles support. Not to be used as a base layer.

- [django-mbtiles](https://github.com/makinacorpus/django-mbtiles) - Uses MBTiles to generate rastered tiles and [UTFGrid](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md). Does not support modern vector tiles. Strong inspiration for this project.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kleingeist/django-tiles-gl",
    "name": "django-tiles-gl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "django,map,mbtiles",
    "author": "Johannes Dillmann",
    "author_email": "dev@ae35.de",
    "download_url": "https://files.pythonhosted.org/packages/8a/54/19cf8c514f55830c14eca0b1729dd15c081205d8711234b0a2b912264f6f/django_tiles_gl-0.3.7.tar.gz",
    "platform": null,
    "description": "# Django Tiles GL\n\nIntegrated Django Vector Tile Server based on mbtiles.\n\n\n## Description\n\nSimple app to serve [Mabpox Vector Tiles](https://docs.mapbox.com/data/tilesets/guides/vector-tiles-standards/) directly from [MBTiles files](https://github.com/mapbox/mbtiles-spec) via Django views.\n\nDjango Tiles has a minimal dependencies. It does not require GeoDjano or any other libraries. Its only dependency is Django itself.\n\nDjango Tiles GL **does not create raster tiles**. It may only be used with map libraries that support to render vector tiles like  [MapLibre](https://maplibre.org/) or [OpenLayers](https://openlayers.org/).\n\nDjango Tiles GL contains the [OSM Bright map style](https://openmaptiles.org/styles/#osm-bright) which can be used to render Vector Tiles following the [OpenMapTiles vector tile  schema](https://openmaptiles.org/schema).\n\nNote that this default style is using [OpenSans fonts](https://github.com/openmaptiles/fonts) which does only contain Latin, Greek and Cyrillic alphabets.\n\nOther tile schemes are possible by creating a custom [map style specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/) and referencing Django Tiles GL [TileJSON endpoint](https://github.com/mapbox/tilejson-spec) as a source.\n\n## Usage\n\nSee the [`demo`](https://github.com/kleingeist/django-tiles-gl/tree/main/demo) Django application for a simple usage example.\n\n\n### Setup\n\n- Add `django_tiles_gl` to you `INSTALLED_APPS` setting.\n- Add `django_tiles_gl.urls` to your url patterns.\n  For example with the `tiles` prefix:\n  ```python\n  urlpatterns = [\n      ...\n      path(\"tiles/\", include(\"django_tiles_gl.urls\")),\n  ]\n  ```\n- Set path to your MBTiles files in you application settings.\n  ```python\n  MBTILES_DATABASE = BASE_DIR / \"demo\" / \"data\" / \"berlin.mbtiles\"\n  ```\n- Optionally set the default center to be set on the default map style.\n  ```python\n  MBTILES_CENTER = [13.4, 52.5, 13]   # [longitude, latitude, zoom]\n  ```\n- Optionally force absolute urls to use SSL by prefixing them with \"https://\".\n  This might be required if you app is running behind a reverse proxy and you\n  are not able to set [`SECURE_PROXY_SSL_HEADER`](https://docs.djangoproject.com/en/4.0/ref/settings/#secure-proxy-ssl-header)\n  from the SSL enabled proxy server.\n  ```python\n  MBTILES_FORCE_SSL = True\n  ```\n\n### Views\nTo render a map you have to include a JavaScript mapping library and refer to the `tile` endpoint or the default integrated style.\n\nDjango Tiles GL provides the following endpoints:\n\n- `{% url 'django_tiles_gl:openmaptiles_style' %}` - Default [OpenMapTiles style defintion](https://openmaptiles.org) using the [OSM Bright map style](https://openmaptiles.org/styles/#osm-bright).\n- `{% url 'django_tiles_gl:tilejson' %}` - [TileJSON](https://github.com/mapbox/tilejson-spec) describing the configured MBTiles files and providing the correct tile urls.\n- `{% url 'django_tiles_gl:tile' x y z %}` - Actual tile endpoint, returning vector data in the [PBF format](https://wiki.openstreetmap.org/wiki/PBF_Format).\n\n\nDjango Tiles GL is bundles with [MapLibre](https://maplibre.org/) and provides a template tag for easy inclusion. A minimal working example has to contain the following defintions:\n\n```html\n{% load tiles_gl_tags %}\n<!DOCTYPE html>\n<html>\n<head>\n    {% maplibre_head %}\n\n    <style>\n        body { margin:0; padding:0; }\n        #map { position:absolute; top:0; bottom:0; width:100%; }\n    </style>\n</head>\n<body>\n\n<div id='map'></div>\n\n<script>\nvar map = new maplibregl.Map({\n\tcontainer: 'map',\n\tstyle: '{% url 'django_tiles_gl:openmaptiles_style' %}',\n});\n</script>\n\n</body>\n</html>\n```\n\n## Data / MBTiles generation\n\nThere are mutiple tools to generate valid MBTiles databases. The easiest to use with Django Tiles GL is [OpenMapTiles](https://github.com/openmaptiles/openmaptiles) as it is compatible with the bundled default style.\n\nFor a quickstart you may generate the MbTiles for an area with the following commands:\n```sh\ngit clone https://github.com/openmaptiles/openmaptiles.git\ncd openmaptiles\n./quickstart.sh <area>\n```\n\nFo further information and optiones see [https://github.com/openmaptiles/openmaptiles](https://github.com/openmaptiles/openmaptiles)\n\n\n\n## Further Topics\n\n### Caching\n\nIt is advised setup a caching proxy for the `tile` endpoint. Please refer to you HTTP servers documentation. For example the [nginx proxy cache config](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache)\n\n\n\n## Other Django tile server solutions\n\n- [django-geojson-tiles](https://github.com/glenrobertson/django-geojson-tiles) - Generates GeoJSON tiles from a GeoDjango model. No MBTiles support.  Not to be used as a base layer.\n\n- [django-vectortiles](https://github.com/submarcos/django-vectortiles) - Generates Vector Tile layers from GeoDjango. No MBTiles support. Not to be used as a base layer.\n\n- [django-mbtiles](https://github.com/makinacorpus/django-mbtiles) - Uses MBTiles to generate rastered tiles and [UTFGrid](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md). Does not support modern vector tiles. Strong inspiration for this project.\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Integrated Django Vector Tile Server based on mbtiles",
    "version": "0.3.7",
    "split_keywords": [
        "django",
        "map",
        "mbtiles"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "4e5f145ec48cc283c31494b5e65a77f4",
                "sha256": "a60fe2f35b27c4c2fffadd1bba8845bc777d2de7f079fab4b5330b62035b2c61"
            },
            "downloads": -1,
            "filename": "django_tiles_gl-0.3.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4e5f145ec48cc283c31494b5e65a77f4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 3179659,
            "upload_time": "2022-12-03T11:52:06",
            "upload_time_iso_8601": "2022-12-03T11:52:06.098558Z",
            "url": "https://files.pythonhosted.org/packages/8f/ed/d1bacff083e7d6708f6d4366792e88a3ec66b959ea34102724a6c13151f9/django_tiles_gl-0.3.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "a26ffd5aa655c13d799d7f1e46efd59b",
                "sha256": "f89f93bacc167f8bf0c27ac7cac0ff69e214ad60b5b4c98e745c939bd8ae6f23"
            },
            "downloads": -1,
            "filename": "django_tiles_gl-0.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "a26ffd5aa655c13d799d7f1e46efd59b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 2431827,
            "upload_time": "2022-12-03T11:52:09",
            "upload_time_iso_8601": "2022-12-03T11:52:09.370655Z",
            "url": "https://files.pythonhosted.org/packages/8a/54/19cf8c514f55830c14eca0b1729dd15c081205d8711234b0a2b912264f6f/django_tiles_gl-0.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-03 11:52:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "kleingeist",
    "github_project": "django-tiles-gl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-tiles-gl"
}
        
Elapsed time: 0.01309s