photos = (
{
height = 2304;
"html_attributions" = (
"<a href=\"https://maps.google.com/maps/contrib/1152719XX951XXXX0531/photos\">XXX XX</a>"
);
"photo_reference" = "CmRaAAAAFectOxyAKTfvFyP6yIp24z8T6FAidRxYcAMEWYdpeijj6SckncfG9EpgOacw1LrPPrGYN_U6bSiR9D1DffgM";
width = 4096;
},
)
发布于 2019-11-18 13:14:13
您可以使用放置照片服务获取与photo_reference
字符串对应的图像。
示例请求:
对于iOS中的placeID
,您可以使用等效的placeID
服务。参见示例代码:
// Specify the place data types to return (in this case, just photos).
let fields: GMSPlaceField = GMSPlaceField(rawValue: UInt(GMSPlaceField.photos.rawValue))!
placesClient?.fetchPlace(fromPlaceID: "INSERT_PLACE_ID_HERE",
placeFields: fields,
sessionToken: nil, callback: {
(place: GMSPlace?, error: Error?) in
if let error = error {
print("An error occurred: \(error.localizedDescription)")
return
}
if let place = place {
// Get the metadata for the first photo in the place photo metadata list.
let photoMetadata: GMSPlacePhotoMetadata = place.photos![0]
// Call loadPlacePhoto to display the bitmap and attribution.
self.placesClient?.loadPlacePhoto(photoMetadata, callback: { (photo, error) -> Void in
if let error = error {
// TODO: Handle the error.
print("Error loading photo metadata: \(error.localizedDescription)")
return
} else {
// Display the first image and its attributions.
self.imageView?.image = photo;
self.lblText?.attributedText = photoMetadata.attributions;
}
})
}
})
请注意,下载从API返回的图像将违反Google的ToS。参见相关的存储随位置信息返回的照片参考资料
希望这能有所帮助!
https://stackoverflow.com/questions/58872197
复制相似问题