steventnorris
steventnorris

Reputation: 5896

Invalid Places Request

I am sending a request like this:

https://maps.googleapis.com/maps/api/place/search/json?radius=30&location=37.7858742105946,-122.406341359019&rankby=distance&key=MYKEYHERE&type=establishment

But the response is coming back as this:

{
   "html_attributions" : [],
   "results" : [],
   "status" : "INVALID_REQUEST"
}

What is wrong about my request that is causing it to be invalid?

Upvotes: 0

Views: 370

Answers (1)

geocodezip
geocodezip

Reputation: 161384

From the documentation:

radius — Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50 000 meters. Note that radius must not be included if rankby=distance (described under Optional parameters below) is specified.

Remove rankby=distance from the request (for a 30 meter radius, it doesn't make sense).

https://maps.googleapis.com/maps/api/place/search/json?radius=30&location=37.7858742105946,-122.406341359019&key=<KEY>&type=establishment

Gives me this response:

{
   "html_attributions" : [],
   "results" : [
      {
         "geometry" : {
            "location" : {
               "lat" : 37.7860877,
               "lng" : -122.4064646
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 37.7874464802915,
                  "lng" : -122.4050379197085
               },
               "southwest" : {
                  "lat" : 37.7847485197085,
                  "lng" : -122.4077358802915
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
         "id" : "acf15a7460a5b2a3c8f7bba1af978fb2fc744f0d",
         "name" : "A/X Armani Exchange",
         "opening_hours" : {
            "open_now" : false,
            "weekday_text" : []
         },
         "place_id" : "ChIJZyuhr4iAhYARpQEX4hwEJQI",
         "rating" : 4.1,
         "reference" : "CmRRAAAAMfTprFXJRaU_yLIqTAeIcGTxQ_6S2eYtBeRTwKk_7Pl6yXePzu3fNbz1gsEyTGEE_l8k_iW7VPjjpL34ynxSdzti1ivWeFQds_m9UD7cEqTuIldgqnT-46iySaeTEdMtEhBCcM7tqTnT5B_4a7gnK81cGhRJKFvJGTM33KhWHKUlrZ6xN7TuEQ",
         "scope" : "GOOGLE",
         "types" : [ "clothing_store", "store", "point_of_interest", "establishment" ],
         "vicinity" : "25 Stockton Street, San Francisco"
      }
   ],
   "status" : "OK"
}

Upvotes: 1

Related Questions