asksuite-core
Version:
35 lines (29 loc) • 1.01 kB
JavaScript
module.exports = function (config) {
const googleMapsClient = require('@google/maps').createClient({
key: config.GOOGLE_PLACES_KEY,
});
const google = {};
google.places = function (location, type, _radius) {
const promise = new Promise(function (resolve, reject) {
const parameters = {
location: [location.lat, location.lng],
type,
language: 'pt-BR',
};
googleMapsClient.places(parameters, function (error, response) {
if (error) {
reject(error);
}
resolve(response.json.results);
});
});
return promise;
};
google.buildPhotoUrl = function (reference) {
console.log(
`https://maps.googleapis.com/maps/api/place/photo?maxwidth=198&maxheight=111&photoreference=${reference}&key=${config.GOOGLE_PLACES_KEY}`,
);
return `https://maps.googleapis.com/maps/api/place/photo?maxwidth=198&maxheight=111&photoreference=${reference}&key=${config.GOOGLE_PLACES_KEY}`;
};
return google;
};