Last active
December 21, 2018 17:15
-
-
Save maptastik/0cff68292a836bb986e6ee0275b7c434 to your computer and use it in GitHub Desktop.
JavaScript functions for fading layers using various map APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fadeInLayerLeaflet(lyr, startOpacity, finalOpacity, opacityStep, delay) { | |
let opacity = startOpacity; | |
let timer = setTimeout(function changeOpacity() { | |
if (opacity < finalOpacity) { | |
lyr.setStyle({ | |
opacity: opacity, | |
fillOpacity: opacity | |
}); | |
opacity = opacity + opacityStep | |
} | |
timer = setTimeout(changeOpacity, delay); | |
}, delay) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fadeInLayerOL3(lyr, startOpacity, finalOpacity, opacityStep, delay) { | |
let opacity = startOpacity; | |
let timer = setTimeout(function changeOpacity() { | |
if (opacity < finalOpacity) { | |
lyr.setProperties({ | |
opacity: opacity | |
}); | |
opacity = opacity + opacityStep | |
} | |
timer = setTimeout(changeOpacity, delay); | |
}, delay) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment