Android getFromLocationName returns results out of bounds

I am doing a location search from my android app. The user enters the address, and I look at the following code,

 private void doSearch(String query){
    FNMApplication.logInfo("Searching:"+query);
    //create a geocoder
    Geocoder gc = new Geocoder(this,Locale.getDefault());
    try{
        //lookup locations which match the query input by the user
        List<Address> addresses = gc.getFromLocationName(query, 5, -44.00, 111.00, -12.0, 155.0);
        //if there are any results save them in an ivar for re-use
        locationSearchResults=addresses;
        promptSearch();          
    }
    catch (Exception e){
        ;
    }
}

The bounding box above is for Australia, but if I search for “Los Angeles,” it returns results in the USA. Is there something I missed? As I see it, it should return only addresses in the bounding box in accordance with the reference document

+5
source share
1 answer

From the question I tried and the results I got are shown below.

18.55, 72.54 = Mumbai
22.18, 70.56 = Rajkot

1)

When I skip the lower latitude vaue as the lower left and searched for the string, I got this

Geocoder gc = new Geocoder(this, Locale.getDefault());
        try {

            List<Address> addresses = gc.getFromLocationName("akshardham", 5,
                    18.55, 72.54, 22.18, 70.56);

            Log.i("Address", "=========0----------------------"
                    + addresses.get(0).getAddressLine(0)
                    + addresses.get(0).getAddressLine(1));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(1).getAddressLine(0)
                    + addresses.get(1).getAddressLine(1));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(2).getAddressLine(0));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(3).getAddressLine(0));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(4).getAddressLine(0));
        } catch (Exception e) {
            ;
        }

The log code of this

11-17 12:42:32.419: INFO/Address(802): =========0----------------------AkshardhamNH 8C, Sector 20
11-17 12:42:32.429: INFO/Address(802): =========0----------------------AkshardhamRajkot, Gujarat 360005
11-17 12:42:32.429: INFO/Address(802): =========0----------------------Akshardham

2)

vaue, , ,

List<Address> addresses = gc.getFromLocationName("akshardham",5, 22.18, 70.56,18.55, 72.54 );

-

11-17 12:43:53.170: INFO/Address(837): =========0----------------------HardhamPulborough, West Sussex RH20 1

3)

: ", , "., , , , , , , , . : Bounding Box , wil , , get (0), (1) . , .

4)

Geocoder.java simple..no ,

= > , , , , , , , . , getFromLocation (, , maxResults), ,

= > ( ) Google.

+5

All Articles