forked from MapComplete/MapComplete
Scalebar: add option to set scalebar, don't show scalebar if not set
This commit is contained in:
parent
3088c829c5
commit
6cacd50817
2 changed files with 31 additions and 4 deletions
|
@ -470,6 +470,31 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "scalebar",
|
||||
"question": {
|
||||
"en": "Should a scale bar be shown on the map?",
|
||||
"nl": "Moet er een schaalbalk weergegeven worden?"
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "mapcomplete-preference-show-scale=true",
|
||||
"then": {
|
||||
"en": "Show the scalebar",
|
||||
"nl": "Toon de schaalbalk"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "mapcomplete-preference-show-scale=false",
|
||||
"alsoShowIf": "mapcomplete-preference-show-scale=",
|
||||
|
||||
"then": {
|
||||
"en": "Hide the scalebar",
|
||||
"nl": "Verberg de schaalbalk"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "picture-license",
|
||||
"description": "This question is not meant to be placed on an OpenStreetMap-element; however it is used in the user information panel to ask which license the user wants",
|
||||
|
|
|
@ -692,15 +692,17 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
|||
if (!map) {
|
||||
return
|
||||
}
|
||||
if (!showScale && this.scaleControl) {
|
||||
map.removeControl(this.scaleControl)
|
||||
if (!showScale) {
|
||||
if(this.scaleControl){
|
||||
map.removeControl(this.scaleControl)
|
||||
this.scaleControl = undefined
|
||||
}
|
||||
return
|
||||
}
|
||||
console.log("Adding scale")
|
||||
if (this.scaleControl === undefined) {
|
||||
|
||||
this.scaleControl = new ScaleControl({
|
||||
maxWidth: 80,
|
||||
maxWidth: 100,
|
||||
unit: "metric"
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue