mapbox-gl-js
mapbox-gl-js copied to clipboard
mapbox-gl-js can not render pyramid images
hi, when i use mapbox-gl-js to render pyramid image and image not find correct.
- source url is
https://github.com/shiweihappy/mapbox-gl-js-source
- i use gdal2tile.py to create pyramid image:
python gdal2tiles.py -r near -s EPSG:3857 -z "0-15" -w openlayers a4.tif ./a4/
- then i put pyramid images to local nginx static source folder
xxxx/tiles/a4/xxxxx
-
nginx already set cors and other vector tiles use correctly
-
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);
- 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?
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 , thank you very much!