Skip to content

Commit

Permalink
fix(google-maps): use URLSession for remote iconUrl on iOS (#1818)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Oct 3, 2023
1 parent 5a8399e commit da5fc51
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions google-maps/ios/Plugin/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit da5fc51

Please sign in to comment.