2021-09-21 01:47:58 +02:00
|
|
|
/**
|
|
|
|
* SHows geojson on the given leaflet map, but attempts to figure out the correct layer first
|
|
|
|
*/
|
2022-07-08 03:14:55 +02:00
|
|
|
import { Store } from "../../Logic/UIEventSource"
|
2021-09-21 02:10:42 +02:00
|
|
|
import ShowDataLayer from "./ShowDataLayer"
|
|
|
|
import PerLayerFeatureSourceSplitter from "../../Logic/FeatureSource/PerLayerFeatureSourceSplitter"
|
|
|
|
import FilteredLayer from "../../Models/FilteredLayer"
|
|
|
|
import { ShowDataLayerOptions } from "./ShowDataLayerOptions"
|
2023-03-24 19:21:15 +01:00
|
|
|
import { Map as MlMap } from "maplibre-gl"
|
2021-09-21 01:47:58 +02:00
|
|
|
export default class ShowDataMultiLayer {
|
2023-03-24 19:21:15 +01:00
|
|
|
constructor(
|
|
|
|
map: Store<MlMap>,
|
|
|
|
options: ShowDataLayerOptions & { layers: Store<FilteredLayer[]> }
|
|
|
|
) {
|
2021-09-21 01:47:58 +02:00
|
|
|
new PerLayerFeatureSourceSplitter(
|
|
|
|
options.layers,
|
|
|
|
(perLayer) => {
|
|
|
|
const newOptions = {
|
2021-12-09 01:22:57 +01:00
|
|
|
...options,
|
2023-03-24 19:21:15 +01:00
|
|
|
layer: perLayer.layer.layerDef,
|
2021-12-09 01:22:57 +01:00
|
|
|
features: perLayer,
|
2021-09-21 01:47:58 +02:00
|
|
|
}
|
2023-03-24 19:21:15 +01:00
|
|
|
new ShowDataLayer(map, newOptions)
|
2021-09-21 01:47:58 +02:00
|
|
|
},
|
|
|
|
options.features
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|