2

I want to search for GPS locations for with Google Maps. I have already registered with Google Maps API, and got the key. I can successfully pinpoint my current location on a map. The next part is to search for items around the current GPS location.

Approach 1: I tried using Android's geocoder.getFromLocationName("UPS",5) but I am not getting anything.

Approach 2: hit Google https://maps.googleapis.cm/maps/apo/place/search but it needs a client id. To get a client id I have to create a premier account. Do I have to do all this?

Any suggestion how to use maps to search location for Android?

rachana
  • 221
  • 1
  • 3
  • 8

2 Answers2

2

"GPS" is the place you're looking up? Not a city or street name? I think that's the problem here.

Maybe look at: How can I find the latitude and longitude from address?

Community
  • 1
  • 1
Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
  • Its not GPS its UPS (United Postal Service) sorry abt that. I want to find UPS locations near my place. – rachana Oct 29 '10 at 07:10
1

You will want to use a better "address" other than UPS to find locations using Geocoder. Do you realize how many UPS locations will be found. getFromLocationName() is best used with detailed location info and a locale directive so it limits its searching to the Locale you specify. Also, you will frequently get IOExceptions in the emulator. Lastly using SDK 2.3 and above will not work with Geocoder.

Try something like this:

Geocoder geocoder = new Geocoder(this, Locale.US);

        String staddress = "Georgia Tech, Atlanta, GA";

        try{
         List<Address> loc = geocoder.getFromLocationName(staddress, 5);
        }
        catch(IOException e) {
         Log.e("IOException", e.getMessage()); 
         Toast.makeText(this, "IOException:  " + e.getMessage(),20).show();

Notice how the locale is set to US when I new up my Geocoder. Also notice the try catch around the call to geocoder. That will catch any IO Exceptions and allow you ot handle them as I did using a Toast message and some other flow control statements that are out of sight

apesa
  • 12,163
  • 6
  • 38
  • 43