Last active
December 17, 2018 06:34
-
-
Save drecodeam/03856a73ab327a64059163c6cf24056a 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
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