tileserver-php
tileserver-php copied to clipboard
Serving tiles with tileserver-php - land and water polygons missing?
I apologize if this is the wrong repo - it's kinda hard to figure out where this should go, as I'm not sure where the problem is, exactly.
Briefly, I'm trying to serve an mbtiles file for USA downloaded from osm2vectortiles via tileserver-php (the reason is that the machine serving it is running FreeBSD, and successfully building all the requisite Node modules even for tileserver-gl-lite, much less tileserver-gl, has proven to be very difficult - most native modules seem to assume it's either Linux or OS X, and there's a lot of build script breakage etc).
Based on this bug being closed with "implementation finished", I assumed that this is a supported scenario: klokantech/tileserver-php#42
Now, when trying to actually test it, using tileserver-php's own index page, I'm seeing the maps, but it seems like the base layer (land and water polygons? not sure what it's called properly) is missing. Here's how it looks:

(It is the same at any zoom level)
Now, all I did was follow the instructions on tileserver-php: unpack it into the www folder of a PHP (7.0) enabled Apache 2.4 installation, copy .mbtiles file there, and open it in the browser.
Is there some configuration step that I'm missing specifically for .mbtiles from osm2vectortiles? Do I need to download some separate vector tileset for those polygons?
OSM2VectorTiles has been closed down. Mapbox claims it breaches their intellectual property, so OSM2VT tiles should not be used in production...
Please download vector tiles from our new project. We have spent another 3 months on implementing a new vector tile schema to avoid the claimed copyright issues: https://openmaptiles.org/.
The screenshot above looks correct - nothing is missing.
This is an x-ray / inspect view on the raw vector tile data...
You have to apply a style on these raw data - to see a nice looking map with land and water in natural colors.
The easiest way how to do that is if you fork or download one of the styles from https://openmaptiles.org/styles/.
For example download and host on your server this: https://github.com/openmaptiles/osm-bright-gl-style/tree/gh-pages
And replace the links to CDN hosting with links to your own TileServerPHP: https://github.com/openmaptiles/osm-bright-gl-style/blob/gh-pages/style-cdn.json#L51
(Never use the temporary key in JSON for CDN hosting - get yours at: https://openmaptiles.com/hosting/ if you need it)
Fonts are available at https://github.com/openmaptiles/fonts, if you want to host it from static directory, you must remove from the JSON the alternative fonts (always use only one font instead of two or three).
BTW If you find this tips helpful - would you be please so kind and improve the documentation at: https://openmaptiles.org/docs/host/tileserver-php/.
Just edit: https://github.com/openmaptiles/www.openmaptiles.org/blob/master/docs/host/tileserver-php.md
Thank you very much! Downloading the new tiles now.
That explains things. I thought it might be some sort of debug mode (what with all the info displayed when hovering over objects), but the docs don't really mention that subject at all, and the demo server has pretty maps, so that got me confused :)
I'll give this a try once I have the tiles, and add a short step-by-step section to the docs if successful.
Hi @int19h - have you managed to make it run for you?
Improvement of the docs would be amazing! :+1:
Yep, it worked! Ran into some trouble with the fonts - per the instructions at https://github.com/openmaptiles/fonts, I specified this in the style:
"glyphs": "http://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
However, it didn't work, and looking at the page at http://fonts.openmaptiles.org/, it looks like there's nothing there? I'm curious as to whether I'm missing something, or the URL changed and instructions in that repo are out of sync.
Then I synced https://github.com/openmaptiles/fonts locally, and served them from Apache as well. As you noted earlier, to do so, I had to clean up the style, going over all "text-font" entries, and leaving only a single font there.
However, I'd still like to find out what the recommended way to deal with the fonts is. If it's to host them locally alongside the tile server, then I'll go with that when writing the step-by-step walkthrough. But if it's serving them from some public place, then I need to figure out why that's not working.
(For my own purposes, I really wanted a 100% offline solution, so hosting fonts locally is preferred anyway. I'm also hosting Mapbox itself locally.)
If you want to use fonts statically, then the JSON style must request only one font - so your modification of the style is correct. This is a way forward if you want all assets served from a static files.
TileServer PHP serves always only the raw tiles.
TileServer GL Light is able to serve the multiple fonts on merged URLs ("font1,font2"), next to serving the vector tiles and styles offline.
@int19h could you please then summarise your findings and make a paragraph or two at: https://github.com/openmaptiles/www.openmaptiles.org/blob/master/docs/host/tileserver-php.md ?
Could you clarify the bit about having fonts served from http://fonts.openmaptiles.org/? Is it supposed to work with alternative fonts in the style? or with just a single font? I couldn't make it work with either, seemingly because the page is 404 - is the corresponding URL in the stylesheet just a deprecated leftover?
If your style uses one font, you can serve it as static files - such as with the static hosting on github like fonts.openmaptiles.org do. So change your GL style JSON to load only OpenSans and it will run.
If your JSON style uses multiple fonts, you need font concatenation on the server side - which is not available on static hosted fonts.openmaptiles.org. Then use TileServer GL Light - or hosted free.tilehosting.com.
We use the openmaptiles/free repository as the storage of the fonts - for the deployment of these.
I still can't make it work with http://fonts.openmaptiles.org. I don't know why - the style only references a single font at a time, and it works when I host those fonts locally. At the same time, when I try to access .pbf files from http://fonts.openmaptiles.org using URIs formatted the way Mapbox GL JS generates them, I can actually download the files, so I'm not sure what the real problem is there.
I have started a PR for the doc updates, including all the steps: https://github.com/openmaptiles/www.openmaptiles.org/pull/11. This still does reference http://fonts.openmaptiles.org for completeness, but in reality I was only successful with locally hosted fonts.