Jeremy
Jeremy

Reputation: 2546

Android Google Maps + Place search result

I have the following code to send a query to google about a particular location.

What i don't understand is, if i enter the following location on google maps (via browser)

"Grand Indonesia, Jakarta"

It returns the correct result.

However, using similar keywords on the code returns different result.

private String getPlacesUrl(String qry){

    try {
        qry = "input=" + URLEncoder.encode(qry, "utf-8");
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }

    // Sensor enabled
    String sensor = "sensor=false";

    // place type to be searched
    String types = "types=geocode";

    // Country
    String country = "components=country:id";

    // Building the parameters to the web service
    String parameters = qry+"&"+types+"&"+sensor+"&"+mKey+"&"+country;

    // Output format
    String output = "json";
    // Building the url to the web service
    String url = "https://maps.googleapis.com/maps/api/place/autocomplete/"+output+"?"+parameters;
    return url;
}

Does anyone knows why ? is there a better way to improve the accuracy?

Cheers...

Upvotes: 0

Views: 1090

Answers (1)

Brett
Brett

Reputation: 2399

You are specifying types=geocode while the results for Grand Indonesia, Jakarta appear to be reflecting a business listing, not an address. If you remove the types=geocode you will receive the same result as the google maps results you received.

Upvotes: 2

Related Questions