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;
}
}
だから私は2つの質問があると思います。アプリ内の場所を Google Places API に追加するときに、場所の詳細を追加できますか? コードに何か問題がある場合、場所の詳細を追加できますか?
ありがとう!