This file contains hidden or 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
const Handlebars = require('handlebars') | |
Handlebars.registerHelper('prod', () => { | |
return process.env.NODE_ENV === 'production'; | |
}) |
This file contains hidden or 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
export const getNearestDivvyStation = (lat, lng) => { | |
const url = `${GOOGLE_PLACES_URL}?location=${lat},${lng}&radius=1000&type=point_of_interest&keyword=divvy&key=${API_KEY}` | |
return async (dispatch) => { | |
const { data } = await axios.get(url) | |
const current = {lat, lng} | |
const closest = data.results.map((station) => { | |
const coord = station.geometry.location |
This file contains hidden or 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
const closest = distance.sort( (a, b) => a.dist - b.dist )[0] |
This file contains hidden or 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
const distances = [ | |
{ | |
"coord": { | |
"lat": 41.8921794, | |
"lng": -87.6366551, | |
}, | |
"dist": 396, | |
}, | |
{ | |
"coord": { |
This file contains hidden or 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
// User's current location | |
const current = {lat, lng} | |
const closest = data.results.map((station) => { | |
const coord = station.geometry.location | |
return { coord, dist: geolib.getDistance(current, coord) } | |
}) |
This file contains hidden or 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
const coords = [ | |
{ | |
"lat": 41.8921794, | |
"lng": -87.6366551, | |
}, | |
{ | |
"lat": 41.894652, | |
"lng": -87.638362, | |
}, | |
{ |
This file contains hidden or 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
import geolib from 'geolib' | |
// ..... | |
const dist = coords.map((coord) => { | |
return { coord, dist: geolib.getDistance(current, coord) } | |
}) |