Reputation: 15777
I cannot for the life of me figure out how to get a simple google maps query to work with the API. All I want to do is get JSON for the foodbanks around Denver. So far I have:
var gm_api_key = "apikeyhere";
// return locations for foodbanks in denver
var denver_lat_long = '39.7392,-104.9903';
var loc = denver_lat_long;
var query_str_foodbank = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?query=food+bank&location=' + loc + '&radius=500&key=' + gm_api_key;
// return locations for thrift shops (e.g. goodwill) in denver
// nodejs implementation
var resp = "";
var request = require('request');
var req = request(query_str_foodbank, function (error, response, body) {
if (!error && response.statusCode == 200) {
resp = body;
//console.log(body); // Show the HTML for the Google homepage.
}
});
var food_bank_json = JSON.parse(resp);
It just returns a bunch of irrelevant stuff like 'post office', etc. It doesn't seem to be actually using the query
.
Upvotes: 1
Views: 199
Reputation: 15777
Ok, so the problems were twofold: one, the keyword
or name
arg is the correct one to use here, not query
that I would expect to use. Two, the radius
parameter is in meters, so for around 100 miles it would need to be about 150000. A correct page call should be:
Upvotes: 2