mapcomplete/UI/Map/ShowDataMultiLayer.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
1,016 B
TypeScript
Raw Normal View History

/**
* 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"
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"
export default class ShowDataMultiLayer {
2023-03-24 19:21:15 +01:00
constructor(
map: Store<MlMap>,
options: ShowDataLayerOptions & { layers: Store<FilteredLayer[]> }
) {
new PerLayerFeatureSourceSplitter(
options.layers,
(perLayer) => {
const newOptions = {
...options,
2023-03-24 19:21:15 +01:00
layer: perLayer.layer.layerDef,
features: perLayer,
}
2023-03-24 19:21:15 +01:00
new ShowDataLayer(map, newOptions)
},
options.features
)
}
}