Mapbox 新 API 和图像压缩
Mapbox new API and image compression
貌似mapbox在新的mapbox studio online上使用了新的API,例如:
https://api.mapbox.com/styles/v1/mapbox/outdoors-v9/tiles/256/{z}/{x}/{y}?access_token=mapboxAccessToken;
在 "old time" 中,很容易在 {y} 之后添加 .jpg70 等,但有了这个新的 url,它就不再起作用了。
有谁知道这个新 api 是如何工作的?
提前致谢
Mapbox.js 有设置图块图像格式的选项。这可能不是您所指的 new API。请说明您使用的是 mapbox.js
还是 mapbox-gl.js
.
从 Mapbox 查看 tileLayer.setFormat(format)
. Also, see the working example of Low bandwidth maps。
// Downsample tiles for faster loading times on slow
// internet connections
var layer = L.mapbox.tileLayer('mapbox.streets', {
format: 'jpg70'
});
所以我从 Mapbox 得到了答案。
新 mapbox Studio Style(在线)的压缩会根据浏览器自动以 jpg 或 webp 格式完成。但它只适用于像 Mapbox 卫星街道这样的光栅图块。
如果您在 mapbox studio 上设计没有任何光栅层的地图,诀窍是上传一个 geotiff,例如在背景上使用纯色,将其指定为所需的样式并将不透明度设置为 0.01。然后压缩就可以了!
貌似mapbox在新的mapbox studio online上使用了新的API,例如:
https://api.mapbox.com/styles/v1/mapbox/outdoors-v9/tiles/256/{z}/{x}/{y}?access_token=mapboxAccessToken;
在 "old time" 中,很容易在 {y} 之后添加 .jpg70 等,但有了这个新的 url,它就不再起作用了。
有谁知道这个新 api 是如何工作的?
提前致谢
Mapbox.js 有设置图块图像格式的选项。这可能不是您所指的 new API。请说明您使用的是 mapbox.js
还是 mapbox-gl.js
.
从 Mapbox 查看 tileLayer.setFormat(format)
. Also, see the working example of Low bandwidth maps。
// Downsample tiles for faster loading times on slow
// internet connections
var layer = L.mapbox.tileLayer('mapbox.streets', {
format: 'jpg70'
});
所以我从 Mapbox 得到了答案。
新 mapbox Studio Style(在线)的压缩会根据浏览器自动以 jpg 或 webp 格式完成。但它只适用于像 Mapbox 卫星街道这样的光栅图块。
如果您在 mapbox studio 上设计没有任何光栅层的地图,诀窍是上传一个 geotiff,例如在背景上使用纯色,将其指定为所需的样式并将不透明度设置为 0.01。然后压缩就可以了!