无法在所选地点获得拉特隆

时间:2019-07-04 21:37:23

标签: android

我使用的是Google Places SDK,当我尝试获取选定的位置信息时,我可以获取名称和ID,但无法获取Latlng等

 fragments[1].setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            // TODO: Get info about the selected place.
            Log.i("asd", "Place: " + place.getLatLng().latitude + ", " + place.getId());
        }

        @Override
        public void onError(Status status) {
            // TODO: Handle the error.
            Log.i("asd", "An error occurred: " + status);
        }
    });
}

我的日志猫

I/asd: Place: Place{address=null, addressComponents=null, attributions=[], id=ChIJO3svnEReUjoR38xr0NFxtiU, latLng=null, name=Vels University, openingHours=null, phoneNumber=null, photoMetadatas=null, plusCode=null, priceLevel=null, rating=null, types=null, userRatingsTotal=null, viewport=null, websiteUri=null}, ChIJO3svnEReUjoR38xr0NFxtiU

1 个答案:

答案 0 :(得分:0)

   fragments[1].setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.LAT_LNG));

我想像上面一样添加Place .field.Lat_LNG属性

https://developers.google.com/places/android-sdk/place-details