From 878cb6d47db502a8c8cc4c15e0bcc0099a25f6fc Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 21 Mar 2021 01:36:34 +0100 Subject: [PATCH] Add maxzoom capability to layers --- Customizations/JSON/LayerConfig.ts | 7 ++++--- Customizations/JSON/LayerConfigJson.ts | 9 +++++++-- Logic/FeatureSource/FilteringFeatureSource.ts | 5 ++++- UI/ShowDataLayer.ts | 1 + assets/themes/speelplekken/speelplekken.json | 3 ++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index af0b7d3..0a4b444 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -30,6 +30,7 @@ export default class LayerConfig { doNotDownload: boolean; passAllFeatures: boolean; minzoom: number; + maxzoom: number; title?: TagRenderingConfig; titleIcons: TagRenderingConfig[]; icon: TagRenderingConfig; @@ -49,7 +50,7 @@ export default class LayerConfig { }[]; tagRenderings: TagRenderingConfig []; - + constructor(json: LayerConfigJson, context?: string) { context = context + "." + json.id; @@ -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) { diff --git a/Customizations/JSON/LayerConfigJson.ts b/Customizations/JSON/LayerConfigJson.ts index 1be2df7..2c253ea 100644 --- a/Customizations/JSON/LayerConfigJson.ts +++ b/Customizations/JSON/LayerConfigJson.ts @@ -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. diff --git a/Logic/FeatureSource/FilteringFeatureSource.ts b/Logic/FeatureSource/FilteringFeatureSource.ts index 1743567..b5f6a37 100644 --- a/Logic/FeatureSource/FilteringFeatureSource.ts +++ b/Logic/FeatureSource/FilteringFeatureSource.ts @@ -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, layerDef: LayerConfig }, location: UIEventSource) { - 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) } } \ No newline at end of file diff --git a/UI/ShowDataLayer.ts b/UI/ShowDataLayer.ts index 9991b08..0e231bc 100644 --- a/UI/ShowDataLayer.ts +++ b/UI/ShowDataLayer.ts @@ -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), diff --git a/assets/themes/speelplekken/speelplekken.json b/assets/themes/speelplekken/speelplekken.json index 7f43645..5a97217 100644 --- a/assets/themes/speelplekken/speelplekken.json +++ b/assets/themes/speelplekken/speelplekken.json @@ -41,7 +41,8 @@ "maxOverlapPercentage": 0, "name": "test", "title": "Test", - "minzoom": 0 + "minzoom": 0, + "maxzoom": 14 }