是否可以使用 Mapbox API 突出显示用户绘制的多边形内的要素?
Is it possible to highlight features within a user drawn polygon using the Mapbox API?
Mapbox 提供了一个使用带有 queryRenderedFeatures 调用的边界框的示例。
突出显示边界框内的特征
https://docs.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/
我想使用多边形而不是边界框来执行此操作。
我知道如何绘制多边形。我不知道如何用多边形查询渲染的要素。
最直接的方法是使用 Turf 的 pointsWithinPolygon function, assuming they are points. Depending on your exact needs, booleanWithin or booleanOverlap 可能是您想要的。
Mapbox 提供了一个使用带有 queryRenderedFeatures 调用的边界框的示例。
突出显示边界框内的特征 https://docs.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/
我想使用多边形而不是边界框来执行此操作。 我知道如何绘制多边形。我不知道如何用多边形查询渲染的要素。
最直接的方法是使用 Turf 的 pointsWithinPolygon function, assuming they are points. Depending on your exact needs, booleanWithin or booleanOverlap 可能是您想要的。