显示精确大小的图标

Displaying icons with exact size

我想要在我的地图上使用精确大小的图标,其中每个图标在地图上占据预定义的大小(以米为单位)。此外,这些需要在运行时进行更改,因此无法提前生成覆盖整个地图的图像。我的用例是显示待涂漆的路面标记,因此 3 平方米可能是显示的最大东西。通过设置 icon-rotation-alignment to map, leaving the issue of size. I could scale the icon-size by interpolate-ing the zoom factor (['interpolate', ['exponential', 2], ['zoom'], 15, 1 / 72, 22, 1 / 0.56]), but I would then run into problems with the difference in latitudes with the Mercator projection 可以轻松匹配旋转和俯仰。不过,根据缩放比例和当前纬度进行插值可能是可能的。

另外,Add a 3D model, Add a canvas source, Add a custom style layer (although I don't think I need that), and Add an image 一些看起来执行类似对齐真实世界大小任务的演示。我对如何使用每个的理解:

以下哪个是最佳选择?

您可以使用 mapbox 中的栅格图层轻松完成此操作,但您需要使用考虑纬度的转换在您这边计算图像 4 个角的长度(以米为单位)。

其他选项,如果你想添加精确米大小的图像(考虑到纬度),只需查看使用最新版本 threebox

制作的这个

您将能够加载任何图像(和任何 3D 模型)并以米(实际上是毫米)为单位定义其大小,只需几行代码,但使用 threejs 插件来完成纯 2D 任务大概就像在桶里射鱼一样。