Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1c835c21d | ||
|
|
15ed6d74bf | ||
|
|
a3d8240aac | ||
|
|
098f057e55 | ||
|
|
18ba6f5059 | ||
|
|
820dbdd3dd | ||
|
|
acd7683f18 | ||
|
|
09859c10c1 | ||
|
|
f201deecdc | ||
|
|
b49521d2ed | ||
|
|
30c9bc8979 |
43
README.md
43
README.md
@@ -1,19 +1,46 @@
|
||||

|
||||
|
||||
|
||||
# TileServer GL
|
||||
[](https://travis-ci.org/klokantech/tileserver-gl)
|
||||
[](https://hub.docker.com/r/klokantech/tileserver-gl/)
|
||||
|
||||
Vector and raster maps with GL styles. Map tile server for Mapbox Android, iOS, GL JS, Leaflet, OpenLayers, GIS via WMTS, etc. Server side rendering by Mapbox GL Native.
|
||||
Vector and raster maps with GL styles. Server side rendering by Mapbox GL Native. Map tile server for Mapbox GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
|
||||
|
||||
## Quickstart
|
||||
Use `npm install -g tileserver-gl` to install the package from npm.
|
||||
## Get Started
|
||||
|
||||
Then you can simply run `tileserver-gl zurich_switzerland.mbtiles` to start the server for the given mbtiles.
|
||||
Install `tileserver-gl` with server-side raster rendering of vector tiles with npm
|
||||
|
||||
Or you can use `docker run -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl` to run the server inside a docker container.
|
||||
```bash
|
||||
npm install -g tileserver-gl
|
||||
```
|
||||
|
||||
Alternatively, you can use `tileserver-gl-light` package instead, which is pure javascript (does not have any native dependencies) and can run anywhere, but does not contain rasterization features.
|
||||
Now download vector tiles from [OSM2VectorTiles](http://osm2vectortiles.org/downloads/).
|
||||
|
||||
Prepared vector tiles can be downloaded from [OSM2VectorTiles](http://osm2vectortiles.org/).
|
||||
```bash
|
||||
curl -o zurich_switzerland.mbtiles https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v2.0/extracts/zurich_switzerland.mbtiles
|
||||
```
|
||||
|
||||
Start `tileserver-gl` with the downloaded vector tiles.
|
||||
|
||||
```bash
|
||||
tileserver-gl zurich_switzerland.mbtiles
|
||||
```
|
||||
|
||||
Alternatively, you can use the `tileserver-gl-light` package instead, which is pure javascript (does not have any native dependencies) and can run anywhere, but does not contain rasterization on the server side made with MapBox GL Native.
|
||||
|
||||
## Using Docker
|
||||
|
||||
An alternative to npm to start the packed software easier is to install [Docker](http://www.docker.com/) on your computer and then run in the directory with the downloaded MBTiles the command:
|
||||
|
||||
```bash
|
||||
docker run -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl
|
||||
```
|
||||
|
||||
This will download and start a ready to use container on your computer and the maps are going to be available in webbrowser on localhost:8080.
|
||||
|
||||
On laptop you can use [Docker Kitematic](https://kitematic.com/) and search "tileserver-gl" and run it, then drop in the 'data' folder the MBTiles.
|
||||
|
||||
## Documentation
|
||||
You can read full documentation of this project at http://tileserver.readthedocs.io/.
|
||||
|
||||
You can read full documentation of this project at http://tileserver.readthedocs.io/.
|
||||
|
||||
@@ -27,3 +27,11 @@ Make sure you have Node v4 or higher (nvm install 4) and run::
|
||||
|
||||
npm install
|
||||
node .
|
||||
|
||||
|
||||
On OSX
|
||||
======
|
||||
|
||||
Make sure to have ``pkg-config`` and ``cairo`` installed::
|
||||
|
||||
brew install pkg-config cairo
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.4",
|
||||
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
|
||||
"main": "src/main.js",
|
||||
"bin": "src/main.js",
|
||||
@@ -19,19 +19,19 @@
|
||||
"async": "2.0.1",
|
||||
"advanced-pool": "0.3.2",
|
||||
"base64url": "2.0.0",
|
||||
"canvas": "1.4.0",
|
||||
"canvas": "1.5.0",
|
||||
"clone": "1.0.2",
|
||||
"color": "0.11.3",
|
||||
"cors": "2.8.0",
|
||||
"cors": "2.8.1",
|
||||
"express": "4.14.0",
|
||||
"glyph-pbf-composite": "0.0.2",
|
||||
"handlebars": "4.0.5",
|
||||
"mapbox-gl-native": "3.3.2",
|
||||
"mapbox-gl-native": "3.3.3",
|
||||
"mbtiles": "0.9.0",
|
||||
"morgan": "1.7.0",
|
||||
"node-pngquant-native": "1.0.4",
|
||||
"nomnom": "1.8.1",
|
||||
"request": "2.74.0",
|
||||
"request": "2.75.0",
|
||||
"sharp": "0.16.0",
|
||||
"sphericalmercator": "1.0.5",
|
||||
"tileserver-gl-styles": "0.3.0"
|
||||
|
||||
@@ -124,6 +124,10 @@
|
||||
<div id='map'></div>
|
||||
<script>
|
||||
var map = L.mapbox.map('map', '/data/{{id}}.json{{&key_query}}', { zoomControl: false });
|
||||
map.eachLayer(function(layer) {
|
||||
// do not add scale prefix even if retina display is detected
|
||||
layer.scalePrefix = '.';
|
||||
});
|
||||
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
||||
setTimeout(function() {
|
||||
new L.Hash(map);
|
||||
|
||||
47
src/main.js
47
src/main.js
@@ -70,10 +70,6 @@ var startWithMBTiles = function(mbtilesFile) {
|
||||
}
|
||||
var instance = new mbtiles(mbtilesFile, function(err) {
|
||||
instance.getInfo(function(err, info) {
|
||||
if (info.format != 'pbf') {
|
||||
console.log('ERROR: MBTiles format is not "pbf".');
|
||||
process.exit(1);
|
||||
}
|
||||
var bounds = info.bounds;
|
||||
|
||||
var styleDir = path.resolve(__dirname, "../node_modules/tileserver-gl-styles/");
|
||||
@@ -89,26 +85,35 @@ var startWithMBTiles = function(mbtilesFile) {
|
||||
}
|
||||
},
|
||||
"styles": {},
|
||||
"data": {
|
||||
"osm2vectortiles": {
|
||||
"mbtiles": path.basename(mbtilesFile)
|
||||
}
|
||||
}
|
||||
"data": {}
|
||||
};
|
||||
|
||||
var styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
||||
for (var i=0; i < styles.length; i++) {
|
||||
var styleFilename = styles[i];
|
||||
if (styleFilename.endsWith('.json')) {
|
||||
var styleObject = {
|
||||
"style": path.basename(styleFilename),
|
||||
"tilejson": {
|
||||
"bounds": bounds
|
||||
}
|
||||
};
|
||||
config['styles'][path.basename(styleFilename, '.json')] =
|
||||
styleObject;
|
||||
if (info.format == 'pbf' &&
|
||||
info.name.toLowerCase().indexOf('osm2vectortiles') > -1) {
|
||||
config['data']['osm2vectortiles'] = {
|
||||
"mbtiles": path.basename(mbtilesFile)
|
||||
};
|
||||
|
||||
var styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var styleFilename = styles[i];
|
||||
if (styleFilename.endsWith('.json')) {
|
||||
var styleObject = {
|
||||
"style": path.basename(styleFilename),
|
||||
"tilejson": {
|
||||
"bounds": bounds
|
||||
}
|
||||
};
|
||||
config['styles'][path.basename(styleFilename, '.json')] =
|
||||
styleObject;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('WARN: MBTiles not in "osm2vectortiles" format. ' +
|
||||
'Serving raw data only...');
|
||||
config['data'][info.id || 'mbtiles'] = {
|
||||
"mbtiles": path.basename(mbtilesFile)
|
||||
};
|
||||
}
|
||||
|
||||
if (opts.verbose) {
|
||||
|
||||
@@ -202,6 +202,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
// meta url which will be detected when requested
|
||||
'mbtiles://' + name + '/{z}/{x}/{y}.' + (info.format || 'pbf')
|
||||
];
|
||||
delete source.scheme;
|
||||
if (source.format == 'pbf') {
|
||||
map.sources[name].emptyTile = new Buffer(0);
|
||||
} else {
|
||||
|
||||
@@ -249,7 +249,7 @@ module.exports = function(opts, callback) {
|
||||
|
||||
var tiles = utils.getTileUrls(
|
||||
req, style.serving_rendered.tiles,
|
||||
'styles/' + id, style.serving_rendered.format);
|
||||
'styles/' + id + '/rendered', style.serving_rendered.format);
|
||||
style.xyz_link = tiles[0];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user