Created
May 10, 2016 02:58
-
-
Save leandroh/2c31e60dd6f31ce667164f3652d1c476 to your computer and use it in GitHub Desktop.
Nearby Search Requests
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
'use strict'; | |
var request = require('request'); | |
var lat = -26.228889; | |
var lon = -52.670833; | |
var keyword = 'Pizzaria'; | |
var output = 'json'; | |
var radius = 2000; | |
var key = 'AIzaSyDVuLEXpSrOyB71IAS152xs7ACp-_HFCdw'; | |
var type = 'restaurant'; | |
var parameters = 'keyword=' + keyword + '&radius=' + radius + '&location=' + lat + ',' + lon + '&key=' + key + '&type=' + type; | |
var url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/' + output + '?' + parameters; | |
request(url, function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
var json = JSON.parse(body); | |
var results = json.results; | |
for (var i = 0; i < results.length; i++) { | |
console.log(results[i].place_id + ' - ' + results[i].name); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment