Google Places API查询' opennow = true'返回0结果(Node.js)

时间:2017-06-20 21:18:46

标签: javascript node.js web-services google-maps google-places-api

我使用以下设置查询Google Places API:

一切正常,但我的搜索请求似乎没有传递我对“目前只有当前打开的地方”的限制。通过' opennow = true'在搜索请求中。当我发送此请求时,阿姆斯特丹肯定会有餐厅开放,我在GoogleMaps上手动检查了它。我一直在尝试所有不同的拼写方式并搜索类似的解决方案,但无法找到问题。非常感谢任何帮助,谢谢。

参考代码:



app.post('/results', function(req,res){

	//PARAMETERS FOR SEARCH QUERY FOR RESTAURANTS, OPEN NOW
	const baseurl = 'https://maps.googleapis.com/maps/api/place/radarsearch/json?';
	const location = 'location=52.370216,4.895168';
	const radius = 'radius=5000';
	const type = 'type=food';
	const key = 'key='+process.env.googleapikey;

	// const opennow = 'openNow=true'; //doesn't narrow down results, doesn't seem to get applied
	// const opennow2 = 'open_now=true'; //doesn't narrow down results, doesn't seem to get applied
	const opennow3 = 'opennow=true'; //0 search results returned, doesn't seem to work

	const queryurl = `${baseurl}${location}&${radius}&${type}&${key}&${opennow3}`;

	//SEARCH QUERY TO GOOGLE PLACES API, USING REQUEST MODULE
	request({
		uri: queryurl,
		method: "GET",
		timeout: 10000,
		followRedirect: true,
		maxRedireccts: 10
		}, function(err, response, body) {

			var allresults = [];

			if(err){
				console.log(err);
			} else {
				
				var responseparsed = JSON.parse(body);
				var results = responseparsed.results;

				for (var i = 0; i < results.length; i++) {
					allresults.push(results[i]);
				} 
				console.log('Maps found >'+results.length+'< results');
			} 
			res.render("results", {allresults: allresults, mapsjsapikey: mapsjsapikey});
		}
	)
});
&#13;
&#13;
&#13;

0 个答案:

没有答案