Choub890
Choub890

Reputation: 1163

Google Places API returning zero-results with specified keyword

I am currently doing an Android app that returns the closest places to a user's location that fits his specified preferences (pizza, coffee, bar, etc). In order to do that, I am using Nearby Search Requests in the Google Places API. This is how I build my HTTP request:

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;
}

The test query I am trying to execute is with lat = 45.5017, lng = 73.5673, keyword = "pizza", which is to find all pizza places that are open now near Montreal.

When I execute that query to the API, I get the ZERO_RESULTS status back all the time. I was using the radius field before, but have since read this question and answer on stackoverflow and it seems that using rankby in the query and then removing all query responses which are further than X meters in my app is better for what I want my app to do.

Why am I getting the ZERO_RESULTS status back instead of actual pizza, coffee, bar, etc places nearby my location?


EDIT:

I have tried the following request as well:

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;
}

And this simple request is still returning the status ZERO_RESULTS.

Upvotes: 0

Views: 1279

Answers (1)

Emma
Emma

Reputation: 9373

Change lng = -73.5673 for Montreal.

Upvotes: 2

Related Questions