我正在嘗試遷移到 New Places SDK 客戶端并導(dǎo)入此“implementation 'com.google.android.libraries.places:places:2.0.0'”庫,并導(dǎo)入“implementation 'com.google.android.libraries.places: place-compat:2.0.0'" 在應(yīng)用程序基礎(chǔ) gradle 中導(dǎo)入兩個(gè)庫后。我想從谷歌地圖獲取位置照片請(qǐng)有人幫助我如何從谷歌地圖獲取照片?提前致謝....我正在嘗試訪問獲取地點(diǎn)照片方法,使用 get place.getPhotoMetadatas() 從谷歌地圖位置獲取照片。placeClient.fetchPlace(placeRequest).addOnSuccessListener((response) -> { Place place = response.getPlace();// Get the photo metadata.PhotoMetadata photoMetadata = place.getPhotoMetadatas().get(0);// Get the attribution text.String attributions = photoMetadata.getAttributions();// Create a FetchPhotoRequest.FetchPhotoRequest photoRequest = FetchPhotoRequest.builder(photoMetadata) .setMaxWidth(500) // Optional. .setMaxHeight(300) // Optional. .build();placesClient.fetchPhoto(photoRequest).addOnSuccessListener((fetchPhotoResponse) -> { Bitmap bitmap = fetchPhotoResponse.getBitmap(); imageView.setImageBitmap(bitmap);}).addOnFailureListener((exception) -> { if (exception instanceof ApiException) { ApiException apiException = (ApiException) exception; int statusCode = apiException.getStatusCode(); // Handle error with given status code. Log.e(TAG, "Place not found: " + exception.getMessage()); }});});無法解析方法 place.getPhotoMetadatas()
當(dāng)我導(dǎo)入遷移到 androidX 中的 New Places SDK 客戶端時(shí)。
慕工程0101907
2023-09-27 16:50:32