react-native-google-maps-plus 1.1.0-dev.2 → 1.1.0-dev.4
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/README.md +7 -5
- package/RNGoogleMapsPlus.podspec +2 -1
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +91 -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/MapHeatmapBuilder.kt +31 -0
- 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 +61 -71
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNHeatmapPointExtension.kt +9 -0
- package/ios/GoogleMapViewImpl.swift +129 -213
- package/ios/LocationHandler.swift +2 -10
- package/ios/MapCircleBuilder.swift +23 -8
- package/ios/MapHeatmapBuilder.swift +27 -0
- 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 +31 -14
- package/ios/extensions/RNCircle+Extension.swift +0 -13
- package/ios/extensions/RNHeatmap+Extension.swift +16 -0
- 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 +3 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +24 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +48 -15
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNCircle.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNHeatmap.hpp +100 -0
- package/nitrogen/generated/android/c++/JRNHeatmapGradient.hpp +89 -0
- package/nitrogen/generated/android/c++/JRNHeatmapPoint.hpp +61 -0
- package/nitrogen/generated/android/c++/JRNMapZoomConfig.hpp +57 -0
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmap.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmapGradient.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmapPoint.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapZoomConfig.kt +32 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +101 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +12 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +23 -11
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +9 -9
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +2 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +39 -19
- package/nitrogen/generated/ios/swift/RNCircle.swift +5 -17
- package/nitrogen/generated/ios/swift/RNHeatmap.swift +180 -0
- package/nitrogen/generated/ios/swift/RNHeatmapGradient.swift +81 -0
- package/nitrogen/generated/ios/swift/RNHeatmapPoint.swift +57 -0
- package/nitrogen/generated/ios/swift/RNMapZoomConfig.swift +70 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +4 -4
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +10 -4
- package/nitrogen/generated/shared/c++/RNCircle.hpp +5 -5
- package/nitrogen/generated/shared/c++/RNHeatmap.hpp +98 -0
- package/nitrogen/generated/shared/c++/RNHeatmapGradient.hpp +76 -0
- package/nitrogen/generated/shared/c++/RNHeatmapPoint.hpp +75 -0
- package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +71 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +19 -19
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +4 -2
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +2 -2
- package/package.json +12 -12
- package/src/RNGoogleMapsPlusView.nitro.ts +4 -2
- package/src/types.ts +28 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CoreLocation
|
|
2
2
|
import GoogleMaps
|
|
3
|
+
import GoogleMapsUtils
|
|
3
4
|
import UIKit
|
|
4
5
|
|
|
5
6
|
final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
@@ -14,11 +15,13 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
14
15
|
private var pendingPolylines: [(id: String, polyline: GMSPolyline)] = []
|
|
15
16
|
private var pendingPolygons: [(id: String, polygon: GMSPolygon)] = []
|
|
16
17
|
private var pendingCircles: [(id: String, circle: GMSCircle)] = []
|
|
18
|
+
private var pendingHeatmaps: [(id: String, heatmap: GMUHeatmapTileLayer)] = []
|
|
17
19
|
|
|
18
20
|
private var markersById: [String: GMSMarker] = [:]
|
|
19
21
|
private var polylinesById: [String: GMSPolyline] = [:]
|
|
20
22
|
private var polygonsById: [String: GMSPolygon] = [:]
|
|
21
23
|
private var circlesById: [String: GMSCircle] = [:]
|
|
24
|
+
private var heatmapsById: [String: GMUHeatmapTileLayer] = [:]
|
|
22
25
|
|
|
23
26
|
private var cameraMoveReasonIsGesture: Bool = false
|
|
24
27
|
private var lastSubmittedCameraPosition: GMSCameraPosition?
|
|
@@ -60,22 +63,16 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
60
63
|
initialized = true
|
|
61
64
|
let options = GMSMapViewOptions()
|
|
62
65
|
options.frame = bounds
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
if let camera = camera {
|
|
70
|
-
options.camera = camera
|
|
71
|
-
}
|
|
66
|
+
|
|
67
|
+
mapId.map { options.mapID = GMSMapID(identifier: $0) }
|
|
68
|
+
liteMode.map { _ in /* not supported */ }
|
|
69
|
+
camera.map { options.camera = $0 }
|
|
70
|
+
|
|
72
71
|
mapView = GMSMapView.init(options: options)
|
|
73
72
|
mapView?.delegate = self
|
|
74
73
|
mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
75
74
|
mapView?.paddingAdjustmentBehavior = .never
|
|
76
|
-
|
|
77
|
-
addSubview(mapView)
|
|
78
|
-
}
|
|
75
|
+
mapView.map { addSubview($0) }
|
|
79
76
|
initLocationCallbacks()
|
|
80
77
|
applyPending()
|
|
81
78
|
onMapReady?(true)
|
|
@@ -109,97 +106,53 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
109
106
|
|
|
110
107
|
@MainActor
|
|
111
108
|
private func applyPending() {
|
|
112
|
-
|
|
113
|
-
if let padding = mapPadding {
|
|
109
|
+
mapPadding.map {
|
|
114
110
|
mapView?.padding = UIEdgeInsets(
|
|
115
|
-
top:
|
|
116
|
-
left:
|
|
117
|
-
bottom:
|
|
118
|
-
right:
|
|
111
|
+
top: $0.top,
|
|
112
|
+
left: $0.left,
|
|
113
|
+
bottom: $0.bottom,
|
|
114
|
+
right: $0.right
|
|
119
115
|
)
|
|
120
116
|
}
|
|
121
117
|
|
|
122
|
-
if let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if let mapToolbarEnabled = uiSettings.mapToolbarEnabled {
|
|
133
|
-
/// not supported
|
|
118
|
+
if let v = uiSettings {
|
|
119
|
+
v.allGesturesEnabled.map { mapView?.settings.setAllGesturesEnabled($0) }
|
|
120
|
+
v.compassEnabled.map { mapView?.settings.compassButton = $0 }
|
|
121
|
+
v.indoorLevelPickerEnabled.map { mapView?.settings.indoorPicker = $0 }
|
|
122
|
+
v.mapToolbarEnabled.map { _ in /* not supported */ }
|
|
123
|
+
v.myLocationButtonEnabled.map { mapView?.settings.myLocationButton = $0 }
|
|
124
|
+
v.rotateEnabled.map { mapView?.settings.rotateGestures = $0 }
|
|
125
|
+
v.scrollEnabled.map { mapView?.settings.scrollGestures = $0 }
|
|
126
|
+
v.scrollDuringRotateOrZoomEnabled.map {
|
|
127
|
+
mapView?.settings.allowScrollGesturesDuringRotateOrZoom = $0
|
|
134
128
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
/// not supported
|
|
154
|
-
}
|
|
155
|
-
if let zoomGesturesEnabled = uiSettings.zoomGesturesEnabled {
|
|
156
|
-
mapView?.settings.zoomGestures = zoomGesturesEnabled
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if let myLocation = myLocationEnabled {
|
|
161
|
-
mapView?.isMyLocationEnabled = myLocation
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if let buildings = buildingEnabled {
|
|
165
|
-
mapView?.isBuildingsEnabled = buildings
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if let traffic = trafficEnabled {
|
|
169
|
-
mapView?.isTrafficEnabled = traffic
|
|
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))
|
|
129
|
+
v.tiltEnabled.map { mapView?.settings.tiltGestures = $0 }
|
|
130
|
+
v.zoomControlsEnabled.map { _ in /* not supported */ }
|
|
131
|
+
v.zoomGesturesEnabled.map { mapView?.settings.zoomGestures = $0 }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
myLocationEnabled.map { mapView?.isMyLocationEnabled = $0 }
|
|
135
|
+
buildingEnabled.map { mapView?.isBuildingsEnabled = $0 }
|
|
136
|
+
trafficEnabled.map { mapView?.isTrafficEnabled = $0 }
|
|
137
|
+
indoorEnabled.map { mapView?.isIndoorEnabled = $0 }
|
|
138
|
+
customMapStyle.map { mapView?.mapStyle = $0 }
|
|
139
|
+
mapType.map { mapView?.mapType = $0 }
|
|
140
|
+
userInterfaceStyle.map { mapView?.overrideUserInterfaceStyle = $0 }
|
|
141
|
+
|
|
142
|
+
mapZoomConfig.map {
|
|
143
|
+
mapView?.setMinZoom(
|
|
144
|
+
Float($0.min ?? 2),
|
|
145
|
+
maxZoom: Float($0.max ?? 21)
|
|
146
|
+
)
|
|
190
147
|
}
|
|
191
148
|
|
|
192
|
-
|
|
149
|
+
locationConfig.map {
|
|
193
150
|
locationHandler.desiredAccuracy =
|
|
194
|
-
|
|
195
|
-
locationHandler.distanceFilterMeters =
|
|
196
|
-
locationConfig.ios?.distanceFilterMeters
|
|
151
|
+
$0.ios?.desiredAccuracy?.toCLLocationAccuracy
|
|
152
|
+
locationHandler.distanceFilterMeters = $0.ios?.distanceFilterMeters
|
|
197
153
|
}
|
|
198
|
-
|
|
199
154
|
if !pendingMarkers.isEmpty {
|
|
200
|
-
pendingMarkers.forEach {
|
|
201
|
-
addMarkerInternal(id: $0.id, marker: $0.marker)
|
|
202
|
-
}
|
|
155
|
+
pendingMarkers.forEach { addMarkerInternal(id: $0.id, marker: $0.marker) }
|
|
203
156
|
pendingMarkers.removeAll()
|
|
204
157
|
}
|
|
205
158
|
if !pendingPolylines.isEmpty {
|
|
@@ -215,11 +168,15 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
215
168
|
pendingPolygons.removeAll()
|
|
216
169
|
}
|
|
217
170
|
if !pendingCircles.isEmpty {
|
|
218
|
-
pendingCircles.forEach {
|
|
219
|
-
addCircleInternal(id: $0.id, circle: $0.circle)
|
|
220
|
-
}
|
|
171
|
+
pendingCircles.forEach { addCircleInternal(id: $0.id, circle: $0.circle) }
|
|
221
172
|
pendingCircles.removeAll()
|
|
222
173
|
}
|
|
174
|
+
if !pendingHeatmaps.isEmpty {
|
|
175
|
+
pendingHeatmaps.forEach {
|
|
176
|
+
addHeatmapInternal(id: $0.id, heatmap: $0.heatmap)
|
|
177
|
+
}
|
|
178
|
+
pendingHeatmaps.removeAll()
|
|
179
|
+
}
|
|
223
180
|
}
|
|
224
181
|
|
|
225
182
|
var currentCamera: GMSCameraPosition? {
|
|
@@ -229,152 +186,86 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
229
186
|
@MainActor
|
|
230
187
|
var uiSettings: RNMapUiSettings? {
|
|
231
188
|
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
|
-
}
|
|
189
|
+
mapView?.settings.setAllGesturesEnabled(
|
|
190
|
+
uiSettings?.allGesturesEnabled ?? true
|
|
191
|
+
)
|
|
192
|
+
mapView?.settings.compassButton = uiSettings?.compassEnabled ?? false
|
|
193
|
+
mapView?.settings.indoorPicker =
|
|
194
|
+
uiSettings?.indoorLevelPickerEnabled ?? false
|
|
195
|
+
mapView?.settings.myLocationButton =
|
|
196
|
+
uiSettings?.myLocationButtonEnabled ?? false
|
|
197
|
+
mapView?.settings.rotateGestures = uiSettings?.rotateEnabled ?? true
|
|
198
|
+
mapView?.settings.scrollGestures = uiSettings?.scrollEnabled ?? true
|
|
199
|
+
mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
|
|
200
|
+
uiSettings?.scrollDuringRotateOrZoomEnabled ?? true
|
|
201
|
+
mapView?.settings.tiltGestures = uiSettings?.tiltEnabled ?? true
|
|
202
|
+
mapView?.settings.zoomGestures = uiSettings?.zoomGesturesEnabled ?? false
|
|
282
203
|
}
|
|
283
204
|
}
|
|
284
205
|
|
|
285
206
|
@MainActor
|
|
286
207
|
var myLocationEnabled: Bool? {
|
|
287
208
|
didSet {
|
|
288
|
-
|
|
289
|
-
mapView?.isMyLocationEnabled = value
|
|
290
|
-
} else {
|
|
291
|
-
mapView?.isMyLocationEnabled = false
|
|
292
|
-
}
|
|
209
|
+
mapView?.isMyLocationEnabled = myLocationEnabled ?? false
|
|
293
210
|
}
|
|
294
211
|
}
|
|
295
212
|
|
|
296
213
|
@MainActor
|
|
297
214
|
var buildingEnabled: Bool? {
|
|
298
215
|
didSet {
|
|
299
|
-
|
|
300
|
-
mapView?.isBuildingsEnabled = value
|
|
301
|
-
} else {
|
|
302
|
-
mapView?.isBuildingsEnabled = false
|
|
303
|
-
}
|
|
216
|
+
mapView?.isBuildingsEnabled = buildingEnabled ?? false
|
|
304
217
|
}
|
|
305
218
|
}
|
|
306
219
|
|
|
307
220
|
@MainActor
|
|
308
221
|
var trafficEnabled: Bool? {
|
|
309
222
|
didSet {
|
|
310
|
-
|
|
311
|
-
mapView?.isTrafficEnabled = value
|
|
312
|
-
} else {
|
|
313
|
-
mapView?.isTrafficEnabled = false
|
|
314
|
-
}
|
|
223
|
+
mapView?.isTrafficEnabled = false
|
|
315
224
|
}
|
|
316
225
|
}
|
|
317
226
|
|
|
318
227
|
@MainActor
|
|
319
228
|
var indoorEnabled: Bool? {
|
|
320
229
|
didSet {
|
|
321
|
-
|
|
322
|
-
mapView?.isIndoorEnabled = value
|
|
323
|
-
} else {
|
|
324
|
-
mapView?.isIndoorEnabled = false
|
|
325
|
-
}
|
|
230
|
+
mapView?.isIndoorEnabled = indoorEnabled ?? false
|
|
326
231
|
}
|
|
327
232
|
}
|
|
328
233
|
|
|
329
234
|
@MainActor
|
|
330
235
|
var customMapStyle: GMSMapStyle? {
|
|
331
236
|
didSet {
|
|
332
|
-
|
|
333
|
-
mapView?.mapStyle = style
|
|
334
|
-
}
|
|
237
|
+
mapView?.mapStyle = customMapStyle
|
|
335
238
|
}
|
|
336
239
|
}
|
|
337
240
|
|
|
338
241
|
@MainActor
|
|
339
242
|
var userInterfaceStyle: UIUserInterfaceStyle? {
|
|
340
243
|
didSet {
|
|
341
|
-
|
|
342
|
-
mapView?.overrideUserInterfaceStyle = style
|
|
343
|
-
}
|
|
244
|
+
mapView?.overrideUserInterfaceStyle = userInterfaceStyle ?? .unspecified
|
|
344
245
|
}
|
|
345
246
|
}
|
|
346
247
|
|
|
347
248
|
@MainActor
|
|
348
|
-
var
|
|
249
|
+
var mapZoomConfig: RNMapZoomConfig? {
|
|
349
250
|
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
|
-
}
|
|
251
|
+
mapView?.setMinZoom(
|
|
252
|
+
Float(mapZoomConfig?.min ?? 2),
|
|
253
|
+
maxZoom: Float(mapZoomConfig?.max ?? 21)
|
|
254
|
+
)
|
|
362
255
|
}
|
|
363
256
|
}
|
|
364
257
|
|
|
365
|
-
@MainActor
|
|
366
|
-
var mapPadding: RNMapPadding? {
|
|
258
|
+
@MainActor var mapPadding: RNMapPadding? {
|
|
367
259
|
didSet {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
260
|
+
mapView?.padding =
|
|
261
|
+
mapPadding.map {
|
|
262
|
+
UIEdgeInsets(
|
|
263
|
+
top: $0.top,
|
|
264
|
+
left: $0.left,
|
|
265
|
+
bottom: $0.bottom,
|
|
266
|
+
right: $0.right
|
|
267
|
+
)
|
|
268
|
+
} ?? .zero
|
|
378
269
|
}
|
|
379
270
|
}
|
|
380
271
|
|
|
@@ -475,7 +366,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
475
366
|
pendingMarkers.append((id, marker))
|
|
476
367
|
return
|
|
477
368
|
}
|
|
478
|
-
|
|
369
|
+
markersById.removeValue(forKey: id).map { $0.map = nil }
|
|
479
370
|
addMarkerInternal(id: id, marker: marker)
|
|
480
371
|
}
|
|
481
372
|
|
|
@@ -488,13 +379,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
488
379
|
|
|
489
380
|
@MainActor
|
|
490
381
|
func updateMarker(id: String, block: @escaping (GMSMarker) -> Void) {
|
|
491
|
-
|
|
492
|
-
block(m)
|
|
382
|
+
markersById[id].map { block($0) }
|
|
493
383
|
}
|
|
494
384
|
|
|
495
385
|
@MainActor
|
|
496
386
|
func removeMarker(id: String) {
|
|
497
|
-
|
|
387
|
+
markersById.removeValue(forKey: id).map { $0.map = nil }
|
|
498
388
|
}
|
|
499
389
|
|
|
500
390
|
@MainActor
|
|
@@ -510,7 +400,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
510
400
|
pendingPolylines.append((id, polyline))
|
|
511
401
|
return
|
|
512
402
|
}
|
|
513
|
-
|
|
403
|
+
polylinesById.removeValue(forKey: id).map { $0.map = nil }
|
|
514
404
|
addPolylineInternal(id: id, polyline: polyline)
|
|
515
405
|
}
|
|
516
406
|
|
|
@@ -523,13 +413,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
523
413
|
|
|
524
414
|
@MainActor
|
|
525
415
|
func updatePolyline(id: String, block: @escaping (GMSPolyline) -> Void) {
|
|
526
|
-
|
|
527
|
-
block(pl)
|
|
416
|
+
polylinesById[id].map { block($0) }
|
|
528
417
|
}
|
|
529
418
|
|
|
530
419
|
@MainActor
|
|
531
420
|
func removePolyline(id: String) {
|
|
532
|
-
|
|
421
|
+
polylinesById.removeValue(forKey: id).map { $0.map = nil }
|
|
533
422
|
}
|
|
534
423
|
|
|
535
424
|
@MainActor
|
|
@@ -545,7 +434,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
545
434
|
pendingPolygons.append((id, polygon))
|
|
546
435
|
return
|
|
547
436
|
}
|
|
548
|
-
|
|
437
|
+
polygonsById.removeValue(forKey: id).map { $0.map = nil }
|
|
549
438
|
addPolygonInternal(id: id, polygon: polygon)
|
|
550
439
|
}
|
|
551
440
|
|
|
@@ -558,13 +447,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
558
447
|
|
|
559
448
|
@MainActor
|
|
560
449
|
func updatePolygon(id: String, block: @escaping (GMSPolygon) -> Void) {
|
|
561
|
-
|
|
562
|
-
block(pg)
|
|
450
|
+
polygonsById[id].map { block($0) }
|
|
563
451
|
}
|
|
564
452
|
|
|
565
453
|
@MainActor
|
|
566
454
|
func removePolygon(id: String) {
|
|
567
|
-
|
|
455
|
+
polygonsById.removeValue(forKey: id).map { $0.map = nil }
|
|
568
456
|
}
|
|
569
457
|
|
|
570
458
|
@MainActor
|
|
@@ -580,7 +468,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
580
468
|
pendingCircles.append((id, circle))
|
|
581
469
|
return
|
|
582
470
|
}
|
|
583
|
-
|
|
471
|
+
circlesById.removeValue(forKey: id).map { $0.map = nil }
|
|
584
472
|
addCircleInternal(id: id, circle: circle)
|
|
585
473
|
}
|
|
586
474
|
|
|
@@ -593,13 +481,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
593
481
|
|
|
594
482
|
@MainActor
|
|
595
483
|
func updateCircle(id: String, block: @escaping (GMSCircle) -> Void) {
|
|
596
|
-
|
|
597
|
-
block(circle)
|
|
484
|
+
circlesById[id].map { block($0) }
|
|
598
485
|
}
|
|
599
486
|
|
|
600
487
|
@MainActor
|
|
601
488
|
func removeCircle(id: String) {
|
|
602
|
-
|
|
489
|
+
circlesById.removeValue(forKey: id).map { $0.map = nil }
|
|
603
490
|
}
|
|
604
491
|
|
|
605
492
|
@MainActor
|
|
@@ -609,12 +496,41 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
609
496
|
pendingCircles.removeAll()
|
|
610
497
|
}
|
|
611
498
|
|
|
499
|
+
@MainActor
|
|
500
|
+
func addHeatmap(id: String, heatmap: GMUHeatmapTileLayer) {
|
|
501
|
+
if mapView == nil {
|
|
502
|
+
pendingHeatmaps.append((id, heatmap))
|
|
503
|
+
return
|
|
504
|
+
}
|
|
505
|
+
heatmapsById.removeValue(forKey: id).map { $0.map = nil }
|
|
506
|
+
addHeatmapInternal(id: id, heatmap: heatmap)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
@MainActor
|
|
510
|
+
private func addHeatmapInternal(id: String, heatmap: GMUHeatmapTileLayer) {
|
|
511
|
+
heatmap.map = mapView
|
|
512
|
+
heatmapsById[id] = heatmap
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
@MainActor
|
|
516
|
+
func removeHeatmap(id: String) {
|
|
517
|
+
heatmapsById.removeValue(forKey: id).map { $0.map = nil }
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
@MainActor
|
|
521
|
+
func clearHeatmaps() {
|
|
522
|
+
heatmapsById.values.forEach { $0.map = nil }
|
|
523
|
+
heatmapsById.removeAll()
|
|
524
|
+
pendingHeatmaps.removeAll()
|
|
525
|
+
}
|
|
526
|
+
|
|
612
527
|
func deinitInternal() {
|
|
613
528
|
markerBuilder.cancelAllIconTasks()
|
|
614
529
|
clearMarkers()
|
|
615
530
|
clearPolylines()
|
|
616
531
|
clearPolygons()
|
|
617
532
|
clearCircles()
|
|
533
|
+
clearHeatmaps()
|
|
618
534
|
locationHandler.stop()
|
|
619
535
|
mapView?.clear()
|
|
620
536
|
mapView?.delegate = nil
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import GoogleMaps
|
|
3
|
+
import GoogleMapsUtils
|
|
4
|
+
import UIKit
|
|
5
|
+
|
|
6
|
+
final class MapHeatmapBuilder {
|
|
7
|
+
func build(_ h: RNHeatmap) -> GMUHeatmapTileLayer {
|
|
8
|
+
let heatmap = GMUHeatmapTileLayer()
|
|
9
|
+
heatmap.weightedData = h.weightedData.toWeightedLatLngs()
|
|
10
|
+
|
|
11
|
+
h.radius.map { heatmap.radius = UInt($0) }
|
|
12
|
+
h.opacity.map { heatmap.opacity = Float($0) }
|
|
13
|
+
h.zIndex.map { heatmap.zIndex = Int32($0) }
|
|
14
|
+
|
|
15
|
+
h.gradient.map { g in
|
|
16
|
+
let colors = g.colors.map { $0.toUIColor() }
|
|
17
|
+
let startPoints = g.startPoints.map { NSNumber(value: $0) }
|
|
18
|
+
heatmap.gradient = GMUGradient(
|
|
19
|
+
colors: colors,
|
|
20
|
+
startPoints: startPoints,
|
|
21
|
+
colorMapSize: 256
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return heatmap
|
|
26
|
+
}
|
|
27
|
+
}
|
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
|
}
|