Add maxzoom capability to layers

This commit is contained in:
pietervdvn 2021-03-21 01:36:34 +01:00
parent f0765df5ed
commit 878cb6d47d
5 changed files with 18 additions and 7 deletions

View file

@ -30,6 +30,7 @@ export default class LayerConfig {
doNotDownload: boolean;
passAllFeatures: boolean;
minzoom: number;
maxzoom: number;
title?: TagRenderingConfig;
titleIcons: TagRenderingConfig[];
icon: TagRenderingConfig;
@ -90,7 +91,8 @@ export default class LayerConfig {
this.doNotDownload = json.doNotDownload ?? false;
this.passAllFeatures = json.passAllFeatures ?? false;
this.minzoom = json.minzoom;
this.minzoom = json.minzoom ?? 0;
this.maxzoom = json.maxzoom ?? 1000;
this.wayHandling = json.wayHandling ?? 0;
this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 0;
this.presets = (json.presets ?? []).map((pr, i) =>
@ -125,7 +127,6 @@ export default class LayerConfig {
/**
* Converts a list of tagRenderingCOnfigJSON in to TagRenderingConfig
* A string is interpreted as a name to call
* @param tagRenderings
*/
function trs(tagRenderings?: (string | TagRenderingConfigJson)[], readOnly = false) {
if (tagRenderings === undefined) {

View file

@ -49,10 +49,15 @@ export interface LayerConfigJson {
/**
* The zoomlevel at which point the data is shown and loaded.
* Default: 0
*/
minzoom: number;
minzoom?: number;
/**
* The zoomlevel at which point the data is hidden again
* Default: 100 (thus: always visible
*/
maxzoom?: number;
/**
* The title shown in a popup for elements of this layer.

View file

@ -71,6 +71,9 @@ export default class FilteringFeatureSource implements FeatureSource {
if (l.zoom < layer.layerDef.minzoom) {
continue;
}
if(l.zoom > layer.layerDef.maxzoom){
continue;
}
if (!layer.isDisplayed.data) {
continue;
}
@ -102,6 +105,6 @@ export default class FilteringFeatureSource implements FeatureSource {
isDisplayed: UIEventSource<boolean>,
layerDef: LayerConfig
}, location: UIEventSource<Loc>) {
return layer.isDisplayed.data && (layer.layerDef.minzoom <= location.data.zoom)
return layer.isDisplayed.data && (layer.layerDef.minzoom <= location.data.zoom) && (layer.layerDef.maxzoom >= location.data.zoom)
}
}

View file

@ -179,6 +179,7 @@ export default class ShowDataLayer {
type: "FeatureCollection",
features: []
}
// @ts-ignore
return L.geoJSON(data, {
style: feature => self.createStyleFor(feature),
pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng),

View file

@ -41,7 +41,8 @@
"maxOverlapPercentage": 0,
"name": "test",
"title": "Test",
"minzoom": 0
"minzoom": 0,
"maxzoom": 14
}