寻找一个圈内的兴趣点

Finding places of interest within a circle

我打算构建一个 android 应用程序,它可以在地图上的某个点周围画一个圆圈,并找到该圆圈内的所有兴趣点(例如酒店)。

我使用 Google 地图 Android API 通过

在我的应用程序中创建了圆圈
 GoogleMap map;
 Circle circle = map.addCircle(new CircleOptions()
 .center(new LatLng(MY_LAT, MY_LONG))
 .radius(MY_RADIUS)
 .strokeColor(Color.RED)
 .fillColor(Color.BLUE));

我也知道我可以使用 Google Places API 找到名胜古迹。

据我所知,PlacePicker是用来搜索名胜的。

经过进一步研究,我意识到我实际上可以使用 LatLngBoundssetLatLngBounds() 方法为 PlacePicker 设置 LatLng 边界。该方法接受东北角和西南角,但我如何确定它们?

我的问题是 - 如何让 PlacePicker 扫描给定圈内的所有兴趣点?

我想到的一个可能的解决方法是:

1) 使用this method得到一组NE和SW点

2) 将这些作为参数添加到 setLatLngBounds() 方法

3) 使用 PlacePicker

这是合适的方式吗?或者有更短的解决方法吗?

您可能需要使用

StringBuilder googlePlacesUrl = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
                googlePlacesUrl.append("location=" + latLng.latitude + "," + latLng.longitude);
                googlePlacesUrl.append("&radius=" + 3);
                googlePlacesUrl.append("&types=" + type);
                googlePlacesUrl.append("&sensor=true");
                googlePlacesUrl.append("&key=" + "server key from google console");

只需使用酒店等类型,半径可能取决于您的需要。