0

我可以使用下面的代码从 android 发布到 Google Place Actions 以在此处发布位置。

 public void postMyPlaces(final double lat, final double lng, String name){
    Log.i(TAG," postMyPlaces called");

    Thread t = new Thread(){

        @Override
        public void run() {
            super.run();

            String url = "https://maps.googleapis.com/maps/api/place/add/json?sensor=true&key=" +GOOGLE_API_KEY ;


            HttpParams httpParameters = new BasicHttpParams();
            // Set the timeout in milliseconds until a connection is established.
            // The default value is zero, that means the timeout is not used. 
            int timeoutConnection = 3000;
            HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
            // Set the default socket timeout (SO_TIMEOUT) 
            // in milliseconds which is the timeout for waiting for data.
            int timeoutSocket = 5000;
            HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

            DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);

            HttpPost httpPost = new HttpPost(url);
            Log.i(TAG," postMyPlaces called "+ url);
            httpPost.setHeader("Content-type", "application/json");


            //Create a json request object to send it via HTTPS
            LocationModel uLocation = new LocationModel(Double.toString(lat),Double.toString(lng));
            MyPlacesModelImpl myPlacesPayload = new MyPlacesModelImpl("50","My Car","parking","en-AU",uLocation);


            StringEntity entity = null;
            try {
                entity = new StringEntity(myPlacesPayload.toJSON().toString());
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            httpPost.setEntity(entity);
            HttpResponse httpResponse = null;
            try {
                 httpResponse = httpClient.execute(httpPost);
                String resp = httpResponse.toString();
                Log.i(TAG,resp);
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        };

    };
    t.start();


}

我得到的响应是“OK”。但是如何查看我在地图中添加的这些地方????请帮忙

4

1 回答 1

0

“地点报告请求用于添加新地点或删除现有地点。新地点将立即在您的应用程序启动的地点附近搜索中可用,并将进入审核队列以考虑用于 Google 地图。新添加的地点将在经过审核程序批准之前,不会出现在 Places Text Search 或 Radar Search 结果或其他应用程序中。” (来自:https ://developers.google.com/places/documentation/actions#PlaceReports )

此网页包含附近的地方搜索https ://developers.google.com/places/documentation/search

于 2013-05-23T05:50:28.007 回答