Use this with two Mapbox GL JS map instances as arguments to the syncMaps
function and it'll keep them pointed
at the same thing.
Created
August 19, 2015 20:43
-
-
Save tmcw/bd48b2c11504dc537835 to your computer and use it in GitHub Desktop.
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 copyPosition(a, b) { | |
b.jumpTo({ | |
center: a.getCenter(), | |
zoom: a.getZoom(), | |
bearing: a.getBearing(), | |
pitch: a.getPitch() | |
}); | |
} | |
function syncMaps(a, b) { | |
a.on('moveend', function() { | |
copyPosition(a, b); | |
}); | |
b.on('moveend', function() { | |
copyPosition(b, a); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment