Public Repository

Last pushed: a year ago
Short Description
构建tileserver-mapnik的服务
Full Description

在tileserver-mapnik的基础上,构建凡米物联科技自己的矢量地图瓦片服务

Docker Pull Command
Owner
kevinjiang

Comments (5)
kevinjiang
a year ago

3.0
FROM kevinjiang/tileserver-mapnik-fm:2.0
MAINTAINER kevinjiang jiangxingkai@fmbj.com.cn

RUN rm -rf /project/*

VOLUME /data
ENV SOURCE_DATA_DIR=/data \
DEST_DATA_DIR=/project \
PORT=8888 \
MAPNIK_FONT_PATH=/fonts \
DOMAINS=

EXPOSE 8888
CMD ["/usr/src/app/run.sh"]

kevinjiang
a year ago

3.0
假如容器运行命令:
sudo docker run -v /fm-dev/mapData:/data --net=host -p 8888:8888 kevinjiang/tileserver-mapnik-fm:3.0

kevinjiang
a year ago

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.

For a single map you can serve up to 50 users concurrently with a standard 4GB VPS server with Docker installed.

Preparation
Download MBTiles
Clone a tm2 project (visual style)
Add both to the same directory
Download MBTiles

On the server download your desired extract of a country or the entire world MBTiles of the Downloads page.

wget -c https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v1.0/world.mbtiles
You can also download a smaller extract like Zurich.

wget -c https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v1.0/extracts/zurich.mbtiles
Clone the Style Project

Clone your custom style project or in this example the official OSM Bright style.

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.

├── mapbox-studio-osm-bright.tm2
└── world.mbtiles
Now run Docker via the command line to serve raster tiles. The raster tiles will be exposed at port 8080 of your Docker host.

docker run -v $(pwd):/data -p 8080:80 klokantech/tileserver-mapnik
Use the Raster Tiles
If you visit your Docker host on port 8080 you should see your map appearing in the interface. If you click on the map thumbnail you will get the configuration of the most common GIS clients and mapping libraries.

Mapping libraries configuration

Choose Source code in Leaflet to get the source code for e.g. Leaflet.

Leaflet configuration

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.

Sponsors

kevinjiang
a year ago

tileserver-mapnik
Mapnik-based tile server generating raster tiles from tilelive-js sources (MapBox Studio project + custom vector tiles for example). It supports also static maps API.

How to use

Docker

The easiest way to run tileserver-mapnik is using the precompiled docker container (https://hub.docker.com/r/klokantech/tileserver-mapnik/).

Detailed instructions how to use the tileserver-mapnik with docker: http://osm2vectortiles.org/docs/serve-raster-tiles-docker

Without docker

Follow the commands in Dockerfile to install the necessary packages, download common fonts and prepare the environment.

Usage: node bin/tessera.js [options]

Options:

-c CONFIG - Configuration file
-p PORT - HTTP port [8080]
-C SIZE - Cache size in MB [10]
-S SIZE - Source cache size (in # of sources) [10]
Example configuration file

{
"/style1": {
"source": "tmstyle://./style1.tm2"
},
"/style2": {
"source": "tmstyle:///home/user/style2.tm2"
},
"/vector": {
"source": "mbtiles:///home/user/data.mbtiles"
}
}
Note: For tm2 styles, you need to make sure the content of style's project.yml (its source property) points to a valid mbtiles file (e.g. source: "mbtiles://./data.mbtiles").

Available URLs

If you visit the server on the configured port (default 8080) you should see your maps appearing in the browser.
The tiles itself are served at /{basename}/{z}/{x}/{y}[@2x].{format}
The optional @2x part can be used to render HiDPI (retina) tiles
Static images are rendered at:
/{basename}/static/{lon},{lat},{zoom}/{width}x{height}[@2x].{format} (center-based)
/{basename}/static/{minx},{miny},{maxx},{maxy}/{zoom}[@2x].{format} (area-based)
TileJSON at /{basename}/index.json "# tileserver-mapnik-customs"