1

I program this but in my location, I just want to show schools only under San Juan and Manila.

This is my code:

@Override
public void onClick(View v) {

    int selectedPosition = mSprPlaceType.getSelectedItemPosition();
    String type = mPlaceType[selectedPosition];

    StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
    sb.append("location="+mLatitude+","+mLongitude);
    sb.append("&radius=3000");
    sb.append("&types=(locality)manila+sanjuan|university");
    sb.append("&sensor=true");
    sb.append("&key=AIzaSyDrFvBwI32y74-TdxcmFyQyAZvV1t5vAKU");
alexwlchan
  • 5,699
  • 7
  • 38
  • 49

1 Answers1

0

To do this, you will need to implement a post filter on the results of the search. This should be fine if your search radius roughly covers only these two regions.

To post filter, use the address_components returned from PlaceDetails requests (https://developers.google.com/places/webservice/details) to filter using the "locality" address component.

plexer
  • 4,542
  • 2
  • 23
  • 27
  • Sir I dont get it can you give example?? Sorry Im new to Google places api. @plexer – Lelouch Rodriguez May 01 '15 at 10:37
  • You will need to write a for loop, that loops over each result you get back from the API. For each result, check the address_components.locality property and ignore that place if it is not in San Juan or Manila. – plexer May 02 '15 at 22:32