Google Places API存在此问题。我正在寻找" Guildhall"在剑桥。它完全在地图上找到它:https://www.google.pl/maps/place/Guildhall,+Market+Hill,+Cambridge+CB2+3QJ,+Wielka+Brytania/@52.2046916,0.1193167,17z/data=!3m1!4b1!4m2!3m1!1s0x47d870bd9c1c0a5d:0x7228336bd9005dae
但api并没有回归" Guildhall"结果:https://maps.googleapis.com/maps/api/place/search/json?location=52.2046916,0.1193167&rankby=distance&keyword=guildhall&sensor=true&key=YOUR_API_KEY
是否可以返回像" Guildhall"来自Places API?
答案 0 :(得分:1)
您可以通过指定类型来配置要返回的地点类型:
请参阅此处的文档; https://developers.google.com/places/documentation/supported_types
然后在创建服务时传入type选项;
var request = {
location: pyrmont,
radius: '500',
types: ['store'] // specify the types here
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
<强>更新强>
我可能会为您提供解决方案:您可以尝试使用Google提供的地理编码服务:https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple
我把它放到JS小提琴中让你有一个玩法:http://jsfiddle.net/loanburger/1vhymg6m/
希望有所帮助