Created
April 14, 2018 12:48
-
-
Save Scarysize/df6890d590323cb605cee6041045d36c to your computer and use it in GitHub Desktop.
Basic mapbox-gl animation loop necessary for smoothly animating GeoJSON sources.
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
const source = this.map.getSource('my-source'); | |
function loop() { | |
source.on('data', requestFrame); | |
source.setData(updatedGeoJson); | |
} | |
function requestFrame(event) { | |
if (event.dataType !== 'source') { | |
return; | |
} | |
source.off('data', this.requestFrame); | |
requestAnimationFrame(loop); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment