Allow a layer to be hidden by default; add some validation and behaviour tweaks
This commit is contained in:
parent
5f3c8dd1b4
commit
ea5bc7cbf4
7 changed files with 17 additions and 2 deletions
|
@ -301,7 +301,7 @@ export default class MapState extends UserRelatedState {
|
||||||
} else {
|
} else {
|
||||||
isDisplayed = QueryParameters.GetBooleanQueryParameter(
|
isDisplayed = QueryParameters.GetBooleanQueryParameter(
|
||||||
"layer-" + layer.id,
|
"layer-" + layer.id,
|
||||||
"true",
|
""+layer.shownByDefault,
|
||||||
"Wether or not layer " + layer.id + " is shown"
|
"Wether or not layer " + layer.id + " is shown"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,6 +255,9 @@ export class TagUtils {
|
||||||
}
|
}
|
||||||
if (tag.indexOf("~") >= 0) {
|
if (tag.indexOf("~") >= 0) {
|
||||||
const split = Utils.SplitFirst(tag, "~");
|
const split = Utils.SplitFirst(tag, "~");
|
||||||
|
if(split[1] === "") {
|
||||||
|
throw "Detected a regextag with an empty regex; this is not allowed. Use '"+split[0]+"='instead (at "+context+")"
|
||||||
|
}
|
||||||
if (split[1] === "*") {
|
if (split[1] === "*") {
|
||||||
split[1] = "..*"
|
split[1] = "..*"
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,13 @@ export interface LayerConfigJson {
|
||||||
*/
|
*/
|
||||||
minzoom?: number;
|
minzoom?: number;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this layer is shown by default;
|
||||||
|
* can be used to hide a layer from start, or to load the layer but only to show it where appropriate (e.g. for snapping to it)
|
||||||
|
*/
|
||||||
|
shownByDefault?: true | boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The zoom level at which point the data is hidden again
|
* The zoom level at which point the data is hidden again
|
||||||
* Default: 100 (thus: always visible
|
* Default: 100 (thus: always visible
|
||||||
|
|
|
@ -47,6 +47,7 @@ export default class LayerConfig extends WithContextLoader {
|
||||||
public readonly deletion: DeleteConfig | null;
|
public readonly deletion: DeleteConfig | null;
|
||||||
public readonly allowMove: MoveConfig | null
|
public readonly allowMove: MoveConfig | null
|
||||||
public readonly allowSplit: boolean
|
public readonly allowSplit: boolean
|
||||||
|
public readonly shownByDefault: boolean;
|
||||||
/**
|
/**
|
||||||
* In seconds
|
* In seconds
|
||||||
*/
|
*/
|
||||||
|
@ -147,6 +148,7 @@ export default class LayerConfig extends WithContextLoader {
|
||||||
this.passAllFeatures = json.passAllFeatures ?? false;
|
this.passAllFeatures = json.passAllFeatures ?? false;
|
||||||
this.minzoom = json.minzoom ?? 0;
|
this.minzoom = json.minzoom ?? 0;
|
||||||
this.minzoomVisible = json.minzoomVisible ?? this.minzoom;
|
this.minzoomVisible = json.minzoomVisible ?? this.minzoom;
|
||||||
|
this.shownByDefault = json.shownByDefault ?? true;
|
||||||
if (json.presets !== undefined && json.presets?.map === undefined) {
|
if (json.presets !== undefined && json.presets?.map === undefined) {
|
||||||
throw "Presets should be a list of items (at " + context + ")"
|
throw "Presets should be a list of items (at " + context + ")"
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,8 @@ export default class LayoutConfig {
|
||||||
result.push(AllKnownLayers.sharedLayers.get(defaultLayer))
|
result.push(AllKnownLayers.sharedLayers.get(defaultLayer))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {layers: result, extractAllNodes: exportAllNodes}
|
return {layers: result, extractAllNodes: exportAllNodes}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ export default class LegacyJsonConvert {
|
||||||
delete config["iconSize"]
|
delete config["iconSize"]
|
||||||
delete config["rotation"]
|
delete config["rotation"]
|
||||||
delete config["wayHandling"]
|
delete config["wayHandling"]
|
||||||
|
delete config["hideUnderlayingFeaturesMinPercentage"]
|
||||||
|
|
||||||
for (const mapRenderingElement of config.mapRendering) {
|
for (const mapRenderingElement of config.mapRendering) {
|
||||||
if (mapRenderingElement["iconOverlays"] !== undefined) {
|
if (mapRenderingElement["iconOverlays"] !== undefined) {
|
||||||
|
|
|
@ -227,7 +227,7 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
||||||
|
|
||||||
leaflet.setMaxZoom(layer.max_zoom)
|
leaflet.setMaxZoom(layer.max_zoom)
|
||||||
leaflet.setMinZoom(self._minZoom ?? layer.max_zoom - 2)
|
leaflet.setMinZoom(self._minZoom ?? layer.max_zoom - 2)
|
||||||
leaflet.setZoom(layer.max_zoom - 1)
|
leaflet.setZoom(layer.max_zoom)
|
||||||
|
|
||||||
}, [this.map.leafletMap])
|
}, [this.map.leafletMap])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue