Skip to content

Instantly share code, notes, and snippets.

@drecodeam
Last active December 17, 2018 06:34
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/03856a73ab327a64059163c6cf24056a to your computer and use it in GitHub Desktop.
Save drecodeam/03856a73ab327a64059163c6cf24056a to your computer and use it in GitHub Desktop.
origin = [37.784872, -122.389752]
destination = [37.817910, -122.279143]
mapbox_drive_route_endpoint = 'https://api.mapbox.com/directions/v5/mapbox/driving/'
# Draw route between 2 places
getRoute = ( source, destination ) ->
directionRequestUrl = bypass_cors + mapbox_drive_route_endpoint + source[1]+","+source[0]+";"+destination[1]+","+destination[0]+"?geometries=geojson&access_token="+access_token
fetch( directionRequestUrl ).then( (result) ->
result.json()
).then( ( data ) ->
drawRoute( data )
)
getRoute( origin, destination )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment