0

我試圖搜索Latlng使用google place api的地方(如餐館或酒店)。有沒有可能改變Places.PlaceDetectionApi getCurrentPlace(mGoogleApiClient, pf);的結果並設置其他座標。我的代碼是:設置當前的谷歌地點API位置

 mGoogleApiClient = new GoogleApiClient 
      .Builder(this) 
      .addApi(Places.GEO_DATA_API) 
      .addApi(Places.PLACE_DETECTION_API) 
      .addConnectionCallbacks(this) 
      .addOnConnectionFailedListener(this) 
      .build(); 


    ArrayList<String> restrictToRestaurants = new ArrayList<>(); 
    restrictToRestaurants.add(Integer.toString(Place.TYPE_RESTAURANT)); 
    PlaceFilter pf; 
    pf = new PlaceFilter(false, restrictToRestaurants); 

    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi 
      .getCurrentPlace(mGoogleApiClient, pf); 

    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() { 
     @Override 
     public void onResult(PlaceLikelihoodBuffer likelyPlaces) { 
      final CharSequence thirdPartyAttributions = likelyPlaces.getAttributions(); 
      for (PlaceLikelihood placeLikelihood : likelyPlaces) { 
       Log.i("tag", String.format("Place '%s' has likelihood: %g", 
         placeLikelihood.getPlace().getName(), 
         placeLikelihood.getLikelihood())); 


      } 
      likelyPlaces.release(); 
     } 
    }); 

所以我有一個變量Latlng,我想搜索的地方几乎是協調。提前致謝。

+0

在閱讀了更多谷歌地方API後,我明白,沒有辦法做到這一點(其唯一用於查找設備位置附近的地方:()......作爲一個建議,也許Google的人可以開發一個功能,給一個位置檢索幾乎那個位置的地方:)(對我的英語感到抱歉,是如此糟糕) – denials

回答

0

好了,你可以隨時使用Google Places API Web Service,這看起來是這樣的:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&keyword=cruise&key=API_KEY
其中

位置 - 緯度/經度在其周圍檢索地方信息。這必須指定爲緯度,經度。

+0

這工作,謝謝:) – denials

+0

因爲你在Android設備:「谷歌地方API Web服務是用於服務器應用程序。如果您正在構建客戶端應用程序,請查看Android版Google Places API和Google Maps JavaScript API中的Places庫。「來源:https://developers.google.com/places/web-service/search#PlaceSearchRequests – Totalys