0

我正在向使用 Google Places API 的 Android 应用程序添加位置,当我搜索这些地方时,我得到了名称、纬度和经度,但我无法检索格式化的地址或格式化的电话号码。我想知道是否无法添加地址、电话号码、网站等位置详细信息,或者我做错了什么。这是我正在使用的 HTTP 帖子:

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

所以我想我有两个问题。您可以在将应用内的位置添加到 Google Places API 时添加地点详细信息吗?如果可以,我的代码有问题吗?

谢谢!

4

1 回答 1

0

根据文档,Place Reports 仅支持请求locationaccuracyname、、、typeslanguage参数。如果您认为支持添加地点详细信息的有用功能,POST请提交Places API - 功能请求。

于 2013-02-01T03:47:38.587 回答