Google Places API会使用指定的关键字返回零结果

时间:2015-04-22 17:10:00

标签: android google-api google-places-api

我目前正在做一个Android应用程序,它返回最符合用户指定偏好(匹配,咖啡,酒吧等)的位置。为此,我在Google Places API中使用了Nearby Search Requests。这就是我构建HTTP请求的方式:

public String createRequestURL() {
    String requestURL = "";

    if ((googleApiKey != "") && (lat <= MAX_GOOGLE_LAT) && (lat >=  MIN_GOOGLE_LAT)
            && (lng <= MAX_GOOGLE_LNG) && (lng >= MIN_GOOGLE_LNG)) {
        requestURL += "https://maps.googleapis.com/maps/api/place/nearbysearch/json?";
        requestURL += "location=" + lat + "," + lng;
        requestURL += "&rankby=distance";
        requestURL += "&keyword=" + keyword;
        requestURL += "&opennow";
        requestURL += "&key=" + googleApiKey;
    }

    return requestURL;
}

我尝试执行的测试查询是lat = 45.5017,lng = 73.5673,keyword =&#34; pizza&#34;,这是为了找到现在在蒙特利尔附近开放的所有披萨店。

当我对API执行该查询时,我始终返回ZERO_RESULTS状态。我以前使用的是radius字段,但之后看过这个question and answer on stackoverflow,似乎在查询中使用了rankby,然后删除了我的应用中超过X米的所有查询响应对于我希望我的应用程序做什么更好。

为什么我的ZERO_RESULTS状态会被取回,而不是我所在位置附近的实际披萨,咖啡,酒吧等?

编辑:

我也尝试过以下请求:

public String createRequestURL() {
    String requestURL = "";

    if ((googleApiKey != "") && (lat <= MAX_GOOGLE_LAT) && (lat >=  MIN_GOOGLE_LAT)
            && (lng <= MAX_GOOGLE_LNG) && (lng >= MIN_GOOGLE_LNG)) {
        requestURL += "https://maps.googleapis.com/maps/api/place/nearbysearch/json?";
        requestURL += "location=" + lat + "," + lng;
        requestURL += "&rankby=distance";
        requestURL += "&types=food";
        requestURL += "&key=" + googleApiKey;
    }

    return requestURL;
}

这个简单的请求仍然返回状态ZERO_RESULTS

1 个答案:

答案 0 :(得分:2)

为蒙特利尔改变lng = -73.5673。