使用谷歌地图查找给定邮政编码的所有公园
我正在尝试使用 Google 地图地理编码 API 返回所有公园给定的邮政编码。看来,如果我有公园名称,那么返回数据就没有问题。例如 http://maps.googleapis.com /maps/api/geocode/json?address=Kerry+Park+98122&sensor=false
但是,如果我搜索公园的邮政编码 http://maps.googleapis.com /maps/api/geocode/json?address=Parks+near+98122&sensor=false
我得到了带有 parks
的邮政编码的任何结果地址。我尝试使用 lanlng
但也有同样的问题。不幸的是,Google 似乎不允许在查询中使用 types[]
查询结果。
如果我在 maps.google.com 我得到了所有结果,但它似乎没有使用相同的 API。
我请求了一个 Google 地图 Places api 密钥,我认为这正是我所需要的。
我想我的问题是:
a) 我在这里遗漏了什么吗?
b) 我不喜欢 Google API,他们的其他 API 会通过 zip 输出所有公园的 JSON 结果。我简单地浏览了必应和雅虎,但没有结果。
谢谢。
I'm trying to use the Google maps geocode API to return all parks for a given zip code. It seems that if I have a park name I have no problem returning the data. Such as
http://maps.googleapis.com/maps/api/geocode/json?address=Kerry+Park+98122&sensor=false
However, if i search for parks for a zip code
http://maps.googleapis.com/maps/api/geocode/json?address=Parks+near+98122&sensor=false
I get any result for the zip code with parks
in the address. I tried using lanlng
but that has the same problem. It seems that Google doesn't allow types[]
in query just the results which is unfortunate.
If I search for "parks near 98122" on maps.google.com I get all the results but it doesn't seem to be using the same API.
I requested a Google maps Places api key which I think is what I need.
I guess my questions are:
a) am I missing something here?
b) I'm not stuck with Google API are their others that will output JSON results for all parks by zip. I looked briefly into Bing and Yahoo to no avail.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Google Places API 和文本搜索。
更改 [zipcode] 和密钥 [apikey]:
Use Google Places API and the text search.
Change the [zipcode] and the key [apikey]:
Google 地理编码器 API 没有在查询中指定“类型”(例如“公园”)的规定。它将识别响应中的功能类型,但您不能将其放入请求中。
您也许可以在 Google Places API 中执行您想要的操作,现已推出开发者预览版。我没试过。您仍然无法在请求中指定类型,但您指定位置和半径,它会返回所有地点,并且每个地点都有一个或多个关联的类型代码(可能包括公园)。您可以搜索返回的结果以查看是否出现公园。请参阅 http://code.google.com/apis/maps/documentation/places/< /a>
The Google geocoder API doesn't have a provision for specifying a "type" such as "park" in the query. It will identify the feature type in the response, but you can't put it in the the request.
You might be able to do what you want in the Google Places API, now out for developer preview. I haven't tried it. You still can't specify a type in the request, but you specify a location and radius, and it returns all places, and each place has one or more associated type codes (which might include park). You can search through the returned results to see if parks appear. See http://code.google.com/apis/maps/documentation/places/
我刚刚研究过这个,我没有使用邮政编码,但您可以使用邮政编码并获取纬度/经度对。此处已使用纬度/经度对(地图中心集)。
这是获取公园的查询。我想说这可能不是绝对的(仅限主要公园)并且有 20 个限制。
顺便说一句,这是来自他们的文档,使用 Places api,该代码也来自 ReactJS,因此参考例如。 “current”
按 ctrl+f 使“store”跳转到代码
https://developers.google.com/maps/documentation/javascript/places
I just worked on this, I am not using a zip code, but you can take a zip code and get a lat/lng pair. The lat/lng pair already used here(map center set).
This is the query to get parks. I will say it is probably not absolute(only major parks) and there is that 20 limit.
This is from their docs btw, using Places api, also this code is from ReactJS hence ref eg. "current"
do ctrl+f for 'store' to jump to the code
https://developers.google.com/maps/documentation/javascript/places