From da5fc5100466db0f9f2de0872ca5fa86465b225b Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 3 Oct 2023 18:52:40 +0200 Subject: [PATCH] fix(google-maps): use URLSession for remote iconUrl on iOS (#1818) --- 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