2

I'm planning to build an android application that draws a circle around a certain point on the map and finds all the points of interests (e.g., hotels) inside that circle.

I created the circle in my app by using the Google Maps Android API via

 GoogleMap map;
 Circle circle = map.addCircle(new CircleOptions()
 .center(new LatLng(MY_LAT, MY_LONG))
 .radius(MY_RADIUS)
 .strokeColor(Color.RED)
 .fillColor(Color.BLUE));

I also know that I can find places of interest using the Google Places API.

As far as I know, the PlacePicker is used for searching places of interests.

Upon further research, I realized I could actually set LatLng bounds for the PlacePicker using LatLngBounds and the setLatLngBounds() method. The method accepts a North-East corner and a South-West corner, but how do I determine them?

My question is this - How can I get the PlacePicker to scan all the places of interests inside the given circle?

One possible workaround I thought of was this:

1) Use this method to obtain a set of NE and SW points

2) Add these as the parameters to the setLatLngBounds() methods

3) Use the PlacePicker

Is this the appropriate way? Or is there any shorter workaround?

Community
  • 1
  • 1
Rahul Kulhalli
  • 555
  • 1
  • 5
  • 12
  • Welcome back ! For PlacePicker see my question [here](http://stackoverflow.com/questions/34416817/how-to-implement-placeautocompletefragment-and-placeautocompleteactivity-to-get) and for finds all the points of interests inside that circle see [this](http://stackoverflow.com/questions/16082622/check-if-marker-is-inside-circle-radius) – pRaNaY Feb 09 '16 at 06:47

1 Answers1

0

You may have to use

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");

Just use type as hotels,etcs and radius may be depends on your need.

Mahesh Giri
  • 1,810
  • 19
  • 27