react-native-google-maps-plus 1.7.0-dev.16 → 1.7.0-dev.17

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.
@@ -35,6 +35,8 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
35
35
 
36
36
  func showLocationDialog() {
37
37
  onMainAsync { [weak self] in
38
+ guard let self = self else { return }
39
+
38
40
  guard let vc = Self.topMostViewController() else { return }
39
41
  let title =
40
42
  Bundle.main.object(forInfoDictionaryKey: "LocationNotAvailableTitle")
@@ -61,7 +63,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
61
63
  title: openLocationSettingsButton ?? "Open settings",
62
64
  style: .default
63
65
  ) { _ in
64
- self?.openLocationSettings()
66
+ self.openLocationSettings()
65
67
  }
66
68
  )
67
69
  vc.present(alert, animated: true, completion: nil)
@@ -32,11 +32,9 @@ func onMain(_ block: @escaping @MainActor () -> Void) {
32
32
 
33
33
  @inline(__always)
34
34
  func onMainAsync(
35
- _ block: @MainActor @escaping () async -> Void
35
+ _ block: @escaping @MainActor () async -> Void
36
36
  ) {
37
- if Thread.isMainThread {
38
- Task { @MainActor in await block() }
39
- } else {
40
- Task { @MainActor in await block() }
37
+ Task { @MainActor in
38
+ await block()
41
39
  }
42
40
  }
@@ -46,14 +46,35 @@ final class MapMarkerBuilder {
46
46
 
47
47
  @MainActor
48
48
  func update(_ prev: RNMarker, _ next: RNMarker, _ m: GMSMarker) {
49
- if !prev.coordinateEquals(next) {
50
- m.position = next.coordinate.toCLLocationCoordinate2D()
51
- }
49
+ withCATransaction(disableActions: true) {
50
+
51
+ var tracksViewChanges = false
52
+ var tracksInfoWindowChanges = false
52
53
 
53
- if !prev.markerStyleEquals(next) {
54
- buildIconAsync(next) { img in
55
- m.icon = img
54
+ if !prev.coordinateEquals(next) {
55
+ m.position = next.coordinate.toCLLocationCoordinate2D()
56
+ }
56
57
 
58
+ if !prev.markerStyleEquals(next) {
59
+ self.buildIconAsync(next) { img in
60
+ tracksViewChanges = true
61
+ m.icon = img
62
+
63
+ if !prev.anchorEquals(next) {
64
+ m.groundAnchor = CGPoint(
65
+ x: next.anchor?.x ?? 0.5,
66
+ y: next.anchor?.y ?? 1
67
+ )
68
+ }
69
+
70
+ if !prev.infoWindowAnchorEquals(next) {
71
+ m.infoWindowAnchor = CGPoint(
72
+ x: next.infoWindowAnchor?.x ?? 0.5,
73
+ y: next.infoWindowAnchor?.y ?? 0
74
+ )
75
+ }
76
+ }
77
+ } else {
57
78
  if !prev.anchorEquals(next) {
58
79
  m.groundAnchor = CGPoint(
59
80
  x: next.anchor?.x ?? 0.5,
@@ -67,74 +88,67 @@ final class MapMarkerBuilder {
67
88
  y: next.infoWindowAnchor?.y ?? 0
68
89
  )
69
90
  }
70
-
71
- m.tracksViewChanges = true
72
- DispatchQueue.main.async {
73
- m.tracksViewChanges = false
74
- }
75
91
  }
76
- } else {
77
- if !prev.anchorEquals(next) {
78
- m.groundAnchor = CGPoint(
79
- x: next.anchor?.x ?? 0.5,
80
- y: next.anchor?.y ?? 1
81
- )
92
+
93
+ if prev.title != next.title {
94
+ tracksInfoWindowChanges = true
95
+ m.title = next.title
82
96
  }
83
97
 
84
- if !prev.infoWindowAnchorEquals(next) {
85
- m.infoWindowAnchor = CGPoint(
86
- x: next.infoWindowAnchor?.x ?? 0.5,
87
- y: next.infoWindowAnchor?.y ?? 0
88
- )
98
+ if prev.snippet != next.snippet {
99
+ tracksInfoWindowChanges = true
100
+ m.snippet = next.snippet
89
101
  }
90
- }
91
102
 
92
- var tracksInfoWindowChanges = false
103
+ if prev.opacity != next.opacity {
104
+ let opacity = Float(next.opacity ?? 1)
105
+ m.opacity = opacity
106
+ m.iconView?.alpha = CGFloat(opacity)
107
+ }
93
108
 
94
- if prev.title != next.title {
95
- tracksInfoWindowChanges = true
96
- m.title = next.title
97
- }
109
+ if prev.flat != next.flat {
110
+ m.isFlat = next.flat ?? false
111
+ }
98
112
 
99
- if prev.snippet != next.snippet {
100
- tracksInfoWindowChanges = true
101
- m.snippet = next.snippet
102
- }
113
+ if prev.draggable != next.draggable {
114
+ m.isDraggable = next.draggable ?? false
115
+ }
103
116
 
104
- if tracksInfoWindowChanges {
105
- m.tracksInfoWindowChanges = true
106
- DispatchQueue.main.async {
107
- m.tracksInfoWindowChanges = false
117
+ if prev.rotation != next.rotation {
118
+ m.rotation = next.rotation ?? 0
108
119
  }
109
- }
110
120
 
111
- if prev.opacity != next.opacity {
112
- let opacity = Float(next.opacity ?? 1)
113
- m.opacity = opacity
114
- m.iconView?.alpha = CGFloat(opacity)
115
- }
121
+ if prev.zIndex != next.zIndex {
122
+ m.zIndex = Int32(next.zIndex ?? 0)
123
+ }
116
124
 
117
- if prev.flat != next.flat {
118
- m.isFlat = next.flat ?? false
119
- }
125
+ if !prev.markerInfoWindowStyleEquals(next) {
126
+ m.tagData = MarkerTag(
127
+ id: next.id,
128
+ iconSvg: next.infoWindowIconSvg
129
+ )
130
+ }
120
131
 
121
- if prev.draggable != next.draggable {
122
- m.isDraggable = next.draggable ?? false
123
- }
132
+ if tracksViewChanges {
133
+ m.tracksViewChanges = tracksViewChanges
134
+ }
135
+ if tracksInfoWindowChanges {
136
+ m.tracksInfoWindowChanges = tracksInfoWindowChanges
137
+ }
124
138
 
125
- if prev.rotation != next.rotation {
126
- m.rotation = next.rotation ?? 0
127
- }
139
+ if tracksViewChanges || tracksInfoWindowChanges {
140
+ onMain { [weak m] in
141
+ guard let m = m else { return }
128
142
 
129
- if prev.zIndex != next.zIndex {
130
- m.zIndex = Int32(next.zIndex ?? 0)
131
- }
143
+ if tracksViewChanges {
144
+ m.tracksViewChanges = false
145
+ }
132
146
 
133
- if !prev.markerInfoWindowStyleEquals(next) {
134
- m.tagData = MarkerTag(
135
- id: next.id,
136
- iconSvg: next.infoWindowIconSvg
137
- )
147
+ if tracksInfoWindowChanges {
148
+ m.tracksInfoWindowChanges = false
149
+ }
150
+ }
151
+ }
138
152
  }
139
153
  }
140
154
 
@@ -170,9 +184,6 @@ final class MapMarkerBuilder {
170
184
 
171
185
  await MainActor.run {
172
186
  guard !Task.isCancelled else { return }
173
- }
174
-
175
- Task { @MainActor in
176
187
  onReady(img)
177
188
  }
178
189
  }
@@ -131,28 +131,26 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
131
131
  )
132
132
 
133
133
  let removed = Set(prevById.keys).subtracting(nextById.keys)
134
- withCATransaction(disableActions: true) {
135
134
 
136
- removed.forEach {
137
- self.impl.removeMarker(id: $0)
138
- self.markerBuilder.cancelIconTask($0)
139
- }
135
+ removed.forEach {
136
+ self.impl.removeMarker(id: $0)
137
+ self.markerBuilder.cancelIconTask($0)
138
+ }
140
139
 
141
- for (id, next) in nextById {
142
- if let prev = prevById[id] {
143
- if !prev.markerEquals(next) {
144
- self.impl.updateMarker(id: id) { [weak self] m in
145
- guard let self else { return }
146
- self.markerBuilder.update(prev, next, m)
147
- }
148
- }
149
- } else {
150
- self.markerBuilder.buildIconAsync(next) { [weak self] icon in
140
+ for (id, next) in nextById {
141
+ if let prev = prevById[id] {
142
+ if !prev.markerEquals(next) {
143
+ self.impl.updateMarker(id: id) { [weak self] m in
151
144
  guard let self else { return }
152
- let marker = self.markerBuilder.build(next, icon: icon)
153
- self.impl.addMarker(id: id, marker: marker)
145
+ self.markerBuilder.update(prev, next, m)
154
146
  }
155
147
  }
148
+ } else {
149
+ self.markerBuilder.buildIconAsync(next) { [weak self] icon in
150
+ guard let self else { return }
151
+ let marker = self.markerBuilder.build(next, icon: icon)
152
+ self.impl.addMarker(id: id, marker: marker)
153
+ }
156
154
  }
157
155
  }
158
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-maps-plus",
3
- "version": "1.7.0-dev.16",
3
+ "version": "1.7.0-dev.17",
4
4
  "description": "React Native wrapper for Android & iOS Google Maps SDK",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",