osm2vectortiles/docs/serve-raster-tiles-docker.md

74 wiersze
2.2 KiB
Markdown
Czysty Zwykły widok Historia

2015-12-15 15:40:39 +00:00
---
layout: page
title: Serve Raster Tiles with Docker
published: true
---
2015-12-15 14:18:31 +00:00
2015-12-17 14:24:26 +00:00
# Serve Raster Tiles with Docker
You can render raster tiles from a Mapbox Studio Classic **.tm2** style project and a vector tile MBTiles file
with the help of Docker and [tileserver-mapnik](https://github.com/klokantech/tileserver-mapnik).
2015-12-15 14:18:31 +00:00
For a single map you can serve up to 50 users concurrently with a standard 4GB VPS server with Docker installed.
## Preparation
2015-12-17 14:01:56 +00:00
1. Download MBTiles
2. Clone a **tm2** project (visual style)
2015-12-15 14:18:31 +00:00
3. Add both to the same directory
### Download MBTiles
On the server download your desired extract of a country or the
2015-12-17 14:21:36 +00:00
entire world MBTiles of the [Downloads page](/downloads).
2015-12-15 14:18:31 +00:00
```bash
wget -c https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v1.0/world.mbtiles
```
2015-12-17 14:21:36 +00:00
You can also download a smaller extract like Zurich.
```bash
wget -c https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v1.0/extracts/zurich.mbtiles
```
2015-12-15 14:18:31 +00:00
### Clone the Style Project
Clone your custom style project or in this example the official OSM Bright style.
```bash
git clone https://github.com/mapbox/mapbox-studio-osm-bright.tm2.git
```
## Run the raster tile server
Make sure you have the style project and the MBTiles file in the same directory.
```bash
├── mapbox-studio-osm-bright.tm2
└── world.mbtiles
```
Now run Docker via the command line to serve raster tiles.
2015-12-17 14:01:56 +00:00
The raster tiles will be exposed at port 8080 of your Docker host.
2015-12-15 14:18:31 +00:00
```bash
docker run -v $(pwd):/data -p 8080:80 klokantech/tileserver-mapnik
2015-12-15 14:18:31 +00:00
```
## Use the Raster Tiles
2015-12-17 14:21:36 +00:00
If you visit your Docker host on port 8080 you should see your map appearing
2015-12-17 14:21:36 +00:00
in the interface. If you click on the map thumbnail you will get the configuration
of the most common GIS clients and mapping libraries.
2015-12-17 14:21:36 +00:00
![Mapping libraries configuration](/media/tileserver_docker_cmd.png)
Choose `Source code` in `Leaflet` to get the source code for e.g. Leaflet.
2015-12-17 14:21:36 +00:00
![Leaflet configuration](/media/leaflet_configuration_tileserver.png)
2015-12-17 14:01:56 +00:00
The server will now provide a TileJSON endpoint at the service URL of the map.
For this example the TileJSON endpoint is `http://192.168.99.101:8080/mapbox-studio-osm-bright/index.json`.
You need to reference this TileJSON endpoint in the Leaflet configuration.