php - Mapbox 静态 map 大数据集

标签 php dataset mapbox

我尝试使用 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/

相关文章:

r - 从R数据集中的特定向量中提取第一个字母

c# - 如何只更新已更改的字段?

javascript - React-mapbox-gl 中的样式标记/功能?

ios - MapBox iOS SDK : add map event

swift 4 : 'subscript' is unavailable error

php - CodeIgniter 1.7 认证库

javascript - 如何让我的查询读取字母(Ñ)

php - 如何从 PHP 中的文本字符串中删除隐藏字符?

php - 如何在 Laravel 中验证最大文件大小?

c# - WCF 服务返回数据集