Skip to content

Instantly share code, notes, and snippets.

@drecodeam
Created December 17, 2018 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drecodeam/5a8b734dbd0b6a9269f203a176b4e11a to your computer and use it in GitHub Desktop.
Save drecodeam/5a8b734dbd0b6a9269f203a176b4e11a to your computer and use it in GitHub Desktop.
# Get map bounds between 2 points
getMapBounds = ( origin, destination ) ->
sw = new mapboxgl.LngLat(origin[1], origin[0]);
ne = new mapboxgl.LngLat(destination[1], destination[0] );
llb = new mapboxgl.LngLatBounds(sw, ne);
return llb
getRoute( origin, destination ).then(
mapInstance.fitBounds( getMapBounds( origin, destination ), {
padding: 100
linear: true
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment