2012-11-28 52 views
0

我可以使用以下代碼發佈到Google Place Android操作,以便在here中發佈地點。實施Google Place添加新地點的操作

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」。 但是如何看到我在地圖中添加的這些地方?請幫助

回答

0

「商家信息報告請求用於添加新的地方,或刪除現有的。新的地方可立即在您的應用程序啓動很近的地方搜索,並進入審覈隊列爲谷歌被認爲是地圖:新增的地方信息不會出現在地點文字搜索或雷達搜索結果中,或其他應用程序中,直至其獲得審覈過程批准爲止。「 (來源:https://developers.google.com/places/documentation/actions#PlaceReports

此網頁包含很近的地方搜索https://developers.google.com/places/documentation/search