0

I am adding locations to my Android application which is utilizing the Google Places API and when I run a search for these places I am getting the Name, latitude and longitude back but I am unable to retrieve the formatted address or formatted phone number. I am wondering if it is not possible to add location details such as the address, phone number, website etc. or am I doing something wrong. Here is the HTTP post I am using:

public JSONObject addPlace(double lat, double lng, String type, String name) throws Exception {
    try {
        Log.v(LOG_KEY, "Adding Place...");
         String vic = "5/48 Pirrama Road, Pyrmont";
         String formtd_address = "5/48 Pirrama Road, Pyrmont NSW, Australia";
         String formtd_phone_number = "(02) 9374 4000";
         String myUrl = "http://maps.google.com/maps/place?cid=10281119596374313554";
         String myWebsite = "http://www.google.com.au/";

        HttpPost post = new HttpPost(PLACE_ADD_URL);
        String postBody = 
                    "{"+
                          "\"location\": {" +
                            "\"lat\": " + lat + "," +
                            "\"lng\": " + lng +
                           "}," + 
                           "\"accuracy\":50.0," +
                           "\"name\": \"" + name + "\"," +
                           "\"types\": [\"" + type + "\"]," +
                           "\"vicinity\":\""+ PlaceAdd.vic +"\","+
                           "\"formatted_address\":\""+ PlaceAdd.formtd_address +"\","+
                           "\"formatted_phone_number\":\""+ PlaceAdd.formtd_phone_number +"\","+
                           "\"url\":\""+ PlaceAdd.myUrl +"\","+
                           "\"website\":\""+ PlaceAdd.myWebsite +"\","+  
                           "\"language\": \"en\" " +

                      "}"; 

        StringEntity se = new StringEntity(postBody,HTTP.UTF_8);
        post.setEntity(se);
        ResponseHandler<String> responseHandler=new BasicResponseHandler();
        String responseBody = new DefaultHttpClient().execute(post, responseHandler);
        JSONObject response = new JSONObject(responseBody);
        Log.v(LOG_KEY, "Requested URL= " + PLACE_ADD_URL); 

        return response;

    } catch (HttpResponseException e) {
        Log.v(LOG_KEY, e.getResponse().parseAsString());
        throw e;
    }

    catch (IOException e) {
        // TODO: handle exception
        throw e;
    }
}  

So I guess I have two questions. Can you add place details when adding a location within your app to the Google Places API, if so is there something wrong with my code?

THANKS!

1 Answer 1

0

As per the documentation, Place Reports only support location, accuracy, name, types and language parameters in the POST request. Please file a Places API - Feature Request if you think that it would be a useful feature to support adding place details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.