in ml-functions/MLFunctionsExampleSwift/ViewController.swift [148:166]
func getRecognizedLandmarksFrom(_ result: HTTPSCallableResult?) {
// [START getRecognizedLandmarksFrom]
if let labelArray = (result?.data as? [String: Any])?["landmarkAnnotations"] as? [[String:Any]] {
for labelObj in labelArray {
let landmarkName = labelObj["description"]
let entityId = labelObj["mid"]
let score = labelObj["score"]
let bounds = labelObj["boundingPoly"]
// Multiple locations are possible, e.g., the location of the depicted
// landmark and the location the picture was taken.
guard let locations = labelObj["locations"] as? [[String: [String: Any]]] else { continue }
for location in locations {
let latitude = location["latLng"]?["latitude"]
let longitude = location["latLng"]?["longitude"]
}
}
}
// [END getRecognizedLandmarksFrom]
}