react-native-google-maps-plus 1.0.3-dev.1 → 1.1.0-dev.2
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/RNGoogleMapsPlus.podspec +2 -0
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +122 -29
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +44 -44
- package/android/src/main/java/com/rngooglemapsplus/{MapCircle.kt → MapCircleBuilder.kt} +2 -12
- package/android/src/main/java/com/rngooglemapsplus/{MapMarker.kt → MapMarkerBuilder.kt} +23 -27
- package/android/src/main/java/com/rngooglemapsplus/{MapPolygon.kt → MapPolygonBuilder.kt} +2 -18
- package/android/src/main/java/com/rngooglemapsplus/{MapPolyline.kt → MapPolylineBuilder.kt.kt} +2 -19
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +45 -54
- 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/RNMarkerExtension.kt +17 -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 +165 -22
- package/ios/LocationHandler.swift +29 -69
- package/ios/MapCircleBuilder.swift +20 -0
- package/ios/{MapMarker.swift → MapMarkerBuilder.swift} +17 -32
- package/ios/MapPolygonBuilder.swift +20 -0
- package/ios/MapPolylineBuilder.swift +24 -0
- package/ios/RNGoogleMapsPlusView.swift +63 -116
- package/ios/extensions/RNCamera+Extension.swift +22 -0
- package/ios/{MapCircle.swift → extensions/RNCircle+Extension.swift} +0 -19
- package/ios/extensions/RNIOSLocationAccuracy+Extensions.swift +19 -0
- package/ios/extensions/RNMarker+Extension.swift +25 -0
- package/ios/{MapPolygon.swift → extensions/RNPolygon+Extension.swift.swift} +0 -19
- package/ios/{MapPolyline.swift → extensions/RNPolyline+Extension.swift.swift} +16 -39
- package/ios/extensions/RNUserInterface+Extension.swift +16 -0
- package/lib/module/types.js +14 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +5 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +43 -2
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +64 -0
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +8 -0
- package/nitrogen/generated/android/c++/JRNAndroidLocationConfig.hpp +63 -0
- package/nitrogen/generated/android/c++/JRNAndroidLocationPriority.hpp +65 -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 +4 -4
- package/nitrogen/generated/android/c++/JRNLocationConfig.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNMapUiSettings.hpp +93 -0
- package/nitrogen/generated/android/c++/JRNMarker.hpp +6 -12
- package/nitrogen/generated/android/c++/JRNMarkerSvg.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +16 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +24 -0
- 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/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 +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationConfig.kt +32 -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 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarkerSvg.kt +35 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +126 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +21 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +49 -0
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +20 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +82 -0
- package/nitrogen/generated/ios/swift/RNAndroidLocationConfig.swift +93 -0
- package/nitrogen/generated/ios/swift/RNAndroidLocationPriority.swift +48 -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 +6 -6
- package/nitrogen/generated/ios/swift/RNLocationConfig.swift +84 -0
- package/nitrogen/generated/ios/swift/RNMapUiSettings.swift +277 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +24 -27
- package/nitrogen/generated/ios/swift/RNMarkerSvg.swift +57 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +8 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +14 -0
- package/nitrogen/generated/shared/c++/RNAndroidLocationConfig.hpp +77 -0
- package/nitrogen/generated/shared/c++/RNAndroidLocationPriority.hpp +64 -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 +5 -5
- package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +76 -0
- package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +107 -0
- package/nitrogen/generated/shared/c++/RNMarker.hpp +8 -13
- package/nitrogen/generated/shared/c++/RNMarkerSvg.hpp +75 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +48 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +4 -0
- package/package.json +1 -1
- package/src/RNGoogleMapsPlusView.nitro.ts +6 -0
- package/src/types.ts +49 -2
- /package/ios/{Color.swift → extensions/String+Extensions.swift} +0 -0
|
@@ -4,11 +4,17 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
4
4
|
import com.facebook.react.bridge.UiThreadUtil
|
|
5
5
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
6
6
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
-
import com.google.android.gms.maps.model.CameraPosition
|
|
8
7
|
import com.google.android.gms.maps.model.LatLng
|
|
9
|
-
import com.google.android.gms.maps.model.MapColorScheme
|
|
10
8
|
import com.google.android.gms.maps.model.MapStyleOptions
|
|
11
9
|
import com.margelo.nitro.core.Promise
|
|
10
|
+
import com.rngooglemapsplus.extensions.circleEquals
|
|
11
|
+
import com.rngooglemapsplus.extensions.markerEquals
|
|
12
|
+
import com.rngooglemapsplus.extensions.markerStyleEquals
|
|
13
|
+
import com.rngooglemapsplus.extensions.polygonEquals
|
|
14
|
+
import com.rngooglemapsplus.extensions.polylineEquals
|
|
15
|
+
import com.rngooglemapsplus.extensions.toCameraPosition
|
|
16
|
+
import com.rngooglemapsplus.extensions.toColor
|
|
17
|
+
import com.rngooglemapsplus.extensions.toMapColorScheme
|
|
12
18
|
|
|
13
19
|
@DoNotStrip
|
|
14
20
|
class RNGoogleMapsPlusView(
|
|
@@ -19,23 +25,33 @@ class RNGoogleMapsPlusView(
|
|
|
19
25
|
private var locationHandler = LocationHandler(context)
|
|
20
26
|
private var playServiceHandler = PlayServicesHandler(context)
|
|
21
27
|
|
|
22
|
-
private val
|
|
23
|
-
private val
|
|
24
|
-
private val
|
|
25
|
-
private val
|
|
28
|
+
private val markerBuilder = MapMarkerBuilder()
|
|
29
|
+
private val polylineBuilder = MapPolylineBuilder()
|
|
30
|
+
private val polygonBuilder = MapPolygonBuilder()
|
|
31
|
+
private val circleBuilder = MapCircleBuilder()
|
|
26
32
|
|
|
27
33
|
override val view =
|
|
28
|
-
GoogleMapsViewImpl(context, locationHandler, playServiceHandler,
|
|
34
|
+
GoogleMapsViewImpl(context, locationHandler, playServiceHandler, markerBuilder)
|
|
29
35
|
|
|
30
36
|
override var initialProps: RNInitialProps? = null
|
|
31
37
|
set(value) {
|
|
32
38
|
view.initMapView(
|
|
33
39
|
value?.mapId,
|
|
34
40
|
value?.liteMode,
|
|
35
|
-
|
|
41
|
+
value?.camera?.toCameraPosition(),
|
|
36
42
|
)
|
|
37
43
|
}
|
|
38
44
|
|
|
45
|
+
override var uiSettings: RNMapUiSettings? = null
|
|
46
|
+
set(value) {
|
|
47
|
+
view.uiSettings = value
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override var myLocationEnabled: Boolean? = null
|
|
51
|
+
set(value) {
|
|
52
|
+
view.myLocationEnabled = value
|
|
53
|
+
}
|
|
54
|
+
|
|
39
55
|
override var buildingEnabled: Boolean? = null
|
|
40
56
|
set(value) {
|
|
41
57
|
view.buildingEnabled = value
|
|
@@ -46,6 +62,11 @@ class RNGoogleMapsPlusView(
|
|
|
46
62
|
view.trafficEnabled = value
|
|
47
63
|
}
|
|
48
64
|
|
|
65
|
+
override var indoorEnabled: Boolean? = null
|
|
66
|
+
set(value) {
|
|
67
|
+
view.indoorEnabled = value
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
override var customMapStyle: String? = null
|
|
50
71
|
set(value) {
|
|
51
72
|
currentCustomMapStyle = value
|
|
@@ -56,7 +77,7 @@ class RNGoogleMapsPlusView(
|
|
|
56
77
|
|
|
57
78
|
override var userInterfaceStyle: RNUserInterfaceStyle? = null
|
|
58
79
|
set(value) {
|
|
59
|
-
view.userInterfaceStyle =
|
|
80
|
+
view.userInterfaceStyle = value.toMapColorScheme()
|
|
60
81
|
}
|
|
61
82
|
|
|
62
83
|
override var minZoomLevel: Double? = null
|
|
@@ -87,17 +108,17 @@ class RNGoogleMapsPlusView(
|
|
|
87
108
|
val nextById = value?.associateBy { it.id } ?: emptyMap()
|
|
88
109
|
|
|
89
110
|
(prevById.keys - nextById.keys).forEach { id ->
|
|
90
|
-
|
|
111
|
+
markerBuilder.cancelIconJob(id)
|
|
91
112
|
view.removeMarker(id)
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
nextById.forEach { (id, next) ->
|
|
95
116
|
val prev = prevById[id]
|
|
96
117
|
if (prev == null) {
|
|
97
|
-
|
|
118
|
+
markerBuilder.buildIconAsync(id, next) { icon ->
|
|
98
119
|
view.addMarker(
|
|
99
120
|
id,
|
|
100
|
-
|
|
121
|
+
markerBuilder.build(next, icon),
|
|
101
122
|
)
|
|
102
123
|
}
|
|
103
124
|
} else if (!prev.markerEquals(next)) {
|
|
@@ -113,7 +134,7 @@ class RNGoogleMapsPlusView(
|
|
|
113
134
|
}
|
|
114
135
|
|
|
115
136
|
if (!prev.markerStyleEquals(next)) {
|
|
116
|
-
|
|
137
|
+
markerBuilder.buildIconAsync(id, next) { icon ->
|
|
117
138
|
m.setIcon(icon)
|
|
118
139
|
}
|
|
119
140
|
}
|
|
@@ -140,7 +161,7 @@ class RNGoogleMapsPlusView(
|
|
|
140
161
|
nextById.forEach { (id, next) ->
|
|
141
162
|
val prev = prevById[id]
|
|
142
163
|
if (prev == null) {
|
|
143
|
-
view.addPolyline(id,
|
|
164
|
+
view.addPolyline(id, polylineBuilder.buildPolylineOptions(next))
|
|
144
165
|
} else if (!prev.polylineEquals(next)) {
|
|
145
166
|
view.updatePolyline(id) { gms ->
|
|
146
167
|
onUi {
|
|
@@ -151,11 +172,11 @@ class RNGoogleMapsPlusView(
|
|
|
151
172
|
}
|
|
152
173
|
next.width?.let { gms.width = it.dpToPx() }
|
|
153
174
|
next.lineCap?.let {
|
|
154
|
-
val cap =
|
|
175
|
+
val cap = polylineBuilder.mapLineCap(it)
|
|
155
176
|
gms.startCap = cap
|
|
156
177
|
gms.endCap = cap
|
|
157
178
|
}
|
|
158
|
-
next.lineJoin?.let { gms.jointType =
|
|
179
|
+
next.lineJoin?.let { gms.jointType = polylineBuilder.mapLineJoin(it) }
|
|
159
180
|
next.color?.let { gms.color = it.toColor() }
|
|
160
181
|
next.zIndex?.let { gms.zIndex = it.toFloat() }
|
|
161
182
|
}
|
|
@@ -177,7 +198,7 @@ class RNGoogleMapsPlusView(
|
|
|
177
198
|
nextById.forEach { (id, next) ->
|
|
178
199
|
val prev = prevById[id]
|
|
179
200
|
if (prev == null) {
|
|
180
|
-
view.addPolygon(id,
|
|
201
|
+
view.addPolygon(id, polygonBuilder.buildPolygonOptions(next))
|
|
181
202
|
} else if (!prev.polygonEquals(next)) {
|
|
182
203
|
view.updatePolygon(id) { gmsPoly ->
|
|
183
204
|
onUi {
|
|
@@ -209,7 +230,7 @@ class RNGoogleMapsPlusView(
|
|
|
209
230
|
nextById.forEach { (id, next) ->
|
|
210
231
|
val prev = prevById[id]
|
|
211
232
|
if (prev == null) {
|
|
212
|
-
view.addCircle(id,
|
|
233
|
+
view.addCircle(id, circleBuilder.buildCircleOptions(next))
|
|
213
234
|
} else if (!prev.circleEquals(next)) {
|
|
214
235
|
view.updateCircle(id) { gmsCircle ->
|
|
215
236
|
onUi {
|
|
@@ -226,6 +247,11 @@ class RNGoogleMapsPlusView(
|
|
|
226
247
|
field = value
|
|
227
248
|
}
|
|
228
249
|
|
|
250
|
+
override var locationConfig: RNLocationConfig? = null
|
|
251
|
+
set(value) {
|
|
252
|
+
view.locationConfig = value
|
|
253
|
+
}
|
|
254
|
+
|
|
229
255
|
override var onMapError: ((RNMapErrorCode) -> Unit)? = null
|
|
230
256
|
set(cb) {
|
|
231
257
|
view.onMapError = cb
|
|
@@ -290,7 +316,7 @@ class RNGoogleMapsPlusView(
|
|
|
290
316
|
animated: Boolean?,
|
|
291
317
|
durationMS: Double?,
|
|
292
318
|
) {
|
|
293
|
-
view.setCamera(camera, animated == true, durationMS?.toInt() ?: 3000)
|
|
319
|
+
view.setCamera(camera.toCameraPosition(), animated == true, durationMS?.toInt() ?: 3000)
|
|
294
320
|
}
|
|
295
321
|
|
|
296
322
|
override fun setCameraToCoordinates(
|
|
@@ -318,41 +344,6 @@ class RNGoogleMapsPlusView(
|
|
|
318
344
|
override fun requestLocationPermission(): Promise<RNLocationPermissionResult> = permissionHandler.requestLocationPermission()
|
|
319
345
|
|
|
320
346
|
override fun isGooglePlayServicesAvailable(): Boolean = playServiceHandler.isPlayServicesAvailable()
|
|
321
|
-
|
|
322
|
-
fun userInterfaceStyleToMapColorScheme(value: RNUserInterfaceStyle?): Int? {
|
|
323
|
-
value ?: return null
|
|
324
|
-
return when (value) {
|
|
325
|
-
RNUserInterfaceStyle.LIGHT -> {
|
|
326
|
-
MapColorScheme.LIGHT
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
RNUserInterfaceStyle.DARK -> {
|
|
330
|
-
MapColorScheme.DARK
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
RNUserInterfaceStyle.DEFAULT -> {
|
|
334
|
-
MapColorScheme.FOLLOW_SYSTEM
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
fun mapCameraToCameraPosition(camera: RNCamera?): CameraPosition? {
|
|
340
|
-
camera ?: return null
|
|
341
|
-
val builder = CameraPosition.builder()
|
|
342
|
-
camera.center?.let {
|
|
343
|
-
builder.target(
|
|
344
|
-
com.google.android.gms.maps.model.LatLng(
|
|
345
|
-
camera.center.latitude,
|
|
346
|
-
camera.center.longitude,
|
|
347
|
-
),
|
|
348
|
-
)
|
|
349
|
-
}
|
|
350
|
-
camera.zoom?.let { builder.zoom(it.toFloat()) }
|
|
351
|
-
camera.bearing?.let { builder.bearing(it.toFloat()) }
|
|
352
|
-
camera.tilt?.let { builder.tilt(it.toFloat()) }
|
|
353
|
-
|
|
354
|
-
return builder.build()
|
|
355
|
-
}
|
|
356
347
|
}
|
|
357
348
|
|
|
358
349
|
private inline fun onUi(crossinline block: () -> Unit) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.CameraPosition
|
|
4
|
+
import com.google.android.gms.maps.model.LatLng
|
|
5
|
+
import com.rngooglemapsplus.RNCamera
|
|
6
|
+
|
|
7
|
+
fun RNCamera.toCameraPosition(): CameraPosition {
|
|
8
|
+
val builder = CameraPosition.builder()
|
|
9
|
+
|
|
10
|
+
center?.let {
|
|
11
|
+
builder.target(LatLng(it.latitude, it.longitude))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
zoom?.let { builder.zoom(it.toFloat()) }
|
|
15
|
+
bearing?.let { builder.bearing(it.toFloat()) }
|
|
16
|
+
tilt?.let { builder.tilt(it.toFloat()) }
|
|
17
|
+
|
|
18
|
+
return builder.build()
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.location.Priority
|
|
4
|
+
import com.rngooglemapsplus.RNAndroidLocationPriority
|
|
5
|
+
|
|
6
|
+
fun RNAndroidLocationPriority.toGooglePriority(): Int =
|
|
7
|
+
when (this) {
|
|
8
|
+
RNAndroidLocationPriority.PRIORITY_HIGH_ACCURACY -> Priority.PRIORITY_HIGH_ACCURACY
|
|
9
|
+
RNAndroidLocationPriority.PRIORITY_BALANCED_POWER_ACCURACY -> Priority.PRIORITY_BALANCED_POWER_ACCURACY
|
|
10
|
+
RNAndroidLocationPriority.PRIORITY_LOW_POWER -> Priority.PRIORITY_LOW_POWER
|
|
11
|
+
RNAndroidLocationPriority.PRIORITY_PASSIVE -> Priority.PRIORITY_PASSIVE
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.rngooglemapsplus.RNCircle
|
|
4
|
+
|
|
5
|
+
fun RNCircle.circleEquals(b: RNCircle): Boolean {
|
|
6
|
+
if (zIndex != b.zIndex) return false
|
|
7
|
+
if (pressable != b.pressable) return false
|
|
8
|
+
if (center != b.center) return false
|
|
9
|
+
if (radius != b.radius) return false
|
|
10
|
+
if (strokeWidth != b.strokeWidth) return false
|
|
11
|
+
if (strokeColor != b.strokeColor) return false
|
|
12
|
+
if (fillColor != b.fillColor) return false
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.rngooglemapsplus.RNMarker
|
|
4
|
+
|
|
5
|
+
fun RNMarker.markerEquals(b: RNMarker): Boolean =
|
|
6
|
+
id == b.id &&
|
|
7
|
+
zIndex == b.zIndex &&
|
|
8
|
+
coordinate == b.coordinate &&
|
|
9
|
+
anchor == b.anchor &&
|
|
10
|
+
markerStyleEquals(b)
|
|
11
|
+
|
|
12
|
+
fun RNMarker.markerStyleEquals(b: RNMarker): Boolean = iconSvg == b.iconSvg
|
|
13
|
+
|
|
14
|
+
fun RNMarker.styleHash(): Int =
|
|
15
|
+
arrayOf<Any?>(
|
|
16
|
+
iconSvg,
|
|
17
|
+
).contentHashCode()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.rngooglemapsplus.RNPolygon
|
|
4
|
+
|
|
5
|
+
fun RNPolygon.polygonEquals(b: RNPolygon): Boolean {
|
|
6
|
+
if (zIndex != b.zIndex) return false
|
|
7
|
+
if (pressable != b.pressable) return false
|
|
8
|
+
if (strokeWidth != b.strokeWidth) return false
|
|
9
|
+
if (fillColor != b.fillColor) return false
|
|
10
|
+
if (strokeColor != b.strokeColor) return false
|
|
11
|
+
val ac = coordinates
|
|
12
|
+
val bc = b.coordinates
|
|
13
|
+
if (ac.size != bc.size) return false
|
|
14
|
+
for (i in ac.indices) {
|
|
15
|
+
val p = ac[i]
|
|
16
|
+
val q = bc[i]
|
|
17
|
+
if (p.latitude != q.latitude || p.longitude != q.longitude) return false
|
|
18
|
+
}
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.rngooglemapsplus.RNPolyline
|
|
4
|
+
|
|
5
|
+
fun RNPolyline.polylineEquals(b: RNPolyline): Boolean {
|
|
6
|
+
if (zIndex != b.zIndex) return false
|
|
7
|
+
if (pressable != b.pressable) return false
|
|
8
|
+
if ((width ?: 0.0) != (b.width ?: 0.0)) return false
|
|
9
|
+
if (lineCap != b.lineCap) return false
|
|
10
|
+
if (lineJoin != b.lineJoin) return false
|
|
11
|
+
if (color != b.color) return false
|
|
12
|
+
val ac = coordinates
|
|
13
|
+
val bc = b.coordinates
|
|
14
|
+
if (ac.size != bc.size) return false
|
|
15
|
+
for (i in ac.indices) {
|
|
16
|
+
val p = ac[i]
|
|
17
|
+
val q = bc[i]
|
|
18
|
+
if (p.latitude != q.latitude || p.longitude != q.longitude) return false
|
|
19
|
+
}
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.MapColorScheme
|
|
4
|
+
import com.rngooglemapsplus.RNUserInterfaceStyle
|
|
5
|
+
|
|
6
|
+
fun RNUserInterfaceStyle?.toMapColorScheme(): Int? =
|
|
7
|
+
when (this) {
|
|
8
|
+
RNUserInterfaceStyle.LIGHT -> MapColorScheme.LIGHT
|
|
9
|
+
RNUserInterfaceStyle.DARK -> MapColorScheme.DARK
|
|
10
|
+
RNUserInterfaceStyle.DEFAULT -> MapColorScheme.FOLLOW_SYSTEM
|
|
11
|
+
null -> null
|
|
12
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.google.android.gms.common.ConnectionResult
|
|
5
|
+
import com.google.android.gms.common.GoogleApiAvailability
|
|
6
|
+
import com.google.android.gms.common.api.ApiException
|
|
7
|
+
import com.google.android.gms.common.api.CommonStatusCodes
|
|
8
|
+
import com.google.android.gms.location.LocationSettingsStatusCodes
|
|
9
|
+
import com.rngooglemapsplus.RNLocationErrorCode
|
|
10
|
+
|
|
11
|
+
fun Throwable.toLocationErrorCode(context: Context): RNLocationErrorCode {
|
|
12
|
+
return when (this) {
|
|
13
|
+
is SecurityException -> RNLocationErrorCode.PERMISSION_DENIED
|
|
14
|
+
|
|
15
|
+
is ApiException ->
|
|
16
|
+
when (statusCode) {
|
|
17
|
+
CommonStatusCodes.NETWORK_ERROR ->
|
|
18
|
+
RNLocationErrorCode.POSITION_UNAVAILABLE
|
|
19
|
+
LocationSettingsStatusCodes.RESOLUTION_REQUIRED,
|
|
20
|
+
LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE,
|
|
21
|
+
->
|
|
22
|
+
RNLocationErrorCode.SETTINGS_NOT_SATISFIED
|
|
23
|
+
else ->
|
|
24
|
+
RNLocationErrorCode.INTERNAL_ERROR
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
else -> {
|
|
28
|
+
if (message?.contains("GoogleApi", ignoreCase = true) == true) {
|
|
29
|
+
val gms = GoogleApiAvailability.getInstance()
|
|
30
|
+
val status = gms.isGooglePlayServicesAvailable(context)
|
|
31
|
+
if (status != ConnectionResult.SUCCESS) {
|
|
32
|
+
return RNLocationErrorCode.PLAY_SERVICE_NOT_AVAILABLE
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
RNLocationErrorCode.INTERNAL_ERROR
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -5,7 +5,7 @@ import UIKit
|
|
|
5
5
|
final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
6
6
|
|
|
7
7
|
private let locationHandler: LocationHandler
|
|
8
|
-
private let
|
|
8
|
+
private let markerBuilder: MapMarkerBuilder
|
|
9
9
|
private var mapView: GMSMapView?
|
|
10
10
|
private var initialized = false
|
|
11
11
|
private var mapReady = false
|
|
@@ -24,26 +24,13 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
24
24
|
private var lastSubmittedCameraPosition: GMSCameraPosition?
|
|
25
25
|
private var lastSubmittedLocation: CLLocation?
|
|
26
26
|
|
|
27
|
-
var onMapError: ((RNMapErrorCode) -> Void)?
|
|
28
|
-
var onMapReady: ((Bool) -> Void)?
|
|
29
|
-
var onLocationUpdate: ((RNLocation) -> Void)?
|
|
30
|
-
var onLocationError: ((_ error: RNLocationErrorCode) -> Void)?
|
|
31
|
-
var onMapPress: ((RNLatLng) -> Void)?
|
|
32
|
-
var onMarkerPress: ((String) -> Void)?
|
|
33
|
-
var onPolylinePress: ((String) -> Void)?
|
|
34
|
-
var onPolygonPress: ((String) -> Void)?
|
|
35
|
-
var onCirclePress: ((String) -> Void)?
|
|
36
|
-
var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
37
|
-
var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
38
|
-
var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
39
|
-
|
|
40
27
|
init(
|
|
41
28
|
frame: CGRect = .zero,
|
|
42
29
|
locationHandler: LocationHandler,
|
|
43
|
-
|
|
30
|
+
markerBuilder: MapMarkerBuilder
|
|
44
31
|
) {
|
|
45
32
|
self.locationHandler = locationHandler
|
|
46
|
-
self.
|
|
33
|
+
self.markerBuilder = markerBuilder
|
|
47
34
|
super.init(frame: frame)
|
|
48
35
|
setupAppLifecycleObservers()
|
|
49
36
|
}
|
|
@@ -132,12 +119,46 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
132
119
|
)
|
|
133
120
|
}
|
|
134
121
|
|
|
135
|
-
if let
|
|
136
|
-
|
|
122
|
+
if let uiSettings = uiSettings {
|
|
123
|
+
if let allGesturesEnabled = uiSettings.allGesturesEnabled {
|
|
124
|
+
mapView?.settings.setAllGesturesEnabled(allGesturesEnabled)
|
|
125
|
+
}
|
|
126
|
+
if let compassEnabled = uiSettings.compassEnabled {
|
|
127
|
+
mapView?.settings.compassButton = compassEnabled
|
|
128
|
+
}
|
|
129
|
+
if let indoorLevelPickerEnabled = uiSettings.indoorLevelPickerEnabled {
|
|
130
|
+
mapView?.settings.indoorPicker = indoorLevelPickerEnabled
|
|
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
|
|
151
|
+
}
|
|
152
|
+
if let zoomControlsEnabled = uiSettings.zoomControlsEnabled {
|
|
153
|
+
/// not supported
|
|
154
|
+
}
|
|
155
|
+
if let zoomGesturesEnabled = uiSettings.zoomGesturesEnabled {
|
|
156
|
+
mapView?.settings.zoomGestures = zoomGesturesEnabled
|
|
157
|
+
}
|
|
137
158
|
}
|
|
138
159
|
|
|
139
|
-
if let
|
|
140
|
-
mapView?.
|
|
160
|
+
if let myLocation = myLocationEnabled {
|
|
161
|
+
mapView?.isMyLocationEnabled = myLocation
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
if let buildings = buildingEnabled {
|
|
@@ -148,6 +169,18 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
148
169
|
mapView?.isTrafficEnabled = traffic
|
|
149
170
|
}
|
|
150
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
|
+
|
|
151
184
|
if let uiStyle = userInterfaceStyle {
|
|
152
185
|
mapView?.overrideUserInterfaceStyle = uiStyle
|
|
153
186
|
}
|
|
@@ -156,6 +189,13 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
156
189
|
mapView?.setMinZoom(Float(minZoom), maxZoom: Float(maxZoom))
|
|
157
190
|
}
|
|
158
191
|
|
|
192
|
+
if let locationConfig = locationConfig {
|
|
193
|
+
locationHandler.desiredAccuracy =
|
|
194
|
+
locationConfig.ios?.desiredAccuracy?.toCLLocationAccuracy
|
|
195
|
+
locationHandler.distanceFilterMeters =
|
|
196
|
+
locationConfig.ios?.distanceFilterMeters
|
|
197
|
+
}
|
|
198
|
+
|
|
159
199
|
if !pendingMarkers.isEmpty {
|
|
160
200
|
pendingMarkers.forEach {
|
|
161
201
|
addMarkerInternal(id: $0.id, marker: $0.marker)
|
|
@@ -186,11 +226,80 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
186
226
|
mapView?.camera
|
|
187
227
|
}
|
|
188
228
|
|
|
229
|
+
@MainActor
|
|
230
|
+
var uiSettings: RNMapUiSettings? {
|
|
231
|
+
didSet {
|
|
232
|
+
guard let mapView = mapView else { return }
|
|
233
|
+
let settings = mapView.settings
|
|
234
|
+
|
|
235
|
+
if let v = uiSettings {
|
|
236
|
+
if let allGesturesEnabled = v.allGesturesEnabled {
|
|
237
|
+
settings.setAllGesturesEnabled(allGesturesEnabled)
|
|
238
|
+
}
|
|
239
|
+
if let compassEnabled = v.compassEnabled {
|
|
240
|
+
settings.compassButton = compassEnabled
|
|
241
|
+
}
|
|
242
|
+
if let indoorLevelPickerEnabled = v.indoorLevelPickerEnabled {
|
|
243
|
+
settings.indoorPicker = indoorLevelPickerEnabled
|
|
244
|
+
}
|
|
245
|
+
if let mapToolbarEnabled = v.mapToolbarEnabled {
|
|
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
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@MainActor
|
|
286
|
+
var myLocationEnabled: Bool? {
|
|
287
|
+
didSet {
|
|
288
|
+
if let value = myLocationEnabled {
|
|
289
|
+
mapView?.isMyLocationEnabled = value
|
|
290
|
+
} else {
|
|
291
|
+
mapView?.isMyLocationEnabled = false
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
189
296
|
@MainActor
|
|
190
297
|
var buildingEnabled: Bool? {
|
|
191
298
|
didSet {
|
|
192
299
|
if let value = buildingEnabled {
|
|
193
300
|
mapView?.isBuildingsEnabled = value
|
|
301
|
+
} else {
|
|
302
|
+
mapView?.isBuildingsEnabled = false
|
|
194
303
|
}
|
|
195
304
|
}
|
|
196
305
|
}
|
|
@@ -200,6 +309,19 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
200
309
|
didSet {
|
|
201
310
|
if let value = trafficEnabled {
|
|
202
311
|
mapView?.isTrafficEnabled = value
|
|
312
|
+
} else {
|
|
313
|
+
mapView?.isTrafficEnabled = false
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@MainActor
|
|
319
|
+
var indoorEnabled: Bool? {
|
|
320
|
+
didSet {
|
|
321
|
+
if let value = indoorEnabled {
|
|
322
|
+
mapView?.isIndoorEnabled = value
|
|
323
|
+
} else {
|
|
324
|
+
mapView?.isIndoorEnabled = false
|
|
203
325
|
}
|
|
204
326
|
}
|
|
205
327
|
}
|
|
@@ -243,7 +365,6 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
243
365
|
@MainActor
|
|
244
366
|
var mapPadding: RNMapPadding? {
|
|
245
367
|
didSet {
|
|
246
|
-
mapPadding
|
|
247
368
|
if let padding = mapPadding {
|
|
248
369
|
mapView?.padding = UIEdgeInsets(
|
|
249
370
|
top: padding.top,
|
|
@@ -263,6 +384,28 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
263
384
|
}
|
|
264
385
|
}
|
|
265
386
|
|
|
387
|
+
@MainActor var locationConfig: RNLocationConfig? {
|
|
388
|
+
didSet {
|
|
389
|
+
locationHandler.desiredAccuracy =
|
|
390
|
+
locationConfig?.ios?.desiredAccuracy?.toCLLocationAccuracy
|
|
391
|
+
locationHandler.distanceFilterMeters =
|
|
392
|
+
locationConfig?.ios?.distanceFilterMeters
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
var onMapError: ((RNMapErrorCode) -> Void)?
|
|
397
|
+
var onMapReady: ((Bool) -> Void)?
|
|
398
|
+
var onLocationUpdate: ((RNLocation) -> Void)?
|
|
399
|
+
var onLocationError: ((_ error: RNLocationErrorCode) -> Void)?
|
|
400
|
+
var onMapPress: ((RNLatLng) -> Void)?
|
|
401
|
+
var onMarkerPress: ((String) -> Void)?
|
|
402
|
+
var onPolylinePress: ((String) -> Void)?
|
|
403
|
+
var onPolygonPress: ((String) -> Void)?
|
|
404
|
+
var onCirclePress: ((String) -> Void)?
|
|
405
|
+
var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
406
|
+
var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
407
|
+
var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
408
|
+
|
|
266
409
|
func setCamera(camera: GMSCameraPosition, animated: Bool, durationMS: Double) {
|
|
267
410
|
if animated {
|
|
268
411
|
withCATransaction(
|
|
@@ -467,7 +610,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
467
610
|
}
|
|
468
611
|
|
|
469
612
|
func deinitInternal() {
|
|
470
|
-
|
|
613
|
+
markerBuilder.cancelAllIconTasks()
|
|
471
614
|
clearMarkers()
|
|
472
615
|
clearPolylines()
|
|
473
616
|
clearPolygons()
|