react-native-google-maps-plus 1.1.0-dev.2 → 1.1.0-dev.3
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.
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +37 -102
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +3 -3
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +16 -2
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +25 -0
- package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +18 -1
- package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +26 -9
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +46 -72
- package/ios/GoogleMapViewImpl.swift +94 -212
- package/ios/LocationHandler.swift +2 -10
- package/ios/MapCircleBuilder.swift +23 -8
- package/ios/MapHelper.swift +6 -4
- package/ios/MapMarkerBuilder.swift +39 -41
- package/ios/MapPolygonBuilder.swift +25 -7
- package/ios/MapPolylineBuilder.swift +27 -11
- package/ios/RNGoogleMapsPlusView.swift +9 -14
- package/ios/extensions/RNCircle+Extension.swift +0 -13
- package/ios/extensions/RNPolygon+Extension.swift.swift +2 -19
- package/ios/extensions/RNPolyline+Extension.swift.swift +1 -26
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +2 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +5 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +10 -15
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +2 -4
- package/nitrogen/generated/android/c++/JRNCircle.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNMapZoomConfig.hpp +57 -0
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +2 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +1 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapZoomConfig.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +1 -1
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +13 -13
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +57 -33
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +8 -12
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +4 -9
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +1 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +46 -94
- package/nitrogen/generated/ios/swift/RNCamera.swift +1 -8
- package/nitrogen/generated/ios/swift/RNCircle.swift +5 -17
- package/nitrogen/generated/ios/swift/RNInitialProps.swift +1 -8
- package/nitrogen/generated/ios/swift/RNLocationConfig.swift +2 -16
- package/nitrogen/generated/ios/swift/RNMapZoomConfig.swift +70 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +2 -16
- package/nitrogen/generated/ios/swift/RNPolygon.swift +11 -15
- package/nitrogen/generated/ios/swift/RNPolyline.swift +11 -15
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +2 -4
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +5 -4
- package/nitrogen/generated/shared/c++/RNCircle.hpp +5 -5
- package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +71 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +7 -19
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +2 -2
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +1 -2
- package/package.json +13 -13
- package/src/RNGoogleMapsPlusView.nitro.ts +2 -2
- package/src/types.ts +6 -1
|
@@ -60,22 +60,16 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
60
60
|
initialized = true
|
|
61
61
|
let options = GMSMapViewOptions()
|
|
62
62
|
options.frame = bounds
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
if let camera = camera {
|
|
70
|
-
options.camera = camera
|
|
71
|
-
}
|
|
63
|
+
|
|
64
|
+
mapId.map { options.mapID = GMSMapID(identifier: $0) }
|
|
65
|
+
liteMode.map { _ in /* not supported */ }
|
|
66
|
+
camera.map { options.camera = $0 }
|
|
67
|
+
|
|
72
68
|
mapView = GMSMapView.init(options: options)
|
|
73
69
|
mapView?.delegate = self
|
|
74
70
|
mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
75
71
|
mapView?.paddingAdjustmentBehavior = .never
|
|
76
|
-
|
|
77
|
-
addSubview(mapView)
|
|
78
|
-
}
|
|
72
|
+
mapView.map { addSubview($0) }
|
|
79
73
|
initLocationCallbacks()
|
|
80
74
|
applyPending()
|
|
81
75
|
onMapReady?(true)
|
|
@@ -109,115 +103,73 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
109
103
|
|
|
110
104
|
@MainActor
|
|
111
105
|
private func applyPending() {
|
|
112
|
-
|
|
113
|
-
if let padding = mapPadding {
|
|
106
|
+
mapPadding.map {
|
|
114
107
|
mapView?.padding = UIEdgeInsets(
|
|
115
|
-
top:
|
|
116
|
-
left:
|
|
117
|
-
bottom:
|
|
118
|
-
right:
|
|
108
|
+
top: $0.top,
|
|
109
|
+
left: $0.left,
|
|
110
|
+
bottom: $0.bottom,
|
|
111
|
+
right: $0.right
|
|
119
112
|
)
|
|
120
113
|
}
|
|
121
114
|
|
|
122
|
-
if let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if let mapToolbarEnabled = uiSettings.mapToolbarEnabled {
|
|
133
|
-
/// not supported
|
|
134
|
-
}
|
|
135
|
-
if let myLocationButtonEnabled = uiSettings.myLocationButtonEnabled {
|
|
136
|
-
mapView?.settings.myLocationButton = myLocationButtonEnabled
|
|
137
|
-
}
|
|
138
|
-
if let rotateEnabled = uiSettings.rotateEnabled {
|
|
139
|
-
mapView?.settings.rotateGestures = rotateEnabled
|
|
140
|
-
}
|
|
141
|
-
if let scrollEnabled = uiSettings.scrollEnabled {
|
|
142
|
-
mapView?.settings.scrollGestures = scrollEnabled
|
|
143
|
-
}
|
|
144
|
-
if let scrollDuringRotateOrZoomEnabled = uiSettings
|
|
145
|
-
.scrollDuringRotateOrZoomEnabled {
|
|
146
|
-
mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
|
|
147
|
-
scrollDuringRotateOrZoomEnabled
|
|
148
|
-
}
|
|
149
|
-
if let tiltEnabled = uiSettings.tiltEnabled {
|
|
150
|
-
mapView?.settings.tiltGestures = tiltEnabled
|
|
115
|
+
if let v = uiSettings {
|
|
116
|
+
v.allGesturesEnabled.map { mapView?.settings.setAllGesturesEnabled($0) }
|
|
117
|
+
v.compassEnabled.map { mapView?.settings.compassButton = $0 }
|
|
118
|
+
v.indoorLevelPickerEnabled.map { mapView?.settings.indoorPicker = $0 }
|
|
119
|
+
v.mapToolbarEnabled.map { _ in /* not supported */ }
|
|
120
|
+
v.myLocationButtonEnabled.map { mapView?.settings.myLocationButton = $0 }
|
|
121
|
+
v.rotateEnabled.map { mapView?.settings.rotateGestures = $0 }
|
|
122
|
+
v.scrollEnabled.map { mapView?.settings.scrollGestures = $0 }
|
|
123
|
+
v.scrollDuringRotateOrZoomEnabled.map {
|
|
124
|
+
mapView?.settings.allowScrollGesturesDuringRotateOrZoom = $0
|
|
151
125
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if let indoor = indoorEnabled {
|
|
173
|
-
mapView?.isIndoorEnabled = indoor
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if let style = customMapStyle {
|
|
177
|
-
mapView?.mapStyle = style
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if let mapType = mapType {
|
|
181
|
-
mapView?.mapType = mapType
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if let uiStyle = userInterfaceStyle {
|
|
185
|
-
mapView?.overrideUserInterfaceStyle = uiStyle
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if let minZoom = minZoomLevel, let maxZoom = maxZoomLevel {
|
|
189
|
-
mapView?.setMinZoom(Float(minZoom), maxZoom: Float(maxZoom))
|
|
126
|
+
v.tiltEnabled.map { mapView?.settings.tiltGestures = $0 }
|
|
127
|
+
v.zoomControlsEnabled.map { _ in /* not supported */ }
|
|
128
|
+
v.zoomGesturesEnabled.map { mapView?.settings.zoomGestures = $0 }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
myLocationEnabled.map { mapView?.isMyLocationEnabled = $0 }
|
|
132
|
+
buildingEnabled.map { mapView?.isBuildingsEnabled = $0 }
|
|
133
|
+
trafficEnabled.map { mapView?.isTrafficEnabled = $0 }
|
|
134
|
+
indoorEnabled.map { mapView?.isIndoorEnabled = $0 }
|
|
135
|
+
customMapStyle.map { mapView?.mapStyle = $0 }
|
|
136
|
+
mapType.map { mapView?.mapType = $0 }
|
|
137
|
+
userInterfaceStyle.map { mapView?.overrideUserInterfaceStyle = $0 }
|
|
138
|
+
|
|
139
|
+
mapZoomConfig.map {
|
|
140
|
+
mapView?.setMinZoom(
|
|
141
|
+
Float($0.min ?? 2),
|
|
142
|
+
maxZoom: Float($0.max ?? 21)
|
|
143
|
+
)
|
|
190
144
|
}
|
|
191
145
|
|
|
192
|
-
|
|
146
|
+
locationConfig.map {
|
|
193
147
|
locationHandler.desiredAccuracy =
|
|
194
|
-
|
|
195
|
-
locationHandler.distanceFilterMeters =
|
|
196
|
-
locationConfig.ios?.distanceFilterMeters
|
|
148
|
+
$0.ios?.desiredAccuracy?.toCLLocationAccuracy
|
|
149
|
+
locationHandler.distanceFilterMeters = $0.ios?.distanceFilterMeters
|
|
197
150
|
}
|
|
198
151
|
|
|
199
152
|
if !pendingMarkers.isEmpty {
|
|
200
|
-
pendingMarkers.forEach {
|
|
201
|
-
addMarkerInternal(id: $0.id, marker: $0.marker)
|
|
202
|
-
}
|
|
153
|
+
pendingMarkers.forEach { addMarkerInternal(id: $0.id, marker: $0.marker) }
|
|
203
154
|
pendingMarkers.removeAll()
|
|
204
155
|
}
|
|
156
|
+
|
|
205
157
|
if !pendingPolylines.isEmpty {
|
|
206
158
|
pendingPolylines.forEach {
|
|
207
159
|
addPolylineInternal(id: $0.id, polyline: $0.polyline)
|
|
208
160
|
}
|
|
209
161
|
pendingPolylines.removeAll()
|
|
210
162
|
}
|
|
163
|
+
|
|
211
164
|
if !pendingPolygons.isEmpty {
|
|
212
165
|
pendingPolygons.forEach {
|
|
213
166
|
addPolygonInternal(id: $0.id, polygon: $0.polygon)
|
|
214
167
|
}
|
|
215
168
|
pendingPolygons.removeAll()
|
|
216
169
|
}
|
|
170
|
+
|
|
217
171
|
if !pendingCircles.isEmpty {
|
|
218
|
-
pendingCircles.forEach {
|
|
219
|
-
addCircleInternal(id: $0.id, circle: $0.circle)
|
|
220
|
-
}
|
|
172
|
+
pendingCircles.forEach { addCircleInternal(id: $0.id, circle: $0.circle) }
|
|
221
173
|
pendingCircles.removeAll()
|
|
222
174
|
}
|
|
223
175
|
}
|
|
@@ -229,152 +181,86 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
229
181
|
@MainActor
|
|
230
182
|
var uiSettings: RNMapUiSettings? {
|
|
231
183
|
didSet {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
/// not supported
|
|
247
|
-
}
|
|
248
|
-
if let myLocationButtonEnabled = v.myLocationButtonEnabled {
|
|
249
|
-
settings.myLocationButton = myLocationButtonEnabled
|
|
250
|
-
}
|
|
251
|
-
if let rotateEnabled = v.rotateEnabled {
|
|
252
|
-
settings.rotateGestures = rotateEnabled
|
|
253
|
-
}
|
|
254
|
-
if let scrollEnabled = v.scrollEnabled {
|
|
255
|
-
settings.scrollGestures = scrollEnabled
|
|
256
|
-
}
|
|
257
|
-
if let scrollDuringRotateOrZoomEnabled = v
|
|
258
|
-
.scrollDuringRotateOrZoomEnabled {
|
|
259
|
-
settings.allowScrollGesturesDuringRotateOrZoom =
|
|
260
|
-
scrollDuringRotateOrZoomEnabled
|
|
261
|
-
}
|
|
262
|
-
if let tiltEnabled = v.tiltEnabled {
|
|
263
|
-
settings.tiltGestures = tiltEnabled
|
|
264
|
-
}
|
|
265
|
-
if let zoomControlsEnabled = v.zoomControlsEnabled {
|
|
266
|
-
/// not supported
|
|
267
|
-
}
|
|
268
|
-
if let zoomGesturesEnabled = v.zoomGesturesEnabled {
|
|
269
|
-
settings.zoomGestures = zoomGesturesEnabled
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
settings.setAllGesturesEnabled(true)
|
|
273
|
-
settings.compassButton = false
|
|
274
|
-
settings.indoorPicker = false
|
|
275
|
-
settings.myLocationButton = false
|
|
276
|
-
settings.rotateGestures = true
|
|
277
|
-
settings.scrollGestures = true
|
|
278
|
-
settings.allowScrollGesturesDuringRotateOrZoom = true
|
|
279
|
-
settings.tiltGestures = true
|
|
280
|
-
settings.zoomGestures = false
|
|
281
|
-
}
|
|
184
|
+
mapView?.settings.setAllGesturesEnabled(
|
|
185
|
+
uiSettings?.allGesturesEnabled ?? true
|
|
186
|
+
)
|
|
187
|
+
mapView?.settings.compassButton = uiSettings?.compassEnabled ?? false
|
|
188
|
+
mapView?.settings.indoorPicker =
|
|
189
|
+
uiSettings?.indoorLevelPickerEnabled ?? false
|
|
190
|
+
mapView?.settings.myLocationButton =
|
|
191
|
+
uiSettings?.myLocationButtonEnabled ?? false
|
|
192
|
+
mapView?.settings.rotateGestures = uiSettings?.rotateEnabled ?? true
|
|
193
|
+
mapView?.settings.scrollGestures = uiSettings?.scrollEnabled ?? true
|
|
194
|
+
mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
|
|
195
|
+
uiSettings?.scrollDuringRotateOrZoomEnabled ?? true
|
|
196
|
+
mapView?.settings.tiltGestures = uiSettings?.tiltEnabled ?? true
|
|
197
|
+
mapView?.settings.zoomGestures = uiSettings?.zoomGesturesEnabled ?? false
|
|
282
198
|
}
|
|
283
199
|
}
|
|
284
200
|
|
|
285
201
|
@MainActor
|
|
286
202
|
var myLocationEnabled: Bool? {
|
|
287
203
|
didSet {
|
|
288
|
-
|
|
289
|
-
mapView?.isMyLocationEnabled = value
|
|
290
|
-
} else {
|
|
291
|
-
mapView?.isMyLocationEnabled = false
|
|
292
|
-
}
|
|
204
|
+
mapView?.isMyLocationEnabled = myLocationEnabled ?? false
|
|
293
205
|
}
|
|
294
206
|
}
|
|
295
207
|
|
|
296
208
|
@MainActor
|
|
297
209
|
var buildingEnabled: Bool? {
|
|
298
210
|
didSet {
|
|
299
|
-
|
|
300
|
-
mapView?.isBuildingsEnabled = value
|
|
301
|
-
} else {
|
|
302
|
-
mapView?.isBuildingsEnabled = false
|
|
303
|
-
}
|
|
211
|
+
mapView?.isBuildingsEnabled = buildingEnabled ?? false
|
|
304
212
|
}
|
|
305
213
|
}
|
|
306
214
|
|
|
307
215
|
@MainActor
|
|
308
216
|
var trafficEnabled: Bool? {
|
|
309
217
|
didSet {
|
|
310
|
-
|
|
311
|
-
mapView?.isTrafficEnabled = value
|
|
312
|
-
} else {
|
|
313
|
-
mapView?.isTrafficEnabled = false
|
|
314
|
-
}
|
|
218
|
+
mapView?.isTrafficEnabled = false
|
|
315
219
|
}
|
|
316
220
|
}
|
|
317
221
|
|
|
318
222
|
@MainActor
|
|
319
223
|
var indoorEnabled: Bool? {
|
|
320
224
|
didSet {
|
|
321
|
-
|
|
322
|
-
mapView?.isIndoorEnabled = value
|
|
323
|
-
} else {
|
|
324
|
-
mapView?.isIndoorEnabled = false
|
|
325
|
-
}
|
|
225
|
+
mapView?.isIndoorEnabled = indoorEnabled ?? false
|
|
326
226
|
}
|
|
327
227
|
}
|
|
328
228
|
|
|
329
229
|
@MainActor
|
|
330
230
|
var customMapStyle: GMSMapStyle? {
|
|
331
231
|
didSet {
|
|
332
|
-
|
|
333
|
-
mapView?.mapStyle = style
|
|
334
|
-
}
|
|
232
|
+
mapView?.mapStyle = customMapStyle
|
|
335
233
|
}
|
|
336
234
|
}
|
|
337
235
|
|
|
338
236
|
@MainActor
|
|
339
237
|
var userInterfaceStyle: UIUserInterfaceStyle? {
|
|
340
238
|
didSet {
|
|
341
|
-
|
|
342
|
-
mapView?.overrideUserInterfaceStyle = style
|
|
343
|
-
}
|
|
239
|
+
mapView?.overrideUserInterfaceStyle = userInterfaceStyle ?? .unspecified
|
|
344
240
|
}
|
|
345
241
|
}
|
|
346
242
|
|
|
347
243
|
@MainActor
|
|
348
|
-
var
|
|
244
|
+
var mapZoomConfig: RNMapZoomConfig? {
|
|
349
245
|
didSet {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
@MainActor
|
|
357
|
-
var maxZoomLevel: Double? {
|
|
358
|
-
didSet {
|
|
359
|
-
if let max = maxZoomLevel, let min = minZoomLevel {
|
|
360
|
-
mapView?.setMinZoom(Float(min), maxZoom: Float(max))
|
|
361
|
-
}
|
|
246
|
+
mapView?.setMinZoom(
|
|
247
|
+
Float(mapZoomConfig?.min ?? 2),
|
|
248
|
+
maxZoom: Float(mapZoomConfig?.max ?? 21)
|
|
249
|
+
)
|
|
362
250
|
}
|
|
363
251
|
}
|
|
364
252
|
|
|
365
|
-
@MainActor
|
|
366
|
-
var mapPadding: RNMapPadding? {
|
|
253
|
+
@MainActor var mapPadding: RNMapPadding? {
|
|
367
254
|
didSet {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
255
|
+
mapView?.padding =
|
|
256
|
+
mapPadding.map {
|
|
257
|
+
UIEdgeInsets(
|
|
258
|
+
top: $0.top,
|
|
259
|
+
left: $0.left,
|
|
260
|
+
bottom: $0.bottom,
|
|
261
|
+
right: $0.right
|
|
262
|
+
)
|
|
263
|
+
} ?? .zero
|
|
378
264
|
}
|
|
379
265
|
}
|
|
380
266
|
|
|
@@ -475,7 +361,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
475
361
|
pendingMarkers.append((id, marker))
|
|
476
362
|
return
|
|
477
363
|
}
|
|
478
|
-
|
|
364
|
+
markersById.removeValue(forKey: id).map { $0.map = nil }
|
|
479
365
|
addMarkerInternal(id: id, marker: marker)
|
|
480
366
|
}
|
|
481
367
|
|
|
@@ -488,13 +374,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
488
374
|
|
|
489
375
|
@MainActor
|
|
490
376
|
func updateMarker(id: String, block: @escaping (GMSMarker) -> Void) {
|
|
491
|
-
|
|
492
|
-
block(m)
|
|
377
|
+
markersById[id].map { block($0) }
|
|
493
378
|
}
|
|
494
379
|
|
|
495
380
|
@MainActor
|
|
496
381
|
func removeMarker(id: String) {
|
|
497
|
-
|
|
382
|
+
markersById.removeValue(forKey: id).map { $0.map = nil }
|
|
498
383
|
}
|
|
499
384
|
|
|
500
385
|
@MainActor
|
|
@@ -510,7 +395,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
510
395
|
pendingPolylines.append((id, polyline))
|
|
511
396
|
return
|
|
512
397
|
}
|
|
513
|
-
|
|
398
|
+
polylinesById.removeValue(forKey: id).map { $0.map = nil }
|
|
514
399
|
addPolylineInternal(id: id, polyline: polyline)
|
|
515
400
|
}
|
|
516
401
|
|
|
@@ -523,13 +408,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
523
408
|
|
|
524
409
|
@MainActor
|
|
525
410
|
func updatePolyline(id: String, block: @escaping (GMSPolyline) -> Void) {
|
|
526
|
-
|
|
527
|
-
block(pl)
|
|
411
|
+
polylinesById[id].map { block($0) }
|
|
528
412
|
}
|
|
529
413
|
|
|
530
414
|
@MainActor
|
|
531
415
|
func removePolyline(id: String) {
|
|
532
|
-
|
|
416
|
+
polylinesById.removeValue(forKey: id).map { $0.map = nil }
|
|
533
417
|
}
|
|
534
418
|
|
|
535
419
|
@MainActor
|
|
@@ -545,7 +429,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
545
429
|
pendingPolygons.append((id, polygon))
|
|
546
430
|
return
|
|
547
431
|
}
|
|
548
|
-
|
|
432
|
+
polygonsById.removeValue(forKey: id).map { $0.map = nil }
|
|
549
433
|
addPolygonInternal(id: id, polygon: polygon)
|
|
550
434
|
}
|
|
551
435
|
|
|
@@ -558,13 +442,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
558
442
|
|
|
559
443
|
@MainActor
|
|
560
444
|
func updatePolygon(id: String, block: @escaping (GMSPolygon) -> Void) {
|
|
561
|
-
|
|
562
|
-
block(pg)
|
|
445
|
+
polygonsById[id].map { block($0) }
|
|
563
446
|
}
|
|
564
447
|
|
|
565
448
|
@MainActor
|
|
566
449
|
func removePolygon(id: String) {
|
|
567
|
-
|
|
450
|
+
polygonsById.removeValue(forKey: id).map { $0.map = nil }
|
|
568
451
|
}
|
|
569
452
|
|
|
570
453
|
@MainActor
|
|
@@ -580,7 +463,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
580
463
|
pendingCircles.append((id, circle))
|
|
581
464
|
return
|
|
582
465
|
}
|
|
583
|
-
|
|
466
|
+
circlesById.removeValue(forKey: id).map { $0.map = nil }
|
|
584
467
|
addCircleInternal(id: id, circle: circle)
|
|
585
468
|
}
|
|
586
469
|
|
|
@@ -593,13 +476,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
593
476
|
|
|
594
477
|
@MainActor
|
|
595
478
|
func updateCircle(id: String, block: @escaping (GMSCircle) -> Void) {
|
|
596
|
-
|
|
597
|
-
block(circle)
|
|
479
|
+
circlesById[id].map { block($0) }
|
|
598
480
|
}
|
|
599
481
|
|
|
600
482
|
@MainActor
|
|
601
483
|
func removeCircle(id: String) {
|
|
602
|
-
|
|
484
|
+
circlesById.removeValue(forKey: id).map { $0.map = nil }
|
|
603
485
|
}
|
|
604
486
|
|
|
605
487
|
@MainActor
|
|
@@ -13,21 +13,13 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
|
|
|
13
13
|
|
|
14
14
|
var desiredAccuracy: CLLocationAccuracy? = kCLLocationAccuracyDefault {
|
|
15
15
|
didSet {
|
|
16
|
-
|
|
17
|
-
manager.desiredAccuracy = desiredAccuracy
|
|
18
|
-
} else {
|
|
19
|
-
manager.desiredAccuracy = kCLLocationAccuracyBest
|
|
20
|
-
}
|
|
16
|
+
manager.desiredAccuracy = desiredAccuracy ?? kCLLocationAccuracyBest
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
var distanceFilterMeters: CLLocationDistance? = kCLDistanceFilterNoneDefault {
|
|
25
21
|
didSet {
|
|
26
|
-
|
|
27
|
-
manager.distanceFilter = distanceFilterMeters
|
|
28
|
-
} else {
|
|
29
|
-
manager.distanceFilter = kCLDistanceFilterNone
|
|
30
|
-
}
|
|
22
|
+
manager.distanceFilter = distanceFilterMeters ?? kCLDistanceFilterNone
|
|
31
23
|
}
|
|
32
24
|
}
|
|
33
25
|
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import GoogleMaps
|
|
2
2
|
|
|
3
3
|
final class MapCircleBuilder {
|
|
4
|
-
|
|
5
|
-
func buildCircle(_ c: RNCircle) -> GMSCircle {
|
|
4
|
+
func build(_ c: RNCircle) -> GMSCircle {
|
|
6
5
|
let circle = GMSCircle()
|
|
7
6
|
circle.position = CLLocationCoordinate2D(
|
|
8
7
|
latitude: c.center.latitude,
|
|
9
8
|
longitude: c.center.longitude
|
|
10
9
|
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
|
|
11
|
+
circle.radius = c.radius
|
|
12
|
+
c.fillColor.map { circle.fillColor = $0.toUIColor() }
|
|
13
|
+
c.strokeColor.map { circle.strokeColor = $0.toUIColor() }
|
|
14
|
+
c.strokeWidth.map { circle.strokeWidth = CGFloat($0) }
|
|
15
|
+
c.pressable.map { circle.isTappable = $0 }
|
|
16
|
+
c.zIndex.map { circle.zIndex = Int32($0) }
|
|
17
17
|
|
|
18
18
|
return circle
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
func update(_ next: RNCircle, _ c: GMSCircle) {
|
|
22
|
+
c.position = CLLocationCoordinate2D(
|
|
23
|
+
latitude: next.center.latitude,
|
|
24
|
+
longitude: next.center.longitude
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
c.radius = next.radius
|
|
28
|
+
c.fillColor = next.fillColor?.toUIColor() ?? nil
|
|
29
|
+
c.strokeColor = next.strokeColor?.toUIColor() ?? .black
|
|
30
|
+
c.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
|
|
31
|
+
c.isTappable = next.pressable ?? false
|
|
32
|
+
c.zIndex = Int32(next.zIndex ?? 0)
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
}
|
package/ios/MapHelper.swift
CHANGED
|
@@ -9,10 +9,12 @@ func withCATransaction(
|
|
|
9
9
|
_ body: () -> Void
|
|
10
10
|
) {
|
|
11
11
|
CATransaction.begin()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
CATransaction.setDisableActions(disableActions)
|
|
14
|
+
duration.map { CATransaction.setAnimationDuration($0) }
|
|
15
|
+
timingFunction.map { CATransaction.setAnimationTimingFunction($0) }
|
|
16
|
+
completion.map { CATransaction.setCompletionBlock($0) }
|
|
17
|
+
|
|
16
18
|
body()
|
|
17
19
|
CATransaction.commit()
|
|
18
20
|
}
|
|
@@ -25,13 +25,49 @@ final class MapMarkerBuilder {
|
|
|
25
25
|
x: m.anchor?.x ?? 0.5,
|
|
26
26
|
y: m.anchor?.y ?? 0.5
|
|
27
27
|
)
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
m.zIndex.map { marker.zIndex = Int32($0) }
|
|
30
|
+
|
|
29
31
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak marker] in
|
|
30
32
|
marker?.tracksViewChanges = false
|
|
31
33
|
}
|
|
34
|
+
|
|
32
35
|
return marker
|
|
33
36
|
}
|
|
34
37
|
|
|
38
|
+
@MainActor
|
|
39
|
+
func update(_ prev: RNMarker, _ next: RNMarker, _ m: GMSMarker) {
|
|
40
|
+
m.position = CLLocationCoordinate2D(
|
|
41
|
+
latitude: next.coordinate.latitude,
|
|
42
|
+
longitude: next.coordinate.longitude
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
m.zIndex = Int32(next.zIndex ?? 0)
|
|
46
|
+
|
|
47
|
+
m.groundAnchor = CGPoint(
|
|
48
|
+
x: next.anchor?.x ?? 0.5,
|
|
49
|
+
y: next.anchor?.y ?? 0.5
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if !prev.markerStyleEquals(next) {
|
|
53
|
+
buildIconAsync(next.id, next) { img in
|
|
54
|
+
m.tracksViewChanges = true
|
|
55
|
+
m.icon = img
|
|
56
|
+
|
|
57
|
+
if prev.anchor?.x != next.anchor?.x || prev.anchor?.y != next.anchor?.y {
|
|
58
|
+
m.groundAnchor = CGPoint(
|
|
59
|
+
x: next.anchor?.x ?? 0.5,
|
|
60
|
+
y: next.anchor?.y ?? 0.5
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak m] in
|
|
65
|
+
m?.tracksViewChanges = false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
35
71
|
@MainActor
|
|
36
72
|
func buildIconAsync(
|
|
37
73
|
_ id: String,
|
|
@@ -53,14 +89,10 @@ final class MapMarkerBuilder {
|
|
|
53
89
|
|
|
54
90
|
let task = Task(priority: .userInitiated) { [weak self] in
|
|
55
91
|
guard let self else { return }
|
|
56
|
-
defer {
|
|
57
|
-
self.tasks.removeValue(forKey: id)
|
|
58
|
-
}
|
|
92
|
+
defer { self.tasks.removeValue(forKey: id) }
|
|
59
93
|
|
|
60
94
|
let img = await self.renderUIImage(m)
|
|
61
|
-
guard let img, !Task.isCancelled else {
|
|
62
|
-
return
|
|
63
|
-
}
|
|
95
|
+
guard let img, !Task.isCancelled else { return }
|
|
64
96
|
|
|
65
97
|
self.iconCache.setObject(img, forKey: key)
|
|
66
98
|
|
|
@@ -68,44 +100,11 @@ final class MapMarkerBuilder {
|
|
|
68
100
|
guard !Task.isCancelled else { return }
|
|
69
101
|
onReady(img)
|
|
70
102
|
}
|
|
71
|
-
|
|
72
103
|
}
|
|
73
104
|
|
|
74
105
|
tasks[id] = task
|
|
75
106
|
}
|
|
76
107
|
|
|
77
|
-
@MainActor
|
|
78
|
-
func updateMarker(_ prev: RNMarker, _ next: RNMarker, _ m: GMSMarker) {
|
|
79
|
-
m.position = CLLocationCoordinate2D(
|
|
80
|
-
latitude: next.coordinate.latitude,
|
|
81
|
-
longitude: next.coordinate.longitude
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
if let zi = next.zIndex { m.zIndex = Int32(zi) }
|
|
85
|
-
|
|
86
|
-
m.groundAnchor = CGPoint(
|
|
87
|
-
x: next.anchor?.x ?? 0.5,
|
|
88
|
-
y: next.anchor?.y ?? 0.5
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
if !prev.markerStyleEquals(next) {
|
|
92
|
-
buildIconAsync(next.id, next) { img in
|
|
93
|
-
m.tracksViewChanges = true
|
|
94
|
-
m.icon = img
|
|
95
|
-
if prev.anchor?.x != next.anchor?.x || prev.anchor?.y != next.anchor?.y {
|
|
96
|
-
m.groundAnchor = CGPoint(
|
|
97
|
-
x: next.anchor?.x ?? 0.5,
|
|
98
|
-
y: next.anchor?.y ?? 0.5
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak m] in
|
|
103
|
-
m?.tracksViewChanges = false
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
108
|
func cancelIconTask(_ id: String) {
|
|
110
109
|
tasks[id]?.cancel()
|
|
111
110
|
tasks.removeValue(forKey: id)
|
|
@@ -181,5 +180,4 @@ final class MapMarkerBuilder {
|
|
|
181
180
|
onCancel: {}
|
|
182
181
|
)
|
|
183
182
|
}
|
|
184
|
-
|
|
185
183
|
}
|