1/** 2 * @file Helper function to get directions from the Mapbox API for the route line between a selected center and a selected place 3 */ 4 5/** 6 * Get directions from the Mapbox API for the route line between a selected center and a selected place 7 * @param {Array} location The location of the selected center 8 * @param {Array} selectedPlace The location of the selected place 9 */ 10export async function getDirections(location, selectedPlace) { 11 const profile = 'mapbox/driving-traffic'; 12 const coordinates = `${selectedPlace[0]},${selectedPlace[1]};${location[0]},${location[1]}`; 13 14 const url = `https://api.mapbox.com/directions/v5/${profile}/${coordinates}?geometries=geojson&access_token=${window.mapboxgl.accessToken}`; 15 16 return await fetch(url).then((r) => r.json()); 17} 18 19/** 20 * Gets travel times from the Mapbox API between a selected center and a selected place 21 * @param {Array} location The location of the selected center 22 * @param {Array} selectedPlace The location of the selected place 23 * @returns 24 */ 25export async function getTravelTimes(location, selectedPlace) { 26 const profile = 'mapbox/driving-traffic'; 27 const coordinates = `${selectedPlace[0]},${selectedPlace[1]};${location[0]},${location[1]}`; 28 29 const url = `https://api.mapbox.com/directions-matrix/v1/${profile}/${coordinates}?annotations=distance,duration&access_token=${window.mapboxgl.accessToken}`; 30 31 return await fetch(url).then((r) => r.json()); 32}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.