react-native-google-maps-plus 1.0.2 → 1.1.0-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.
- package/README.md +127 -11
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +359 -139
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +44 -44
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +19 -0
- package/android/src/main/java/com/rngooglemapsplus/{MapMarker.kt → MapMarkerBuilder.kt} +7 -6
- package/android/src/main/java/com/rngooglemapsplus/{MapPolygon.kt → MapPolygonBuilder.kt} +4 -18
- package/android/src/main/java/com/rngooglemapsplus/{MapPolyline.kt → MapPolylineBuilder.kt.kt} +4 -19
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +145 -129
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNCameraExtension.kt +19 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNLocationPriorityExtension.kt +12 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNMapCircleExtension.kt +14 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolygonExtension.kt +20 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolylineExtension.kt +21 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNUserInterfaceExtension.kt +12 -0
- package/android/src/main/java/com/rngooglemapsplus/{Color.kt → extensions/StringExtension.kt} +1 -1
- package/android/src/main/java/com/rngooglemapsplus/extensions/ThrowableExtension.kt +38 -0
- package/ios/GoogleMapViewImpl.swift +348 -150
- package/ios/LocationHandler.swift +29 -69
- package/ios/MapCircleBuilder.swift +20 -0
- package/ios/{MapMarker.swift → MapMarkerBuilder.swift} +11 -42
- package/ios/MapPolygonBuilder.swift +20 -0
- package/ios/MapPolylineBuilder.swift +24 -0
- package/ios/PermissionHandler.swift +1 -1
- package/ios/RNGoogleMapsPlusModule.swift +1 -1
- package/ios/RNGoogleMapsPlusView.swift +159 -168
- package/ios/extensions/RNCamera+Extension.swift +22 -0
- package/ios/extensions/RNCircle+Extension.swift +24 -0
- package/ios/extensions/RNIOSLocationAccuracy+Extensions.swift +19 -0
- package/ios/extensions/RNMarker+Extension.swift +24 -0
- package/ios/{MapPolygon.swift → extensions/RNPolygon+Extension.swift.swift} +7 -23
- package/ios/extensions/RNPolyline+Extension.swift.swift +62 -0
- package/ios/extensions/RNUserInterface+Extension.swift +16 -0
- package/ios/{Color.swift → extensions/String+Extensions.swift} +20 -20
- package/lib/module/types.js +14 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +21 -12
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +59 -3
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +233 -69
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +40 -22
- package/nitrogen/generated/android/c++/JRNAndroidLocationConfig.hpp +63 -0
- package/nitrogen/generated/android/c++/JRNAndroidLocationPriority.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNCircle.hpp +84 -0
- package/nitrogen/generated/android/c++/JRNIOSLocationAccuracy.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNIOSLocationConfig.hpp +59 -0
- package/nitrogen/generated/android/c++/JRNInitialProps.hpp +66 -0
- package/nitrogen/generated/android/c++/JRNLocationConfig.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNMapType.hpp +68 -0
- package/nitrogen/generated/android/c++/JRNMapUiSettings.hpp +93 -0
- package/nitrogen/generated/android/c++/JRNMarker.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNPolygon.hpp +8 -4
- package/nitrogen/generated/android/c++/JRNPolyline.hpp +8 -4
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +40 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +89 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationConfig.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationPriority.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationAccuracy.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationConfig.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNInitialProps.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationConfig.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapUiSettings.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygon.kt +4 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolyline.kt +4 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +7 -1
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +296 -45
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +27 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +131 -37
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +61 -16
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +20 -11
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +378 -45
- package/nitrogen/generated/ios/swift/RNAndroidLocationConfig.swift +93 -0
- package/nitrogen/generated/ios/swift/RNAndroidLocationPriority.swift +48 -0
- package/nitrogen/generated/ios/swift/RNCircle.swift +198 -0
- package/nitrogen/generated/ios/swift/RNIOSLocationAccuracy.swift +48 -0
- package/nitrogen/generated/ios/swift/RNIOSLocationConfig.swift +70 -0
- package/nitrogen/generated/ios/swift/RNInitialProps.swift +107 -0
- package/nitrogen/generated/ios/swift/RNLocationConfig.swift +84 -0
- package/nitrogen/generated/ios/swift/RNMapType.swift +52 -0
- package/nitrogen/generated/ios/swift/RNMapUiSettings.swift +277 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +17 -5
- package/nitrogen/generated/ios/swift/RNPolygon.swift +40 -5
- package/nitrogen/generated/ios/swift/RNPolyline.swift +40 -5
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +20 -2
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +59 -26
- package/nitrogen/generated/shared/c++/RNAndroidLocationConfig.hpp +77 -0
- package/nitrogen/generated/shared/c++/RNAndroidLocationPriority.hpp +64 -0
- package/nitrogen/generated/shared/c++/RNCircle.hpp +98 -0
- package/nitrogen/generated/shared/c++/RNIOSLocationAccuracy.hpp +64 -0
- package/nitrogen/generated/shared/c++/RNIOSLocationConfig.hpp +73 -0
- package/nitrogen/generated/shared/c++/RNInitialProps.hpp +78 -0
- package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +76 -0
- package/nitrogen/generated/shared/c++/RNMapType.hpp +88 -0
- package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +107 -0
- package/nitrogen/generated/shared/c++/RNMarker.hpp +6 -6
- package/nitrogen/generated/shared/c++/RNPolygon.hpp +10 -6
- package/nitrogen/generated/shared/c++/RNPolyline.hpp +10 -6
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +138 -30
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +27 -13
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +10 -1
- package/package.json +5 -5
- package/src/RNGoogleMapsPlusView.nitro.ts +25 -11
- package/src/types.ts +67 -3
- package/ios/MapPolyline.swift +0 -83
|
@@ -8,90 +8,118 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
8
8
|
private let permissionHandler: PermissionHandler
|
|
9
9
|
private let locationHandler: LocationHandler
|
|
10
10
|
|
|
11
|
+
private let markerBuilder = MapMarkerBuilder()
|
|
12
|
+
private let polylineBuilder = MapPolylineBuilder()
|
|
13
|
+
private let polygonBuilder = MapPolygonBuilder()
|
|
14
|
+
private let circleBuilder = MapCircleBuilder()
|
|
15
|
+
|
|
11
16
|
private let impl: GoogleMapsViewImpl
|
|
12
17
|
|
|
13
18
|
var view: UIView {
|
|
14
19
|
return impl
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
private var currentCustomMapStyle: String = ""
|
|
18
|
-
private let markerOptions = MapMarkerOptions()
|
|
19
|
-
private let polylineOptions = MapPolylineOptions()
|
|
20
|
-
private let polygonOptions = MapPolygonOptions()
|
|
21
|
-
|
|
22
22
|
override init() {
|
|
23
23
|
self.permissionHandler = PermissionHandler()
|
|
24
24
|
self.locationHandler = LocationHandler()
|
|
25
25
|
self.impl = GoogleMapsViewImpl(
|
|
26
26
|
locationHandler: locationHandler,
|
|
27
|
-
|
|
27
|
+
markerBuilder: markerBuilder
|
|
28
28
|
)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/*
|
|
32
|
+
/// TODO: prepareForRecycle
|
|
33
|
+
override func prepareForRecycle() {
|
|
34
|
+
impl.clearAll()
|
|
35
|
+
}
|
|
36
|
+
*/
|
|
37
|
+
|
|
31
38
|
@MainActor
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
var initialProps: RNInitialProps? {
|
|
40
|
+
didSet {
|
|
41
|
+
impl.initMapView(
|
|
42
|
+
mapId: initialProps?.mapId,
|
|
43
|
+
liteMode: initialProps?.liteMode,
|
|
44
|
+
camera: initialProps?.camera?.toGMSCameraPosition(current: nil)
|
|
45
|
+
)
|
|
46
|
+
}
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
@MainActor
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
set { impl.trafficEnabled = newValue }
|
|
50
|
+
var uiSettings: RNMapUiSettings? {
|
|
51
|
+
didSet { impl.uiSettings = uiSettings }
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
@MainActor
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
set {
|
|
47
|
-
currentCustomMapStyle = newValue
|
|
48
|
-
impl.customMapStyle = try? GMSMapStyle(jsonString: newValue)
|
|
49
|
-
}
|
|
55
|
+
var myLocationEnabled: Bool? {
|
|
56
|
+
didSet { impl.myLocationEnabled = myLocationEnabled }
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
@MainActor
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
set { impl.initialCamera = mapCameraToGMSCamera(newValue) }
|
|
60
|
+
var buildingEnabled: Bool? {
|
|
61
|
+
didSet { impl.buildingEnabled = buildingEnabled }
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
@MainActor
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
var trafficEnabled: Bool? {
|
|
66
|
+
didSet { impl.trafficEnabled = trafficEnabled }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@MainActor
|
|
70
|
+
var indoorEnabled: Bool? {
|
|
71
|
+
didSet { impl.indoorEnabled = indoorEnabled }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@MainActor
|
|
75
|
+
var customMapStyle: String? {
|
|
76
|
+
didSet {
|
|
77
|
+
if let value = customMapStyle {
|
|
78
|
+
impl.customMapStyle = try? GMSMapStyle(jsonString: value)
|
|
79
|
+
}
|
|
65
80
|
}
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
@MainActor
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
var userInterfaceStyle: RNUserInterfaceStyle? {
|
|
85
|
+
didSet {
|
|
86
|
+
impl.userInterfaceStyle = userInterfaceStyle?.toUIUserInterfaceStyle
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@MainActor
|
|
91
|
+
var minZoomLevel: Double? {
|
|
92
|
+
didSet { impl.minZoomLevel = minZoomLevel }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@MainActor
|
|
96
|
+
var maxZoomLevel: Double? {
|
|
97
|
+
didSet { impl.maxZoomLevel = maxZoomLevel }
|
|
72
98
|
}
|
|
73
99
|
|
|
74
100
|
@MainActor
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
set { impl.maxZoomLevel = newValue }
|
|
101
|
+
var mapPadding: RNMapPadding? {
|
|
102
|
+
didSet { impl.mapPadding = mapPadding }
|
|
78
103
|
}
|
|
79
104
|
|
|
80
105
|
@MainActor
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
106
|
+
var mapType: RNMapType? {
|
|
107
|
+
didSet {
|
|
108
|
+
impl.mapType = mapType.map {
|
|
109
|
+
GMSMapViewType(rawValue: UInt($0.rawValue)) ?? .normal
|
|
110
|
+
}
|
|
111
|
+
}
|
|
84
112
|
}
|
|
85
113
|
|
|
86
114
|
@MainActor
|
|
87
|
-
var markers: [RNMarker]
|
|
115
|
+
var markers: [RNMarker]? {
|
|
88
116
|
didSet {
|
|
89
117
|
let prevById = Dictionary(
|
|
90
|
-
oldValue.map { ($0.id, $0) },
|
|
118
|
+
(oldValue ?? []).map { ($0.id, $0) },
|
|
91
119
|
uniquingKeysWith: { _, new in new }
|
|
92
120
|
)
|
|
93
121
|
let nextById = Dictionary(
|
|
94
|
-
markers.map { ($0.id, $0) },
|
|
122
|
+
(markers ?? []).map { ($0.id, $0) },
|
|
95
123
|
uniquingKeysWith: { _, new in new }
|
|
96
124
|
)
|
|
97
125
|
|
|
@@ -100,20 +128,20 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
100
128
|
|
|
101
129
|
removed.forEach {
|
|
102
130
|
impl.removeMarker(id: $0)
|
|
103
|
-
|
|
131
|
+
markerBuilder.cancelIconTask($0)
|
|
104
132
|
}
|
|
105
133
|
|
|
106
134
|
for (id, next) in nextById {
|
|
107
135
|
if let prev = prevById[id] {
|
|
108
136
|
if !prev.markerEquals(next) {
|
|
109
137
|
impl.updateMarker(id: id) { m in
|
|
110
|
-
self.
|
|
138
|
+
self.markerBuilder.updateMarker(prev, next, m)
|
|
111
139
|
}
|
|
112
140
|
}
|
|
113
141
|
} else {
|
|
114
|
-
|
|
142
|
+
markerBuilder.buildIconAsync(next.id, next) { icon in
|
|
115
143
|
guard let icon else { return }
|
|
116
|
-
let marker = self.
|
|
144
|
+
let marker = self.markerBuilder.build(next, icon: icon)
|
|
117
145
|
self.impl.addMarker(id: id, marker: marker)
|
|
118
146
|
}
|
|
119
147
|
}
|
|
@@ -123,14 +151,14 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
123
151
|
}
|
|
124
152
|
|
|
125
153
|
@MainActor
|
|
126
|
-
var polylines: [RNPolyline]
|
|
154
|
+
var polylines: [RNPolyline]? {
|
|
127
155
|
didSet {
|
|
128
156
|
let prevById = Dictionary(
|
|
129
|
-
oldValue.map { ($0.id, $0) },
|
|
157
|
+
(oldValue ?? []).map { ($0.id, $0) },
|
|
130
158
|
uniquingKeysWith: { _, new in new }
|
|
131
159
|
)
|
|
132
160
|
let nextById = Dictionary(
|
|
133
|
-
polylines.map { ($0.id, $0) },
|
|
161
|
+
(polylines ?? []).map { ($0.id, $0) },
|
|
134
162
|
uniquingKeysWith: { _, new in new }
|
|
135
163
|
)
|
|
136
164
|
|
|
@@ -140,29 +168,29 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
140
168
|
for (id, next) in nextById {
|
|
141
169
|
if let prev = prevById[id] {
|
|
142
170
|
if !prev.polylineEquals(next) {
|
|
143
|
-
impl.updatePolyline(id: id) {
|
|
144
|
-
prev.updatePolyline(next,
|
|
171
|
+
impl.updatePolyline(id: id) { pl in
|
|
172
|
+
prev.updatePolyline(next, pl)
|
|
145
173
|
}
|
|
146
|
-
} else {
|
|
147
|
-
impl.addPolyline(
|
|
148
|
-
id: id,
|
|
149
|
-
polyline: polylineOptions.buildPolyline(next)
|
|
150
|
-
)
|
|
151
174
|
}
|
|
175
|
+
} else {
|
|
176
|
+
impl.addPolyline(
|
|
177
|
+
id: id,
|
|
178
|
+
polyline: polylineBuilder.buildPolyline(next)
|
|
179
|
+
)
|
|
152
180
|
}
|
|
153
181
|
}
|
|
154
182
|
}
|
|
155
183
|
}
|
|
156
184
|
|
|
157
185
|
@MainActor
|
|
158
|
-
var polygons: [RNPolygon]
|
|
186
|
+
var polygons: [RNPolygon]? {
|
|
159
187
|
didSet {
|
|
160
188
|
let prevById = Dictionary(
|
|
161
|
-
oldValue.map { ($0.id, $0) },
|
|
189
|
+
(oldValue ?? []).map { ($0.id, $0) },
|
|
162
190
|
uniquingKeysWith: { _, new in new }
|
|
163
191
|
)
|
|
164
192
|
let nextById = Dictionary(
|
|
165
|
-
polygons.map { ($0.id, $0) },
|
|
193
|
+
(polygons ?? []).map { ($0.id, $0) },
|
|
166
194
|
uniquingKeysWith: { _, new in new }
|
|
167
195
|
)
|
|
168
196
|
|
|
@@ -177,73 +205,109 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
177
205
|
}
|
|
178
206
|
}
|
|
179
207
|
} else {
|
|
180
|
-
impl.addPolygon(id: id, polygon:
|
|
208
|
+
impl.addPolygon(id: id, polygon: polygonBuilder.buildPolygon(next))
|
|
181
209
|
}
|
|
182
210
|
}
|
|
183
211
|
}
|
|
184
212
|
}
|
|
185
213
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
214
|
+
@MainActor
|
|
215
|
+
var circles: [RNCircle]? {
|
|
216
|
+
didSet {
|
|
217
|
+
let prevById = Dictionary(
|
|
218
|
+
(oldValue ?? []).map { ($0.id, $0) },
|
|
219
|
+
uniquingKeysWith: { _, new in new }
|
|
192
220
|
)
|
|
221
|
+
let nextById = Dictionary(
|
|
222
|
+
(circles ?? []).map { ($0.id, $0) },
|
|
223
|
+
uniquingKeysWith: { _, new in new }
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
let removed = Set(prevById.keys).subtracting(nextById.keys)
|
|
227
|
+
removed.forEach { impl.removeCircle(id: $0) }
|
|
228
|
+
|
|
229
|
+
for (id, next) in nextById {
|
|
230
|
+
if let prev = prevById[id] {
|
|
231
|
+
if !prev.circleEquals(next) {
|
|
232
|
+
impl.updateCircle(id: id) { circle in
|
|
233
|
+
prev.updateCircle(next, circle)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
impl.addCircle(id: id, circle: circleBuilder.buildCircle(next))
|
|
238
|
+
}
|
|
239
|
+
}
|
|
193
240
|
}
|
|
194
241
|
}
|
|
195
242
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
animated: Bool?,
|
|
200
|
-
durationMS: Double?
|
|
201
|
-
) {
|
|
202
|
-
onMain {
|
|
203
|
-
self.impl.setCameraToCoordinates(
|
|
204
|
-
coordinates: coordinates,
|
|
205
|
-
padding: padding ?? RNMapPadding(0, 0, 0, 0),
|
|
206
|
-
animated: animated ?? true,
|
|
207
|
-
durationMS: durationMS ?? 3000
|
|
208
|
-
)
|
|
243
|
+
@MainActor var locationConfig: RNLocationConfig? {
|
|
244
|
+
didSet {
|
|
245
|
+
impl.locationConfig = locationConfig
|
|
209
246
|
}
|
|
210
247
|
}
|
|
211
248
|
|
|
212
249
|
var onMapError: ((RNMapErrorCode) -> Void)? {
|
|
213
|
-
|
|
214
|
-
set { impl.onMapError = newValue }
|
|
250
|
+
didSet { impl.onMapError = onMapError }
|
|
215
251
|
}
|
|
216
252
|
var onMapReady: ((Bool) -> Void)? {
|
|
217
|
-
|
|
218
|
-
set { impl.onMapReady = newValue }
|
|
253
|
+
didSet { impl.onMapReady = onMapReady }
|
|
219
254
|
}
|
|
220
255
|
var onLocationUpdate: ((RNLocation) -> Void)? {
|
|
221
|
-
|
|
222
|
-
set { impl.onLocationUpdate = newValue }
|
|
256
|
+
didSet { impl.onLocationUpdate = onLocationUpdate }
|
|
223
257
|
}
|
|
224
258
|
var onLocationError: ((_ error: RNLocationErrorCode) -> Void)? {
|
|
225
|
-
|
|
226
|
-
set { impl.onLocationError = newValue }
|
|
259
|
+
didSet { impl.onLocationError = onLocationError }
|
|
227
260
|
}
|
|
228
261
|
var onMapPress: ((RNLatLng) -> Void)? {
|
|
229
|
-
|
|
230
|
-
set { impl.onMapPress = newValue }
|
|
262
|
+
didSet { impl.onMapPress = onMapPress }
|
|
231
263
|
}
|
|
232
264
|
var onMarkerPress: ((String) -> Void)? {
|
|
233
|
-
|
|
234
|
-
|
|
265
|
+
didSet { impl.onMarkerPress = onMarkerPress }
|
|
266
|
+
}
|
|
267
|
+
var onPolylinePress: ((String) -> Void)? {
|
|
268
|
+
didSet { impl.onPolylinePress = onPolylinePress }
|
|
269
|
+
}
|
|
270
|
+
var onPolygonPress: ((String) -> Void)? {
|
|
271
|
+
didSet { impl.onPolygonPress = onPolygonPress }
|
|
272
|
+
}
|
|
273
|
+
var onCirclePress: ((String) -> Void)? {
|
|
274
|
+
didSet { impl.onCirclePress = onCirclePress }
|
|
235
275
|
}
|
|
236
276
|
var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)? {
|
|
237
|
-
|
|
238
|
-
set { impl.onCameraChangeStart = newValue }
|
|
277
|
+
didSet { impl.onCameraChangeStart = onCameraChangeStart }
|
|
239
278
|
}
|
|
240
279
|
var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)? {
|
|
241
|
-
|
|
242
|
-
set { impl.onCameraChange = newValue }
|
|
280
|
+
didSet { impl.onCameraChange = onCameraChange }
|
|
243
281
|
}
|
|
244
282
|
var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)? {
|
|
245
|
-
|
|
246
|
-
|
|
283
|
+
didSet { impl.onCameraChangeComplete = onCameraChangeComplete }
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
func setCamera(camera: RNCamera, animated: Bool?, durationMS: Double?) {
|
|
287
|
+
let cam = camera.toGMSCameraPosition(current: impl.currentCamera)
|
|
288
|
+
onMain {
|
|
289
|
+
self.impl.setCamera(
|
|
290
|
+
camera: cam,
|
|
291
|
+
animated: animated ?? true,
|
|
292
|
+
durationMS: durationMS ?? 3000
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
func setCameraToCoordinates(
|
|
298
|
+
coordinates: [RNLatLng],
|
|
299
|
+
padding: RNMapPadding?,
|
|
300
|
+
animated: Bool?,
|
|
301
|
+
durationMS: Double?
|
|
302
|
+
) {
|
|
303
|
+
onMain {
|
|
304
|
+
self.impl.setCameraToCoordinates(
|
|
305
|
+
coordinates: coordinates,
|
|
306
|
+
padding: padding ?? RNMapPadding(0, 0, 0, 0),
|
|
307
|
+
animated: animated ?? true,
|
|
308
|
+
durationMS: durationMS ?? 3000
|
|
309
|
+
)
|
|
310
|
+
}
|
|
247
311
|
}
|
|
248
312
|
|
|
249
313
|
func showLocationDialog() {
|
|
@@ -255,7 +319,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
255
319
|
}
|
|
256
320
|
|
|
257
321
|
func requestLocationPermission()
|
|
258
|
-
|
|
322
|
+
-> NitroModules.Promise<RNLocationPermissionResult> {
|
|
259
323
|
return permissionHandler.requestLocationPermission()
|
|
260
324
|
}
|
|
261
325
|
|
|
@@ -263,79 +327,6 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
263
327
|
/// not supported
|
|
264
328
|
return true
|
|
265
329
|
}
|
|
266
|
-
|
|
267
|
-
private func mapCameraToGMSCamera(_ c: RNCamera) -> GMSCameraPosition {
|
|
268
|
-
let current = impl.currentCamera
|
|
269
|
-
let center = CLLocationCoordinate2D(
|
|
270
|
-
latitude: c.center?.latitude ?? current.target.latitude,
|
|
271
|
-
longitude: c.center?.longitude ?? current.target.longitude
|
|
272
|
-
)
|
|
273
|
-
let z = Float(c.zoom ?? Double(current.zoom))
|
|
274
|
-
let b = c.bearing ?? current.bearing
|
|
275
|
-
let t = c.tilt ?? current.viewingAngle
|
|
276
|
-
|
|
277
|
-
return GMSCameraPosition.camera(
|
|
278
|
-
withTarget: center,
|
|
279
|
-
zoom: z,
|
|
280
|
-
bearing: b,
|
|
281
|
-
viewingAngle: t
|
|
282
|
-
)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
private func mapCameraPositionToCamera(_ cp: GMSCameraPosition)
|
|
286
|
-
-> RNCamera {
|
|
287
|
-
return RNCamera(
|
|
288
|
-
center: RNLatLng(
|
|
289
|
-
latitude: cp.target.latitude,
|
|
290
|
-
longitude: cp.target.longitude
|
|
291
|
-
),
|
|
292
|
-
zoom: Double(cp.zoom),
|
|
293
|
-
bearing: cp.bearing,
|
|
294
|
-
tilt: cp.viewingAngle
|
|
295
|
-
)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
func mapUserInterfaceStyleToUIUserInterfaceStyle(
|
|
299
|
-
_ style: RNUserInterfaceStyle
|
|
300
|
-
)
|
|
301
|
-
-> UIUserInterfaceStyle {
|
|
302
|
-
switch style {
|
|
303
|
-
case .light: return .light
|
|
304
|
-
case .dark: return .dark
|
|
305
|
-
case .default: return .unspecified
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
func mapUIUserInterfaceStyletoUserInterfaceStyle(
|
|
310
|
-
_ uiStyle: UIUserInterfaceStyle
|
|
311
|
-
) -> RNUserInterfaceStyle {
|
|
312
|
-
switch uiStyle {
|
|
313
|
-
case .light: return .light
|
|
314
|
-
case .dark: return .dark
|
|
315
|
-
case .unspecified: return .default
|
|
316
|
-
@unknown default: return .default
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
extension UIUserInterfaceStyle {
|
|
322
|
-
init?(fromString string: String) {
|
|
323
|
-
switch string.lowercased() {
|
|
324
|
-
case "light": self = .light
|
|
325
|
-
case "dark": self = .dark
|
|
326
|
-
case "default": self = .unspecified
|
|
327
|
-
default: return nil
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
var stringValue: String {
|
|
332
|
-
switch self {
|
|
333
|
-
case .light: return "light"
|
|
334
|
-
case .dark: return "dark"
|
|
335
|
-
case .unspecified: return "default"
|
|
336
|
-
@unknown default: return "default"
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
330
|
}
|
|
340
331
|
|
|
341
332
|
@inline(__always)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import CoreLocation
|
|
2
|
+
import GoogleMaps
|
|
3
|
+
|
|
4
|
+
extension RNCamera {
|
|
5
|
+
func toGMSCameraPosition(current: GMSCameraPosition?) -> GMSCameraPosition {
|
|
6
|
+
let center = CLLocationCoordinate2D(
|
|
7
|
+
latitude: center?.latitude ?? current?.target.latitude ?? 0,
|
|
8
|
+
longitude: center?.longitude ?? current?.target.longitude ?? 0
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
let zoom = Float(zoom ?? Double(current?.zoom ?? 0))
|
|
12
|
+
let bearing = bearing ?? current?.bearing ?? 0
|
|
13
|
+
let tilt = tilt ?? current?.viewingAngle ?? 0
|
|
14
|
+
|
|
15
|
+
return GMSCameraPosition.camera(
|
|
16
|
+
withTarget: center,
|
|
17
|
+
zoom: zoom,
|
|
18
|
+
bearing: bearing,
|
|
19
|
+
viewingAngle: tilt
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import GoogleMaps
|
|
2
|
+
|
|
3
|
+
extension RNCircle {
|
|
4
|
+
func updateCircle(_ next: RNCircle, _ c: GMSCircle) {
|
|
5
|
+
c.position = CLLocationCoordinate2D(
|
|
6
|
+
latitude: next.center.latitude,
|
|
7
|
+
longitude: next.center.longitude
|
|
8
|
+
)
|
|
9
|
+
if let r = next.radius { c.radius = r }
|
|
10
|
+
if let fc = next.fillColor?.toUIColor() { c.fillColor = fc }
|
|
11
|
+
if let sc = next.strokeColor?.toUIColor() { c.strokeColor = sc }
|
|
12
|
+
if let sw = next.strokeWidth { c.strokeWidth = CGFloat(sw) }
|
|
13
|
+
if let pr = next.pressable { c.isTappable = pr }
|
|
14
|
+
if let zi = next.zIndex { c.zIndex = Int32(zi) }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func circleEquals(_ b: RNCircle) -> Bool {
|
|
18
|
+
zIndex == b.zIndex && pressable == b.pressable
|
|
19
|
+
&& center.latitude == b.center.latitude
|
|
20
|
+
&& center.longitude == b.center.longitude && radius == b.radius
|
|
21
|
+
&& strokeWidth == b.strokeWidth && strokeColor == b.strokeColor
|
|
22
|
+
&& fillColor == b.fillColor
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import CoreLocation
|
|
2
|
+
|
|
3
|
+
extension RNIOSLocationAccuracy {
|
|
4
|
+
var toCLLocationAccuracy: CLLocationAccuracy {
|
|
5
|
+
switch self {
|
|
6
|
+
case .accuracyBest:
|
|
7
|
+
return kCLLocationAccuracyBest
|
|
8
|
+
|
|
9
|
+
case .accuracyNearestTenMeter:
|
|
10
|
+
return kCLLocationAccuracyNearestTenMeters
|
|
11
|
+
|
|
12
|
+
case .accuracyNearestHundredMeter:
|
|
13
|
+
return kCLLocationAccuracyHundredMeters
|
|
14
|
+
|
|
15
|
+
case .accuracyKilometer:
|
|
16
|
+
return kCLLocationAccuracyKilometer
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import GoogleMaps
|
|
2
|
+
|
|
3
|
+
extension RNMarker {
|
|
4
|
+
func markerEquals(_ b: RNMarker) -> Bool {
|
|
5
|
+
id == b.id && zIndex == b.zIndex
|
|
6
|
+
&& coordinate.latitude == b.coordinate.latitude
|
|
7
|
+
&& coordinate.longitude == b.coordinate.longitude
|
|
8
|
+
&& anchor?.x == b.anchor?.x && anchor?.y == b.anchor?.y
|
|
9
|
+
&& markerStyleEquals(b)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
func markerStyleEquals(_ b: RNMarker) -> Bool {
|
|
13
|
+
width == b.width && height == b.height
|
|
14
|
+
&& iconSvg == b.iconSvg
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func styleHash() -> NSString {
|
|
18
|
+
var hasher = Hasher()
|
|
19
|
+
hasher.combine(width)
|
|
20
|
+
hasher.combine(height)
|
|
21
|
+
hasher.combine(iconSvg)
|
|
22
|
+
return String(hasher.finalize()) as NSString
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import GoogleMaps
|
|
2
2
|
|
|
3
|
-
class MapPolygonOptions {
|
|
4
|
-
|
|
5
|
-
func buildPolygon(_ p: RNPolygon) -> GMSPolygon {
|
|
6
|
-
let path = GMSMutablePath()
|
|
7
|
-
p.coordinates.forEach {
|
|
8
|
-
path.add(
|
|
9
|
-
CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude)
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
let pg = GMSPolygon(path: path)
|
|
13
|
-
if let fc = p.fillColor?.toUIColor() { pg.fillColor = fc }
|
|
14
|
-
if let sc = p.strokeColor?.toUIColor() { pg.strokeColor = sc }
|
|
15
|
-
if let sw = p.strokeWidth { pg.strokeWidth = CGFloat(sw) }
|
|
16
|
-
pg.zIndex = Int32(p.zIndex)
|
|
17
|
-
return pg
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
3
|
extension RNPolygon {
|
|
22
4
|
func updatePolygon(_ next: RNPolygon, _ pg: GMSPolygon) {
|
|
23
5
|
let path = GMSMutablePath()
|
|
@@ -34,15 +16,17 @@ extension RNPolygon {
|
|
|
34
16
|
if let fc = next.fillColor?.toUIColor() { pg.fillColor = fc }
|
|
35
17
|
if let sc = next.strokeColor?.toUIColor() { pg.strokeColor = sc }
|
|
36
18
|
if let sw = next.strokeWidth { pg.strokeWidth = CGFloat(sw) }
|
|
37
|
-
pg.
|
|
19
|
+
if let pr = next.pressable { pg.isTappable = pr }
|
|
20
|
+
if let zi = next.zIndex { pg.zIndex = Int32(zi) }
|
|
38
21
|
}
|
|
39
22
|
|
|
40
23
|
func polygonEquals(_ b: RNPolygon) -> Bool {
|
|
41
24
|
guard zIndex == b.zIndex,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
pressable == b.pressable,
|
|
26
|
+
strokeWidth == b.strokeWidth,
|
|
27
|
+
fillColor == b.fillColor,
|
|
28
|
+
strokeColor == b.strokeColor,
|
|
29
|
+
coordinates.count == b.coordinates.count
|
|
46
30
|
else { return false }
|
|
47
31
|
for i in 0..<coordinates.count {
|
|
48
32
|
if coordinates[i].latitude != b.coordinates[i].latitude
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import GoogleMaps
|
|
2
|
+
|
|
3
|
+
extension RNPolyline {
|
|
4
|
+
func updatePolyline(_ next: RNPolyline, _ pl: GMSPolyline) {
|
|
5
|
+
let path = GMSMutablePath()
|
|
6
|
+
next.coordinates.forEach {
|
|
7
|
+
path.add(
|
|
8
|
+
CLLocationCoordinate2D(
|
|
9
|
+
latitude: $0.latitude,
|
|
10
|
+
longitude: $0.longitude
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
pl.path = path
|
|
15
|
+
if let w = next.width { pl.strokeWidth = CGFloat(w) }
|
|
16
|
+
if let cap = next.lineCap {
|
|
17
|
+
pl.spans = nil
|
|
18
|
+
/// gms.lineCap = mapLineCap(cap)
|
|
19
|
+
}
|
|
20
|
+
if let join = next.lineJoin {
|
|
21
|
+
/// gms.strokeJoin = mapLineJoin(join)
|
|
22
|
+
}
|
|
23
|
+
if let c = next.color?.toUIColor() {
|
|
24
|
+
pl.strokeColor = c
|
|
25
|
+
}
|
|
26
|
+
if let pr = next.pressable { pl.isTappable = pr }
|
|
27
|
+
if let zi = next.zIndex { pl.zIndex = Int32(zi) }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func polylineEquals(_ b: RNPolyline) -> Bool {
|
|
31
|
+
guard zIndex == b.zIndex,
|
|
32
|
+
(width ?? 0) == (b.width ?? 0),
|
|
33
|
+
lineCap == b.lineCap,
|
|
34
|
+
lineJoin == b.lineJoin,
|
|
35
|
+
color == b.color,
|
|
36
|
+
coordinates.count == b.coordinates.count
|
|
37
|
+
else { return false }
|
|
38
|
+
for i in 0..<coordinates.count {
|
|
39
|
+
if coordinates[i].latitude != b.coordinates[i].latitude
|
|
40
|
+
|| coordinates[i].longitude != b.coordinates[i].longitude {
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private func mapLineCap(_ t: RNLineCapType) -> CGLineCap {
|
|
48
|
+
switch t {
|
|
49
|
+
case .round: return .round
|
|
50
|
+
case .square: return .square
|
|
51
|
+
default: return .butt
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private func mapLineJoin(_ t: RNLineJoinType) -> CGLineJoin {
|
|
56
|
+
switch t {
|
|
57
|
+
case .round: return .round
|
|
58
|
+
case .bevel: return .bevel
|
|
59
|
+
default: return .miter
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
extension RNUserInterfaceStyle {
|
|
4
|
+
var toUIUserInterfaceStyle: UIUserInterfaceStyle {
|
|
5
|
+
switch self {
|
|
6
|
+
case .light:
|
|
7
|
+
return .light
|
|
8
|
+
case .dark:
|
|
9
|
+
return .dark
|
|
10
|
+
case .default:
|
|
11
|
+
return .unspecified
|
|
12
|
+
@unknown default:
|
|
13
|
+
return .unspecified
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|