1.0.4 • Published 2 years ago
lambda-data-helper v1.0.4
Lambda route places module
This library is based on @googlemaps/google-maps-services-js
Node: 16.13
How to use
import { GMapsRouteWithPlaces, PlaceTypes } from 'lambda-data-helper'
(async () => {
const route = {
origin: 'kyiv',
destination: 'lviv',
};
const routeOptions = {
maxDistanceBetweenWaypoints: 20000, // meters
radius: 20000, // meters
};
const routeWithPlaces = new GMapsRouteWithPlaces(route, routeOptions);
const data = await routeWithPlaces.getByDistance(100000, PlaceTypes.gas_station, 10);
console.log(JSON.stringify(data));
})();
and will return
[
{
"formatted_address": "Soborna Street, Village, Lenina Str, 87, Sofiivska Borshchahivka, Kyivs'ka oblast, Ukraine, 08140",
"geometry": {
"location": {
"lat": 50.4022392,
"lng": 30.3326178
},
"viewport": {
"northeast": {
"lat": 50.40362038029149,
"lng": 30.3339322302915
},
"southwest": {
"lat": 50.4009224197085,
"lng": 30.3312342697085
}
}
},
"international_phone_number": "+380 67 507 0993",
"name": "АЗС Shell 4051",
"opening_hours": {
"open_now": true,
"periods": [
{
"open": {
"day": 0,
"time": "0000"
}
}
],
"weekday_text": [
"Monday: Open 24 hours",
"Tuesday: Open 24 hours",
"Wednesday: Open 24 hours",
"Thursday: Open 24 hours",
"Friday: Open 24 hours",
"Saturday: Open 24 hours",
"Sunday: Open 24 hours"
]
},
"place_id": "ChIJCbpXcVTK1EARiBA4tm2cpOc",
"url": "https://maps.google.com/?cid=16691638113964396680",
"vicinity": "Village, Soborna Street, Lenina Str, 87, Sofiivska Borshchahivka",
"website": "https://find.shell.com/ua/fuel/10090787-petrovskoe",
"distance": {
"text": "17.8 km",
"value": 17819
}
},
{
"formatted_address": "Akademika Zabolotnoho St, 174а, Kyiv, Ukraine, 03143",
"geometry": {
"location": {
"lat": 50.34614759999999,
"lng": 30.4995352
},
"viewport": {
"northeast": {
"lat": 50.34765378029149,
"lng": 30.5009193802915
},
"southwest": {
"lat": 50.3449558197085,
"lng": 30.4982214197085
}
}
},
"international_phone_number": "+380 800 300 525",
"name": "Wog",
"opening_hours": {
"open_now": true,
"periods": [
{
"open": {
"day": 0,
"time": "0000"
}
}
],
"weekday_text": [
"Monday: Open 24 hours",
"Tuesday: Open 24 hours",
"Wednesday: Open 24 hours",
"Thursday: Open 24 hours",
"Friday: Open 24 hours",
"Saturday: Open 24 hours",
"Sunday: Open 24 hours"
]
},
"place_id": "ChIJeyDy4NnH1EARD-IX5IXQGoM",
"url": "https://maps.google.com/?cid=9447092441839034895",
"vicinity": "Akademika Zabolotnoho Street, 174а, Kyiv",
"website": "http://www.wog.ua/",
"distance": {
"text": "24.5 km",
"value": 24504
}
}
]
Developing
In order to run, you'll need to supply your API key via an environment variable.
$ export GOOGLE_MAPS_API_KEY=AIza-your-api-key