Search code examples
mapboxmbtilesopenmaptilestileserver-gl

Mapbox - invalid tile order


I am working on my own tile server. I have weird problems with displaying tiles in the correct order. Tiles were created using OSM data. When I use tileserver-gl-light as a tiles server everything seems to be ok, but when I try to serve tiles by my own server they do not appear in correct order after zooming. I use the same page to render the map so I think the problem is connected with the server. The tiles look like this (Zoom 1):

enter image description here

I appreciate any help. Best regards, Marek


Solution

  • I don't know the reason why but there was a need for correction y axis value before fetching data from mbtiles database.

    If your tiles url looks like: http://host:port/data/{z}/{x}/{y} you need to recalculate y value before fetching tile data in pbf format from database:

    y = pow(2, z) - 1 - y
    

    There is no mention about this in mbtiles specification but I found the solution in Tileserver-PHP source code