谷歌地图:附近的搜索参数

时间:2017-01-22 17:25:18

标签: android google-maps google-maps-api-3

我希望使用此方法让当前城市附近的城市。我把类型局部性但它没有返回很多结果。是否有另一种方法可以从一个地方获取最近的城市并指定半径?

https://maps.googleapis.com/maps/api/place/nearbysearch/json?type=locality&key=AIzaSyCkvow9LlFNOywy8lzaekn-xROBZRsSFvU&radius=30000&location=51.509865,%20-0.118092

1 个答案:

答案 0 :(得分:0)

试试这段代码:

StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
sb.append("location=" + your_latitude + "," + your_longitude);
sb.append("&radius=3500");   //specify radius
sb.append("&types=" + "atm");   //specify type of place
sb.append("&sensor=true");
sb.append("&key=YOUR_API_KEY");
// Creating a new non-ui thread task to download Google place json data
PlacesTask placesTask = new PlacesTask();

// Invokes the "doInBackground()" method of the class PlaceTask
placesTask.execute(sb.toString());

代表网址:

  

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=23.873751,90.396454&radius=500&types=atm&key=YOUR_API_KEY

对于不同类型的地方,请参阅:

https://developers.google.com/places/supported_types