mapbox-gl可以组geoJSON特性的值内属性对象?



在传单中我可以这样写:

const [groupedLayers] = useState<DeviceFeedLayerGroups>({
mine: new LayerGroup(),
public: new LayerGroup(),
private: new LayerGroup(),
favorite: new LayerGroup(),
});
const onEachFeature = (
feature: Feature<Geometry, NexusGenAllTypes['GeoJSONFeatureProperties']>,
layer: L.Layer,
) => {
/* ... */
groupedLayers[feature.properties.relation].addLayer(layer);
}
geoJSON(deviceFeed, {
pointToLayer,
onEachFeature,
});

这样我就可以有一组可以打开或关闭的图层。这可以用mapbox-gl完成吗?

谢谢。

我不完全理解你所说的传单功能,但是:

Mapbox GL JS不支持"的层。但是,您可以使用过滤器制作一个GeoJSON源,其中包含多个显示不同特性的层。然后可以独立显示或隐藏每一层。

最新更新