mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

mapbox-gl-js can not render pyramid images

Open shiweihappy opened this issue 9 years ago • 2 comments

hi, when i use mapbox-gl-js to render pyramid image and image not find correct.

  1. source url is https://github.com/shiweihappy/mapbox-gl-js-source

source

  1. i use gdal2tile.py to create pyramid image:

python gdal2tiles.py -r near -s EPSG:3857 -z "0-15" -w openlayers a4.tif ./a4/

  1. then i put pyramid images to local nginx static source folder

xxxx/tiles/a4/xxxxx

  1. nginx already set cors and other vector tiles use correctly

  2. html render code:

var ndvi_source = {
    "type": "raster",
    'tiles': [
        "http://localhost:7777/tiles/a4/{z}/{x}/{y}.png"
    ],
    'tileSize': 256,
    'bounds': [121.849365234, 41.428569989, 121.947212219, 41.4838910427]
};
var ndvi_layer = {
    "id": "ndvi_layer_id",
    "type": "raster",
    "source": "ndvi_source",
    'paint': {}
};
map.addSource('ndvi_source', ndvi_source);
map.addLayer(ndvi_layer);
  1. then open html i found that, mapbox-gl-js can not find pyramid image, but i use leaflet or openlayer3 is correct. so i do not know why mapbox-gl-js not find correct image x/y/z?

shiweihappy avatar Nov 06 '17 07:11 shiweihappy

gdal2tiles generates tiles with TMS numbering scheme, so you need to set "scheme": "tms" in the source options. Sorry for not having documentation for this property yet -- it'll be documented on https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-raster in the next release.

jfirebaugh avatar Nov 06 '17 23:11 jfirebaugh

@jfirebaugh , thank you very much!

shiweihappy avatar Nov 07 '17 02:11 shiweihappy