Scalebar: add option to set scalebar, don't show scalebar if not set

This commit is contained in:
Pieter Vander Vennet 2024-09-13 00:58:07 +02:00
parent 3088c829c5
commit 6cacd50817
2 changed files with 31 additions and 4 deletions

View file

@ -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"
})
}