Skip to content

Instantly share code, notes, and snippets.

@drecodeam
Last active December 18, 2018 03:43
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/e92cd619af3dc3f103617ef46607fe72 to your computer and use it in GitHub Desktop.
Save drecodeam/e92cd619af3dc3f103617ef46607fe72 to your computer and use it in GitHub Desktop.
mapbox_api_endpoint = 'https://api.mapbox.com/geocoding/v5/'
# Using this service to bypass CORS related issue
bypass_cors = 'https://cors-anywhere.herokuapp.com/'
# Update the place name
getPlaceName = ( coordinates ) ->
geocodeRequestUrl = bypass_cors + mapbox_api_endpoint + "mapbox.places/" + coordinates[1] + "," + coordinates[0] + ".json?&access_token=" + access_token
fetch(geocodeRequestUrl).then( (result) ->
result.json()
).then( ( data ) ->
return data.features[0]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment