Skip to content

Instantly share code, notes, and snippets.

@jkeefe
Last active January 19, 2022 21:50
Show Gist options
  • Save jkeefe/aeecbfb22ac4282381f7e06992c8ee50 to your computer and use it in GitHub Desktop.
Save jkeefe/aeecbfb22ac4282381f7e06992c8ee50 to your computer and use it in GitHub Desktop.
When a marker is not the center of the map, first zoom in without panning zooms to marker (Mapbox)
let dragged_once = false;
map.on('dragstart', () => {
dragged_once = true;
});
map.on('zoomend', () => {
if (!dragged_once) {
map.easeTo({
center: label_list[0].lngLat,
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment