react-native-google-maps-plus 1.10.0-dev.7 → 1.10.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,9 +45,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
45
45
  }
46
46
 
47
47
  func showLocationDialog() {
48
- onMainAsync { [weak self] in
49
- guard let self = self else { return }
50
-
48
+ onMain {
51
49
  guard let vc = Self.topMostViewController() else { return }
52
50
  let title =
53
51
  Bundle.main.object(forInfoDictionaryKey: "LocationNotAvailableTitle")
@@ -96,7 +94,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
96
94
  }
97
95
 
98
96
  func openLocationSettings() {
99
- onMainAsync {
97
+ onMain {
100
98
  let openSettings = {
101
99
  if #available(iOS 18.3, *) {
102
100
  guard
@@ -1,7 +1,6 @@
1
1
  import GoogleMaps
2
2
 
3
3
  final class MapCircleBuilder {
4
- @MainActor
5
4
  func build(_ c: RNCircle) -> GMSCircle {
6
5
  let circle = GMSCircle()
7
6
  circle.position = c.center.toCLLocationCoordinate2D()
@@ -15,34 +14,35 @@ final class MapCircleBuilder {
15
14
  return circle
16
15
  }
17
16
 
18
- @MainActor
19
17
  func update(_ prev: RNCircle, _ next: RNCircle, _ c: GMSCircle) {
20
- if !prev.centerEquals(next) {
21
- c.position = next.center.toCLLocationCoordinate2D()
22
- }
23
-
24
- if prev.radius != next.radius {
25
- c.radius = next.radius
26
- }
27
-
28
- if prev.fillColor != next.fillColor {
29
- c.fillColor = next.fillColor?.toUIColor() ?? .clear
30
- }
31
-
32
- if prev.strokeColor != next.strokeColor {
33
- c.strokeColor = next.strokeColor?.toUIColor() ?? .black
34
- }
35
-
36
- if prev.strokeWidth != next.strokeWidth {
37
- c.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
38
- }
39
-
40
- if prev.pressable != next.pressable {
41
- c.isTappable = next.pressable ?? false
42
- }
43
-
44
- if prev.zIndex != next.zIndex {
45
- c.zIndex = Int32(next.zIndex ?? 0)
18
+ onMain {
19
+ if !prev.centerEquals(next) {
20
+ c.position = next.center.toCLLocationCoordinate2D()
21
+ }
22
+
23
+ if prev.radius != next.radius {
24
+ c.radius = next.radius
25
+ }
26
+
27
+ if prev.fillColor != next.fillColor {
28
+ c.fillColor = next.fillColor?.toUIColor() ?? .clear
29
+ }
30
+
31
+ if prev.strokeColor != next.strokeColor {
32
+ c.strokeColor = next.strokeColor?.toUIColor() ?? .black
33
+ }
34
+
35
+ if prev.strokeWidth != next.strokeWidth {
36
+ c.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
37
+ }
38
+
39
+ if prev.pressable != next.pressable {
40
+ c.isTappable = next.pressable ?? false
41
+ }
42
+
43
+ if prev.zIndex != next.zIndex {
44
+ c.zIndex = Int32(next.zIndex ?? 0)
45
+ }
46
46
  }
47
47
  }
48
48
  }
@@ -4,7 +4,6 @@ import GoogleMapsUtils
4
4
  import UIKit
5
5
 
6
6
  final class MapHeatmapBuilder {
7
- @MainActor
8
7
  func build(_ h: RNHeatmap) -> GMUHeatmapTileLayer {
9
8
  let heatmap = GMUHeatmapTileLayer()
10
9
  heatmap.weightedData = h.weightedData.toWeightedLatLngs()
@@ -1,12 +1,12 @@
1
1
  import QuartzCore
2
2
 
3
- @MainActor @inline(__always)
3
+ @inline(__always)
4
4
  func withCATransaction(
5
5
  disableActions: Bool = true,
6
6
  duration: CFTimeInterval? = nil,
7
7
  timingFunction: CAMediaTimingFunction? = nil,
8
8
  completion: (() -> Void)? = nil,
9
- _ body: @escaping @MainActor () -> Void
9
+ _ body: @escaping () -> Void
10
10
  ) {
11
11
  onMain {
12
12
  CATransaction.begin()
@@ -21,20 +21,15 @@ func withCATransaction(
21
21
  }
22
22
  }
23
23
 
24
- @MainActor @inline(__always)
25
- func onMain(_ block: @escaping @MainActor () -> Void) {
24
+ @inline(__always)
25
+ func onMain(
26
+ _ block: @escaping () -> Void
27
+ ) {
26
28
  if Thread.isMainThread {
27
29
  block()
28
30
  } else {
29
- Task { @MainActor in block() }
30
- }
31
- }
32
-
33
- @inline(__always)
34
- func onMainAsync(
35
- _ block: @escaping @MainActor () async -> Void
36
- ) {
37
- Task { @MainActor in
38
- await block()
31
+ Task { @MainActor in
32
+ block()
33
+ }
39
34
  }
40
35
  }
@@ -10,7 +10,6 @@ final class MapMarkerBuilder {
10
10
  }()
11
11
  private var tasks: [String: Task<Void, Never>] = [:]
12
12
 
13
- @MainActor
14
13
  func build(_ m: RNMarker, icon: UIImage?) -> GMSMarker {
15
14
  let marker = GMSMarker(
16
15
  position: m.coordinate.toCLLocationCoordinate2D()
@@ -44,22 +43,37 @@ final class MapMarkerBuilder {
44
43
  return marker
45
44
  }
46
45
 
47
- @MainActor
48
46
  func update(_ prev: RNMarker, _ next: RNMarker, _ m: GMSMarker) {
49
- withCATransaction(disableActions: true) {
47
+ onMain {
48
+ withCATransaction(disableActions: true) {
50
49
 
51
- var tracksViewChanges = false
52
- var tracksInfoWindowChanges = false
50
+ var tracksViewChanges = false
51
+ var tracksInfoWindowChanges = false
53
52
 
54
- if !prev.coordinateEquals(next) {
55
- m.position = next.coordinate.toCLLocationCoordinate2D()
56
- }
57
-
58
- if !prev.markerStyleEquals(next) {
59
- self.buildIconAsync(next) { img in
60
- tracksViewChanges = true
61
- m.icon = img
53
+ if !prev.coordinateEquals(next) {
54
+ m.position = next.coordinate.toCLLocationCoordinate2D()
55
+ }
62
56
 
57
+ if !prev.markerStyleEquals(next) {
58
+ self.buildIconAsync(next) { img in
59
+ tracksViewChanges = true
60
+ m.icon = img
61
+
62
+ if !prev.anchorEquals(next) {
63
+ m.groundAnchor = CGPoint(
64
+ x: next.anchor?.x ?? 0.5,
65
+ y: next.anchor?.y ?? 1
66
+ )
67
+ }
68
+
69
+ if !prev.infoWindowAnchorEquals(next) {
70
+ m.infoWindowAnchor = CGPoint(
71
+ x: next.infoWindowAnchor?.x ?? 0.5,
72
+ y: next.infoWindowAnchor?.y ?? 0
73
+ )
74
+ }
75
+ }
76
+ } else {
63
77
  if !prev.anchorEquals(next) {
64
78
  m.groundAnchor = CGPoint(
65
79
  x: next.anchor?.x ?? 0.5,
@@ -74,72 +88,54 @@ final class MapMarkerBuilder {
74
88
  )
75
89
  }
76
90
  }
77
- } else {
78
- if !prev.anchorEquals(next) {
79
- m.groundAnchor = CGPoint(
80
- x: next.anchor?.x ?? 0.5,
81
- y: next.anchor?.y ?? 1
82
- )
83
- }
84
91
 
85
- if !prev.infoWindowAnchorEquals(next) {
86
- m.infoWindowAnchor = CGPoint(
87
- x: next.infoWindowAnchor?.x ?? 0.5,
88
- y: next.infoWindowAnchor?.y ?? 0
89
- )
92
+ if prev.title != next.title {
93
+ tracksInfoWindowChanges = true
94
+ m.title = next.title
90
95
  }
91
- }
92
96
 
93
- if prev.title != next.title {
94
- tracksInfoWindowChanges = true
95
- m.title = next.title
96
- }
97
-
98
- if prev.snippet != next.snippet {
99
- tracksInfoWindowChanges = true
100
- m.snippet = next.snippet
101
- }
102
-
103
- if prev.opacity != next.opacity {
104
- let opacity = Float(next.opacity ?? 1)
105
- m.opacity = opacity
106
- m.iconView?.alpha = CGFloat(opacity)
107
- }
97
+ if prev.snippet != next.snippet {
98
+ tracksInfoWindowChanges = true
99
+ m.snippet = next.snippet
100
+ }
108
101
 
109
- if prev.flat != next.flat {
110
- m.isFlat = next.flat ?? false
111
- }
102
+ if prev.opacity != next.opacity {
103
+ let opacity = Float(next.opacity ?? 1)
104
+ m.opacity = opacity
105
+ m.iconView?.alpha = CGFloat(opacity)
106
+ }
112
107
 
113
- if prev.draggable != next.draggable {
114
- m.isDraggable = next.draggable ?? false
115
- }
108
+ if prev.flat != next.flat {
109
+ m.isFlat = next.flat ?? false
110
+ }
116
111
 
117
- if prev.rotation != next.rotation {
118
- m.rotation = next.rotation ?? 0
119
- }
112
+ if prev.draggable != next.draggable {
113
+ m.isDraggable = next.draggable ?? false
114
+ }
120
115
 
121
- if prev.zIndex != next.zIndex {
122
- m.zIndex = Int32(next.zIndex ?? 0)
123
- }
116
+ if prev.rotation != next.rotation {
117
+ m.rotation = next.rotation ?? 0
118
+ }
124
119
 
125
- if !prev.markerInfoWindowStyleEquals(next) {
126
- m.tagData = MarkerTag(
127
- id: next.id,
128
- iconSvg: next.infoWindowIconSvg
129
- )
130
- }
120
+ if prev.zIndex != next.zIndex {
121
+ m.zIndex = Int32(next.zIndex ?? 0)
122
+ }
131
123
 
132
- if tracksViewChanges {
133
- m.tracksViewChanges = tracksViewChanges
134
- }
135
- if tracksInfoWindowChanges {
136
- m.tracksInfoWindowChanges = tracksInfoWindowChanges
137
- }
124
+ if !prev.markerInfoWindowStyleEquals(next) {
125
+ m.tagData = MarkerTag(
126
+ id: next.id,
127
+ iconSvg: next.infoWindowIconSvg
128
+ )
129
+ }
138
130
 
139
- if tracksViewChanges || tracksInfoWindowChanges {
140
- onMain { [weak m] in
141
- guard let m = m else { return }
131
+ if tracksViewChanges {
132
+ m.tracksViewChanges = tracksViewChanges
133
+ }
134
+ if tracksInfoWindowChanges {
135
+ m.tracksInfoWindowChanges = tracksInfoWindowChanges
136
+ }
142
137
 
138
+ if tracksViewChanges || tracksInfoWindowChanges {
143
139
  if tracksViewChanges {
144
140
  m.tracksViewChanges = false
145
141
  }
@@ -191,13 +187,11 @@ final class MapMarkerBuilder {
191
187
  tasks[m.id] = task
192
188
  }
193
189
 
194
- @MainActor
195
190
  func cancelIconTask(_ id: String) {
196
191
  tasks[id]?.cancel()
197
192
  tasks.removeValue(forKey: id)
198
193
  }
199
194
 
200
- @MainActor
201
195
  func cancelAllIconTasks() {
202
196
  let ids = Array(tasks.keys)
203
197
  for id in ids {
@@ -208,7 +202,6 @@ final class MapMarkerBuilder {
208
202
  CATransaction.flush()
209
203
  }
210
204
 
211
- @MainActor
212
205
  func buildInfoWindow(iconSvg: RNMarkerSvg?) -> UIImageView? {
213
206
  guard let iconSvg = iconSvg else {
214
207
  return nil
@@ -246,6 +239,7 @@ final class MapMarkerBuilder {
246
239
  let iconSvg = m.iconSvg,
247
240
  let data = iconSvg.svgString.data(using: .utf8)
248
241
  else { return nil }
242
+ print("Is main thread:", Thread.isMainThread)
249
243
 
250
244
  let size = CGSize(
251
245
  width: max(1, CGFloat(iconSvg.width)),
@@ -1,7 +1,6 @@
1
1
  import GoogleMaps
2
2
 
3
3
  final class MapPolygonBuilder {
4
- @MainActor
5
4
  func build(_ p: RNPolygon) -> GMSPolygon {
6
5
  let path = p.coordinates.toGMSPath()
7
6
  let pg = GMSPolygon(path: path)
@@ -17,38 +16,39 @@ final class MapPolygonBuilder {
17
16
  return pg
18
17
  }
19
18
 
20
- @MainActor
21
19
  func update(_ prev: RNPolygon, _ next: RNPolygon, _ pg: GMSPolygon) {
22
- if !prev.coordinatesEquals(next) {
23
- pg.path = next.coordinates.toGMSPath()
24
- }
25
-
26
- if !prev.holesEquals(next) {
27
- pg.holes = next.holes.toMapPolygonHoles()
28
- }
29
-
30
- if prev.fillColor != next.fillColor {
31
- pg.fillColor = next.fillColor?.toUIColor() ?? .clear
32
- }
33
-
34
- if prev.strokeColor != next.strokeColor {
35
- pg.strokeColor = next.strokeColor?.toUIColor() ?? .black
36
- }
37
-
38
- if prev.strokeWidth != next.strokeWidth {
39
- pg.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
40
- }
41
-
42
- if prev.pressable != next.pressable {
43
- pg.isTappable = next.pressable ?? false
44
- }
45
-
46
- if prev.geodesic != next.geodesic {
47
- pg.geodesic = next.geodesic ?? false
48
- }
49
-
50
- if prev.zIndex != next.zIndex {
51
- pg.zIndex = Int32(next.zIndex ?? 0)
20
+ onMain {
21
+ if !prev.coordinatesEquals(next) {
22
+ pg.path = next.coordinates.toGMSPath()
23
+ }
24
+
25
+ if !prev.holesEquals(next) {
26
+ pg.holes = next.holes.toMapPolygonHoles()
27
+ }
28
+
29
+ if prev.fillColor != next.fillColor {
30
+ pg.fillColor = next.fillColor?.toUIColor() ?? .clear
31
+ }
32
+
33
+ if prev.strokeColor != next.strokeColor {
34
+ pg.strokeColor = next.strokeColor?.toUIColor() ?? .black
35
+ }
36
+
37
+ if prev.strokeWidth != next.strokeWidth {
38
+ pg.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
39
+ }
40
+
41
+ if prev.pressable != next.pressable {
42
+ pg.isTappable = next.pressable ?? false
43
+ }
44
+
45
+ if prev.geodesic != next.geodesic {
46
+ pg.geodesic = next.geodesic ?? false
47
+ }
48
+
49
+ if prev.zIndex != next.zIndex {
50
+ pg.zIndex = Int32(next.zIndex ?? 0)
51
+ }
52
52
  }
53
53
  }
54
54
  }
@@ -1,7 +1,6 @@
1
1
  import GoogleMaps
2
2
 
3
3
  final class MapPolylineBuilder {
4
- @MainActor
5
4
  func build(_ p: RNPolyline) -> GMSPolyline {
6
5
  let path = GMSMutablePath()
7
6
  p.coordinates.forEach {
@@ -23,30 +22,31 @@ final class MapPolylineBuilder {
23
22
  return pl
24
23
  }
25
24
 
26
- @MainActor
27
25
  func update(_ prev: RNPolyline, _ next: RNPolyline, _ pl: GMSPolyline) {
28
- if !prev.coordinatesEquals(next) {
29
- pl.path = next.coordinates.toGMSPath()
30
- }
31
-
32
- if prev.width != next.width {
33
- pl.strokeWidth = CGFloat(next.width ?? 1.0)
34
- }
35
-
36
- if prev.color != next.color {
37
- pl.strokeColor = next.color?.toUIColor() ?? .black
38
- }
39
-
40
- if prev.pressable != next.pressable {
41
- pl.isTappable = next.pressable ?? false
42
- }
43
-
44
- if prev.geodesic != next.geodesic {
45
- pl.geodesic = next.geodesic ?? false
46
- }
47
-
48
- if prev.zIndex != next.zIndex {
49
- pl.zIndex = Int32(next.zIndex ?? 0)
26
+ onMain {
27
+ if !prev.coordinatesEquals(next) {
28
+ pl.path = next.coordinates.toGMSPath()
29
+ }
30
+
31
+ if prev.width != next.width {
32
+ pl.strokeWidth = CGFloat(next.width ?? 1.0)
33
+ }
34
+
35
+ if prev.color != next.color {
36
+ pl.strokeColor = next.color?.toUIColor() ?? .black
37
+ }
38
+
39
+ if prev.pressable != next.pressable {
40
+ pl.isTappable = next.pressable ?? false
41
+ }
42
+
43
+ if prev.geodesic != next.geodesic {
44
+ pl.geodesic = next.geodesic ?? false
45
+ }
46
+
47
+ if prev.zIndex != next.zIndex {
48
+ pl.zIndex = Int32(next.zIndex ?? 0)
49
+ }
50
50
  }
51
51
  }
52
52
  }
@@ -1,7 +1,6 @@
1
1
  import GoogleMaps
2
2
 
3
3
  class MapUrlTileOverlayBuilder {
4
- @MainActor
5
4
  func build(_ t: RNUrlTileOverlay) -> GMSURLTileLayer {
6
5
 
7
6
  let constructor: GMSTileURLConstructor = { (x: UInt, y: UInt, zoom: UInt) in