Add maxzoom capability to layers
This commit is contained in:
parent
f0765df5ed
commit
878cb6d47d
5 changed files with 18 additions and 7 deletions
|
@ -30,6 +30,7 @@ export default class LayerConfig {
|
||||||
doNotDownload: boolean;
|
doNotDownload: boolean;
|
||||||
passAllFeatures: boolean;
|
passAllFeatures: boolean;
|
||||||
minzoom: number;
|
minzoom: number;
|
||||||
|
maxzoom: number;
|
||||||
title?: TagRenderingConfig;
|
title?: TagRenderingConfig;
|
||||||
titleIcons: TagRenderingConfig[];
|
titleIcons: TagRenderingConfig[];
|
||||||
icon: TagRenderingConfig;
|
icon: TagRenderingConfig;
|
||||||
|
@ -90,7 +91,8 @@ export default class LayerConfig {
|
||||||
|
|
||||||
this.doNotDownload = json.doNotDownload ?? false;
|
this.doNotDownload = json.doNotDownload ?? false;
|
||||||
this.passAllFeatures = json.passAllFeatures ?? 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.wayHandling = json.wayHandling ?? 0;
|
||||||
this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 0;
|
this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 0;
|
||||||
this.presets = (json.presets ?? []).map((pr, i) =>
|
this.presets = (json.presets ?? []).map((pr, i) =>
|
||||||
|
@ -125,7 +127,6 @@ export default class LayerConfig {
|
||||||
/**
|
/**
|
||||||
* Converts a list of tagRenderingCOnfigJSON in to TagRenderingConfig
|
* Converts a list of tagRenderingCOnfigJSON in to TagRenderingConfig
|
||||||
* A string is interpreted as a name to call
|
* A string is interpreted as a name to call
|
||||||
* @param tagRenderings
|
|
||||||
*/
|
*/
|
||||||
function trs(tagRenderings?: (string | TagRenderingConfigJson)[], readOnly = false) {
|
function trs(tagRenderings?: (string | TagRenderingConfigJson)[], readOnly = false) {
|
||||||
if (tagRenderings === undefined) {
|
if (tagRenderings === undefined) {
|
||||||
|
|
|
@ -49,10 +49,15 @@ export interface LayerConfigJson {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The zoomlevel at which point the data is shown and loaded.
|
* 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.
|
* The title shown in a popup for elements of this layer.
|
||||||
|
|
|
@ -71,6 +71,9 @@ export default class FilteringFeatureSource implements FeatureSource {
|
||||||
if (l.zoom < layer.layerDef.minzoom) {
|
if (l.zoom < layer.layerDef.minzoom) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(l.zoom > layer.layerDef.maxzoom){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!layer.isDisplayed.data) {
|
if (!layer.isDisplayed.data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +105,6 @@ export default class FilteringFeatureSource implements FeatureSource {
|
||||||
isDisplayed: UIEventSource<boolean>,
|
isDisplayed: UIEventSource<boolean>,
|
||||||
layerDef: LayerConfig
|
layerDef: LayerConfig
|
||||||
}, location: UIEventSource<Loc>) {
|
}, 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -179,6 +179,7 @@ export default class ShowDataLayer {
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
features: []
|
features: []
|
||||||
}
|
}
|
||||||
|
// @ts-ignore
|
||||||
return L.geoJSON(data, {
|
return L.geoJSON(data, {
|
||||||
style: feature => self.createStyleFor(feature),
|
style: feature => self.createStyleFor(feature),
|
||||||
pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng),
|
pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng),
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
"maxOverlapPercentage": 0,
|
"maxOverlapPercentage": 0,
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"minzoom": 0
|
"minzoom": 0,
|
||||||
|
"maxzoom": 14
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue