谷歌地图API根据纬度和地点返回地点类型经度 [英] Google maps APIs to return place' type based on latitude & longitude
问题描述
我正在尝试构建一个应用程序,我需要根据经度和纬度检索位置的类型。我尝试使用谷歌的地方API,但没有得到满意的结果。
例如,如果我想知道用户是否搜索SFSU,它应该存储为'university' 。我可以通过地理编码API获取它的经纬度。
https://maps.googleapis.com/maps/api/geocode/json?address=SFSU&key=YOUR_KEY
但是从API的API中,我无法得到确切的类型,我主要是将它看作是街道或企业:
https://maps.googleapis.com/maps/api/geocode/ json?latlng = 37.7244047,-122.4760196& key = YOUR_KEY
同样,我想为任何星巴克或商场/购物中心获得咖啡厅购物中心。
编辑:
我在地理编码API并将API作为地理编码API返回地方'类型。
我发现即使我们提供正确的经度和纬度,API也会返回多个结果。因此,如果我们需要完美的结果,我们需要使用Places API提供排序过滤器。
看起来您正在使用反向地理编码,而不是Places API。
请求Places API应该是这样的:
这一个返回'旧金山州立大学1600 Holloway Avenu e,旧金山'
https://developers.google.com/places/web-service/search#PlaceSearchRequests
希望它有帮助!
I am trying to build an application in which I need to retrieve location's type based on latitude and longitude. I tried using google's places API but not getting satisfied results.
For eg, if I want to know if the user searches for SFSU, it should be stored as 'university'. I can get its latitude/longitude from geocoding APIs.
https://maps.googleapis.com/maps/api/geocode/json?address=SFSU&key=YOUR_KEY
But from places API, I cannot get the exact type, I mostly get it as street or establishment:
https://maps.googleapis.com/maps/api/geocode/json?latlng=37.7244047,-122.4760196&key=YOUR_KEY
Similarly, I wanted to get cafe for any starbucks or mall/shopping-center for any mall.
Edit:
I got confused between geocode API and places API as geocode API also returns place' type. I found that places API returns multiple results even if we provide correct latitude and longitude. So if we need the perfect result, we need to provide sort filter with Places API.
It looks like you are using reverse geocoding, not the Places API.
Request to Places API should be something like:
This one returns 'San Francisco State University, 1600 Holloway Avenue, San Francisco'
https://developers.google.com/places/web-service/search#PlaceSearchRequests
Hope it helps!
这篇关于谷歌地图API根据纬度和地点返回地点类型经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!