Skip to content

Instantly share code, notes, and snippets.

@LouisaKB
Created August 23, 2018 12:03
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 LouisaKB/100e0b4a37d4ca9b20cba57edfb7e0ab to your computer and use it in GitHub Desktop.
Save LouisaKB/100e0b4a37d4ca9b20cba57edfb7e0ab to your computer and use it in GitHub Desktop.
// Creates a function that responds to the selected suggestion.
function moveMarker(map, marker) {
return function (suggestion) {
// The Geocoding API returns coordinates in a [<lng>, <lat>] format. We transform it into Leaflet's LatLng.
var latLng = L.latLng(suggestion.data.reverse());
// Change the coordintates for the marker.
marker.setLatLng(latLng);
// Pan to the map view the new coordinates.
map.flyTo(latLng);
// Send a Time Map request and draw the isochrone.
sendTimeMapRequest(suggestion.data, map)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment