-1

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

Marek Marczak
  • 532
  • 8
  • 14

2 Answers2

1

Set the scheme to "tms" when adding layer to mapbox-gl like this:

    map.addLayer({
      id: 'tms_layer',
      type: 'raster',
      source: {
        type: 'raster',
        tiles: [
          'https://tile-server/{z}/{x}/{y}.png'
        ],
        scheme: 'tms'
      },
    });

This happens because certain tile servers use the OSGeo spec scheme.

More info here: https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources-raster-scheme

Manish
  • 4,903
  • 1
  • 29
  • 39
0

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

Marek Marczak
  • 532
  • 8
  • 14