From 8384ffdcfb3cf04c2f6394d10da872b9eee4204b Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 27 Sep 2023 18:38:09 +0200 Subject: [PATCH] fix(google-maps): use URLSession for remote iconUrl on iOS --- google-maps/ios/Plugin/Map.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/google-maps/ios/Plugin/Map.swift b/google-maps/ios/Plugin/Map.swift index 5a5797019..d7315f0e9 100644 --- a/google-maps/ios/Plugin/Map.swift +++ b/google-maps/ios/Plugin/Map.swift @@ -189,7 +189,7 @@ public class Map { func destroy() { DispatchQueue.main.async { - self.mapViewController.GMapView = nil + self.mapViewController.GMapView = nil self.targetViewController?.tag = 0 self.mapViewController.view = nil self.enableTouch() @@ -614,11 +614,15 @@ public class Map { newMarker.icon = getResizedIcon(iconImage, marker) } else { if iconUrl.starts(with: "https:") { - DispatchQueue.main.async { - if let url = URL(string: iconUrl), let data = try? Data(contentsOf: url), let iconImage = UIImage(data: data) { - self.markerIcons[iconUrl] = iconImage - newMarker.icon = getResizedIcon(iconImage, marker) - } + if let url = URL(string: iconUrl) { + URLSession.shared.dataTask(with: url) { (data, _, _) in + DispatchQueue.main.async { + if let data = data, let iconImage = UIImage(data: data) { + self.markerIcons[iconUrl] = iconImage + newMarker.icon = getResizedIcon(iconImage, marker) + } + } + }.resume() } } else if let iconImage = UIImage(named: "public/\(iconUrl)") { self.markerIcons[iconUrl] = iconImage