Merge branch 'project/natuurpunt' of https://github.com/pietervdvn/MapComplete into project/natuurpunt
This commit is contained in:
commit
208ab51c73
2 changed files with 25 additions and 1 deletions
|
@ -121,7 +121,6 @@ export default class GeoJsonSource implements FeatureSource {
|
|||
if (location.zoom < flayer.layerDef.minzoom ||
|
||||
location.zoom > flayer.layerDef.maxzoom) {
|
||||
// No need to download! - the layer is disabled
|
||||
console.log("Not loading layers for " + url, "zoom" + location.zoom, " not between", flayer.layerDef.minzoom, "and", flayer.layerDef.maxzoom)
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
25
Logic/FeatureSource/ZoomRespectingFeatureSource.ts
Normal file
25
Logic/FeatureSource/ZoomRespectingFeatureSource.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import FeatureSource from "./FeatureSource";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import LayerConfig from "../../Customizations/JSON/LayerConfig";
|
||||
|
||||
export default class ZoomRespectingFeatureSource implements FeatureSource{
|
||||
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]>;
|
||||
public readonly name: string;
|
||||
|
||||
constructor(layerConfig: LayerConfig, location: UIEventSource<{zoom: number}>, upstream: FeatureSource) {
|
||||
this.name = "zoomrespecting("+upstream.name+")"
|
||||
const empty = []
|
||||
this.features = upstream.features.map(
|
||||
features => {
|
||||
const z = location.data.zoom
|
||||
|
||||
if(layerConfig.minzoom < z || layerConfig.maxzoom > z){
|
||||
return empty
|
||||
}
|
||||
|
||||
|
||||
return features
|
||||
},[location]
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue