简体   繁体   English

Android Google地图+放置搜索结果

[英]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... 干杯...

You are specifying types=geocode while the results for Grand Indonesia, Jakarta appear to be reflecting a business listing, not an address. 您指定types=geocodeGrand Indonesia,Jakarta的结果似乎反映了商家信息,而不是地址。 If you remove the types=geocode you will receive the same result as the google maps results you received. 如果您删除types=geocode您将收到与您收到的Google地图结果相同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM