mapbox - Mapbox Static API - 如何在 GeoJSON 叠加层中使用自定义标记?
问题描述
文档说这是可能的,所以我显然遗漏了一些东西。到目前为止,我已经在 Mapbox操场上使用单点和特征集合(如示例中所示)测试了 marker-url 和 url- 的不同变体,但我得到的只是通用标记。
有什么指导可以为我指明正确的方向吗?
https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/geojson({"type":"FeatureCollection","features":[{"type":"Feature","properties":{"url-":"http%253A%252F%252Fwebsite.com%252Ffiles%252Fmarkers%252Fgreenpin.png"},"geometry":{"type":"Point","coordinates":[-122.2599,37.8098]}},{"type":"Feature","properties":{"url-":"http%253A%252F%252Fwebsite.com%252Ffiles%252Fmarkers%252Fgreenpin.png"},"geometry":{"type":"Point","coordinates":[-122.2591,37.8062]}},{"type":"Feature","properties":{"url-":"http%253A%252F%252Fwebsite.com%252Ffiles%252Fmarkers%252Fgreenpin.png"},"geometry":{"type":"Point","coordinates":[-122.2565,37.8063]}}]})/-122.2647,37.8006,12,0/1080x1080@2x?access_token={token}
解决方案
这没有反映在官方文档中,但是为了使用带有 geojson 覆盖的自定义标记,您可以依赖该marker-url
属性来实现您的功能。
如果您将对 API 的请求更新为以下内容,您应该会获得所需的结果:
https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/geojson({"type":"FeatureCollection","features":[{"type":"Feature","properties":{"marker-url":"http%253A%252F%252Fwebsite.com%252Ffiles%252Fmarkers%252Fgreenpin.png"},"geometry":{"type":"Point","coordinates":[-122.2599,37.8098]}},{"type":"Feature","properties":{"marker-url":"http%253A%252F%252Fwebsite.com%252Ffiles%252Fmarkers%252Fgreenpin.png"},"geometry":{"type":"Point","coordinates":[-122.2591,37.8062]}},{"type":"Feature","properties":{"marker-url":"http%253A%252F%252Fwebsite.com%252Ffiles%252Fmarkers%252Fgreenpin.png"},"geometry":{"type":"Point","coordinates":[-122.2565,37.8063]}}]})/-122.2647,37.8006,12,0/1080x1080@2x?access_token={token}
免责声明:我目前在 Mapbox 工作
推荐阅读
- python - 将链表中的元素与列表的其余部分进行比较python
- php - PDO 插入空而不是空?
- python - 如何为谓词调用 leaveOut 条目
- c - 在 C 中递归文件时如何打印整个路径名和单个路径名?
- javascript - TypeScript & Yup 错误:“参考”类型的参数
' 不能分配给 'number | 类型的参数 参考 ' - flutter - 哪种架构更适合具有大量 API 调用的 Flutter 应用程序?
- php - 有没有其他方法可以更改 PHP 变量的数据类型?
- java - why is my stack s giving null here when it has elements pushed inside it. what am i missing?
- java - Java Streams() 与 Heap.poll() 的区别
- java - 为什么我在使用最大整数值时得到荒谬的值?