Open dimix opened 1 year ago
The code used is:
let snapshot = Snapshot(options: options, accessToken: Self.token)
let image = snapshot.image
I found the issue.
The code is wrong on WatchOS:
Snapshot.swift line 174
@objc open var image: Image? {
if let data = try? Data(contentsOf: url) {
return Image(data: data)
} else {
return nil
}
}
Loading directly from Data is not allowed. You need to use URLSession instead.
Extend Class Snapshot and implement new method using URLSession like:
extension Snapshot {
func getImage() async throws -> UIImage? {
let (data, _) = try await URLSession.shared.data(from: url)
return UIImage(data: data)
}
}
On Apple Watch Device I've Network errors and the image is not loaded:
In simulator the image is loaded correctly without errors.
How can I load map images directly in Device? Thanks!