Skip to content

Commit

Permalink
fix overlay. when selecting another overlay it should be visible even…
Browse files Browse the repository at this point in the history
… though opacity was zero
  • Loading branch information
Eskild Skov Pedersen committed Oct 1, 2020
1 parent 76bf76b commit 54f5957
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ if (activeBaseLayerName) {
const activeOverlayName = localStorage.getItem('activeOverlayName')
? localStorage.getItem('activeOverlayName')
: 'Helning'
localStorage.removeItem('activeOverlayName')
map.addLayer(overlayMaps[activeOverlayName])
activeOverlay = overlayMaps[activeOverlayName]

Expand Down Expand Up @@ -215,7 +214,7 @@ map.on('pm:drawstart', ({ workingLayer }) => {
//

opacitySlider.slider.addEventListener('click', function () {
localStorage.setItem('currentOpacity', opacitySlider.slider.value)
localStorage.setItem('currentOpacity', opacitySlider.slider.valueAsNumber)
})

function savePosition (e) {
Expand All @@ -236,12 +235,13 @@ function saveActiveOverlay (e) {

map.on('baselayerchange', saveActiveBaseLayer)
map.on('overlayadd', saveActiveOverlay)
map.on('overlayadd', changeOverlayControl)
map.on('moveend', savePosition)
map.on('zoomend', saveZoom)

function changeOverlayControl (e) {
activeOverlay = e.layer
if (opacitySlider.slider.value === 0) {
if (opacitySlider.slider.valueAsNumber === 0) {
const val = 0.2
activeOverlay.setOpacity(val)
opacitySlider.slider.value = val
Expand All @@ -250,8 +250,6 @@ function changeOverlayControl (e) {
}
}

map.on('overlayadd', changeOverlayControl)

// FILE LOADER

fileLayer.loader.on('data:error', function (error) {
Expand Down

0 comments on commit 54f5957

Please sign in to comment.