Places.GeoDataApi setResultCallback无法正常工作

时间:2019-02-12 11:07:25

标签: android callback google-places-api

我正在尝试从自动完成编辑文本中检索到的地点ID中获取地点的纬度和经度,但未调用回调:

Places.GeoDataApi.getPlaceById(mGoogleApiClient, data.getPlaceId())
    .setResultCallback(new ResultCallback<PlaceBuffer>() {

    @Override
    public void onResult(PlaceBuffer places) {
        Toast.makeText(Location_getter.this, "hello", Toast.LENGTH_SHORT).show();
        if (places.getStatus().isSuccess() && places.getCount() > 0) {
            Toast.makeText(Location_getter.this, "hello", Toast.LENGTH_SHORT).show();
            // Get the Place object from the buffer.

            LatLng  latLngDrop = places.get(0).getLatLng();
            Log.i("hell", "Place found: " + places.get(0).getName());

            Log.v("latitude:", "" + latLngDrop.latitude);
            Log.v("longitude:", "" + latLngDrop.longitude);
        } else {
            Log.e("hel", "Place not found");
        }
        places.release();
    }
});

0 个答案:

没有答案