MapBox and TIFF

2019-08-12 06:06发布

问题:

I am trying to show my TIFF file at the MapBox's map. I am starting with this example: https://www.mapbox.com/mapbox-gl-js/example/vector-source/ by replacing

map.addSource('terrain-data', {
    type: 'vector',
    url: 'mapbox://mapbox.mapbox-terrain-v2'
});

with

map.addSource('terrain-data', {
    type: 'vector',
    url: 'mapbox://xxx.yyy'
});

where xxx.yyy is my Map ID from Data section of the account (https://www.mapbox.com/studio/data/)

JavaScript initiates needed calls (to some jpg files), but all of them come with 404 error and the following message: {"message":"Tile does not exist"}

回答1:

If xxx.yyy is a tileset resulting from a TIFF upload, it's a raster source, not a vector source. You will need to replace type: 'vector' with type: 'raster', specify tileSize: 256, and use it as the source for raster layers.