Skip to content

Instantly share code, notes, and snippets.

@David-Hackro
Last active February 6, 2017 04:34
Show Gist options
  • Save David-Hackro/6a8b86da081ebf51cf8d71efb12011c3 to your computer and use it in GitHub Desktop.
Save David-Hackro/6a8b86da081ebf51cf8d71efb12011c3 to your computer and use it in GitHub Desktop.
const Client = require('node-rest-client').Client
var client = new Client()
//const key = 'AIzaSyArQQ_RJgWEKUlM2Y8Jw_lc_BMjzt3yR7I'
const key = 'AIzaSyBWtpveyWKoj26zuaMs-vHT8u0o2i0rKqY'
const radius = 3000
getListPlacesToken = (lat,long,token)=>{
url = ''
if(token == '')
url = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat},${long}&radius=${radius}&types=convenience_store&%20food&%20store&%20point_of_interest&%20establishment&key=${key}`
else
url = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat},${long}&radius=${radius}&types=convenience_store&%20food&%20store&%20point_of_interest&%20establishment&key=${key}&pagetoken=${token}`
return new Promise(function(resolve,reject){
setTimeout(function() {
client.get(url, function(data, response) {
if (data.error)
return reject(data.error)
return resolve(data)
}).on('error',reject)
}, 2000)
})
}
module.exports = {
getListPlacesToken
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment