gpt4 book ai didi

php - Mapbox 静态 map 大数据集

转载 作者:行者123 更新时间:2023-12-04 13:43:36 31 4
gpt4 key购买 nike

我尝试使用 mapbox 静态 api 返回显示基于坐标的特定路线的 map 。

https://www.mapbox.com/api-documentation/?language=cURL#retrieve-a-static-map-from-a-style

这是有效的,但是,这受 URL 长度的限制,如何根据具有大量坐标的数据集生成静态 map ?

最佳答案

如文档中所述:

Using a large GeoJSON object as an argument to the overlay parameter may result in hitting the 8,192 byte URL length limit. Possible options for shortening the resulting URL length include:

  • Simplifying your GeoJSON using a third party library, such as simplify-geojson, before passing it as an argument.
  • Limiting the precision of the coordinates in the GeoJSON to no more than five to six decimals places, which would allow you to make use of more points in the GeoJSON itself.


但是,您的文件轨道(geojson、gpx 等)可能太大,以至于上述所有选项都无法有效地将其减少到字符限制以下。

所以最后一个解决方案是下面的一个。首先将您的文件上传为图块集(而不是您所做的数据集),将其作为图层添加到自定义样式,然后从中生成静态 map 。

  • If the GeoJSON consists of a large and detailed polygon, you could create a custom style in Mapbox Studio including the polygon, and pass the resulting style ID to the style_id parameter of the Static Images API instead of using the overlay parameter. First upload the GeoJSON to Mapbox as a tileset, and then add it as a layer in a custom style. Reference this tutorial for guidance.


来源: https://docs.mapbox.com/api/maps/#static-images

因此,首先,您需要了解如何将文件上传到您的 MapBox 帐户:
https://docs.mapbox.com/help/how-mapbox-works/uploading-data/

我知道这个帖子很旧,希望它能帮助其他开发者。
对不起我的英语不好,
托马斯

关于php - Mapbox 静态 map 大数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53090933/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com