谷歌地图的API只能返回城市? [英] Google Maps places API to only return cities?

查看:373
本文介绍了谷歌地图的API只能返回城市?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Google的地图API从其json请求中返回城市:

  https://地图。 googleapis.com/maps/api/place/autocomplete/json?input=green%20lanes&types=geocode&sensor=false&types=regions&key=*API此处按键* 

关键是& types = regions ,但它仍会返回所有结果。



例如,我正在寻找街道 Green Lanes ,而不是返回可能包含 Green的城市。

https:// maps.googleapis.com/maps/api/place/autocomplete/json?input=green%20lanes&types=geocode&sensor=false&types=regions&key= API KEY HERE


应该是

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=green %20lanes& sensor = false& types =(regions)& key = API KEY HERE



ZERO RESULTS, (区域)类型集合指示Place服务返回与以下类型匹配的任何结果:
locality
sublocality
postal_code
country
administrative_area1
administrative_area2


I am trying to use Google's map API to only return cities from their json request:

 https://maps.googleapis.com/maps/api/place/autocomplete/json?input=green%20lanes&types=geocode&sensor=false&types=regions&key=*API KEY HERE*

The key being &types=regions but it still returns all results.

For example, I am searching for the street Green Lanes and rather than returning cities that might contain Green Lanes its returning the street in London as the top result.

解决方案

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=green%20lanes&types=geocode&sensor=false&types=regions&key=API KEY HERE

should be

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=green%20lanes&sensor=false&types=(regions)&key=API KEY HERE

ZERO RESULTS, because regions does not search for street name:

the (regions) type collection instructs the Place service to return any result matching the following types: locality sublocality postal_code country administrative_area1 administrative_area2

这篇关于谷歌地图的API只能返回城市?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆