react-native-google-maps-plus 1.3.0 → 1.4.1-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/android/build.gradle +1 -1
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +50 -161
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +38 -36
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +33 -9
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +73 -18
- package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +59 -12
- package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +47 -12
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +12 -9
- package/android/src/main/java/com/rngooglemapsplus/extensions/CameraPositionExtension.kt +12 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/IntExtension.kt +28 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngBounds.kt +15 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngExtension.kt +6 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/LocationExtension.kt +59 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNCameraExtension.kt +1 -2
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNLatLngExtension.kt +6 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNMarkerExtension.kt +8 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolygonExtension.kt +2 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolylineExtension.kt +1 -0
- package/ios/GoogleMapViewImpl.swift +39 -180
- package/ios/LocationHandler.swift +5 -13
- package/ios/MapCircleBuilder.swift +30 -18
- package/ios/MapHelper.swift +20 -0
- package/ios/MapMarkerBuilder.swift +105 -86
- package/ios/MapPolygonBuilder.swift +62 -13
- package/ios/MapPolylineBuilder.swift +33 -15
- package/ios/RNGoogleMapsPlusView.swift +15 -9
- package/ios/extensions/CLError+Extension.swift +14 -0
- package/ios/extensions/CLLocation+Extension.swift +27 -0
- package/ios/extensions/CLLocationCoordinate2D+Extension.swift +7 -0
- package/ios/extensions/GMSCameraPosition+Extension.swift +12 -0
- package/ios/extensions/GMSCoordinateBounds+Extension.swift +19 -0
- package/ios/extensions/RNLatLng+Extension.swift +7 -0
- package/ios/extensions/RNMarker+Extension.swift +7 -3
- package/ios/extensions/RNPolygon+Extension.swift.swift +16 -1
- package/ios/extensions/RNPolyline+Extension.swift.swift +1 -0
- package/lib/module/GoogleMapsPlus.js +7 -0
- package/lib/module/GoogleMapsPlus.js.map +1 -0
- package/lib/module/index.js +3 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +44 -0
- package/lib/typescript/src/GoogleMapsPlus.d.ts +5 -0
- package/lib/typescript/src/GoogleMapsPlus.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +33 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_RNLocation.hpp +6 -0
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +12 -0
- package/nitrogen/generated/android/c++/JRNLocation.hpp +32 -2
- package/nitrogen/generated/android/c++/JRNLocationAndroid.hpp +82 -0
- package/nitrogen/generated/android/c++/JRNLocationIOS.hpp +77 -0
- package/nitrogen/generated/android/c++/JRNMarker.hpp +8 -0
- package/nitrogen/generated/android/c++/JRNPolygon.hpp +29 -2
- package/nitrogen/generated/android/c++/JRNPolygonHole.hpp +72 -0
- package/nitrogen/generated/android/c++/JRNPolyline.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocation.kt +19 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationAndroid.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationIOS.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +6 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygon.kt +7 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygonHole.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolyline.kt +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +8 -3
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +16 -16
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +87 -20
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +12 -3
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +8 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +7 -56
- package/nitrogen/generated/ios/swift/RNCamera.swift +1 -8
- package/nitrogen/generated/ios/swift/RNHeatmap.swift +1 -8
- package/nitrogen/generated/ios/swift/RNHeatmapGradient.swift +11 -15
- package/nitrogen/generated/ios/swift/RNInitialProps.swift +1 -8
- package/nitrogen/generated/ios/swift/RNLocation.swift +92 -2
- package/nitrogen/generated/ios/swift/RNLocationAndroid.swift +215 -0
- package/nitrogen/generated/ios/swift/RNLocationConfig.swift +2 -16
- package/nitrogen/generated/ios/swift/RNLocationIOS.swift +185 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +47 -15
- package/nitrogen/generated/ios/swift/RNPolygon.swift +66 -1
- package/nitrogen/generated/ios/swift/RNPolygonHole.swift +47 -0
- package/nitrogen/generated/ios/swift/RNPolyline.swift +24 -1
- package/nitrogen/generated/ios/swift/RNSnapshotOptions.swift +1 -8
- package/nitrogen/generated/shared/c++/RNAndroidLocationConfig.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNCamera.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNCircle.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNHeatmap.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNHeatmapGradient.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNHeatmapPoint.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNIOSLocationConfig.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNIndoorBuilding.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNIndoorLevel.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNInitialProps.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNKMLayer.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNLatLng.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNLatLngBounds.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNLocation.hpp +41 -2
- package/nitrogen/generated/shared/c++/RNLocationAndroid.hpp +104 -0
- package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNLocationIOS.hpp +99 -0
- package/nitrogen/generated/shared/c++/RNLocationPermissionResult.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNMapPadding.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNMarker.hpp +17 -1
- package/nitrogen/generated/shared/c++/RNMarkerSvg.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNPolygon.hpp +21 -2
- package/nitrogen/generated/shared/c++/RNPolygonHole.hpp +77 -0
- package/nitrogen/generated/shared/c++/RNPolyline.hpp +13 -1
- package/nitrogen/generated/shared/c++/RNPosition.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNRegion.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNSize.hpp +8 -0
- package/nitrogen/generated/shared/c++/RNSnapshotOptions.hpp +8 -0
- package/package.json +9 -16
- package/src/GoogleMapsPlus.tsx +20 -0
- package/src/index.tsx +6 -14
- package/src/types.ts +36 -0
- package/lib/module/package.json +0 -1
- package/lib/typescript/package.json +0 -1
|
@@ -2,38 +2,85 @@ package com.rngooglemapsplus
|
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
4
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
5
|
-
import com.google.android.gms.maps.model.LatLng
|
|
6
5
|
import com.google.android.gms.maps.model.Polygon
|
|
7
6
|
import com.google.android.gms.maps.model.PolygonOptions
|
|
8
7
|
import com.rngooglemapsplus.extensions.toColor
|
|
8
|
+
import com.rngooglemapsplus.extensions.toLatLng
|
|
9
9
|
|
|
10
10
|
class MapPolygonBuilder {
|
|
11
11
|
fun build(poly: RNPolygon): PolygonOptions =
|
|
12
12
|
PolygonOptions().apply {
|
|
13
13
|
poly.coordinates.forEach { pt ->
|
|
14
14
|
add(
|
|
15
|
-
|
|
16
|
-
.LatLng(pt.latitude, pt.longitude),
|
|
15
|
+
pt.toLatLng(),
|
|
17
16
|
)
|
|
18
17
|
}
|
|
19
18
|
poly.fillColor?.let { fillColor(it.toColor()) }
|
|
20
19
|
poly.strokeColor?.let { strokeColor(it.toColor()) }
|
|
21
20
|
poly.strokeWidth?.let { strokeWidth(it.dpToPx()) }
|
|
22
21
|
poly.pressable?.let { clickable(it) }
|
|
22
|
+
poly.geodesic?.let { geodesic(it) }
|
|
23
|
+
poly.holes?.forEach { hole ->
|
|
24
|
+
addHole(hole.coordinates.map { it.toLatLng() })
|
|
25
|
+
}
|
|
23
26
|
poly.zIndex?.let { zIndex(it.toFloat()) }
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
fun update(
|
|
27
|
-
|
|
30
|
+
prev: RNPolygon,
|
|
28
31
|
next: RNPolygon,
|
|
32
|
+
poly: Polygon,
|
|
29
33
|
) {
|
|
30
|
-
|
|
31
|
-
next.coordinates.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
val coordsChanged =
|
|
35
|
+
prev.coordinates.size != next.coordinates.size ||
|
|
36
|
+
!prev.coordinates.zip(next.coordinates).all { (a, b) ->
|
|
37
|
+
a.latitude == b.latitude && a.longitude == b.longitude
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (coordsChanged) {
|
|
41
|
+
poly.points = next.coordinates.map { it.toLatLng() }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
val prevHoles = prev.holes?.toList() ?: emptyList()
|
|
45
|
+
val nextHoles = next.holes?.toList() ?: emptyList()
|
|
46
|
+
val holesChanged =
|
|
47
|
+
prevHoles.size != nextHoles.size ||
|
|
48
|
+
!prevHoles.zip(nextHoles).all { (ha, hb) ->
|
|
49
|
+
ha.coordinates.size == hb.coordinates.size &&
|
|
50
|
+
ha.coordinates.zip(hb.coordinates).all { (a, b) ->
|
|
51
|
+
a.latitude == b.latitude && a.longitude == b.longitude
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (holesChanged) {
|
|
56
|
+
poly.holes =
|
|
57
|
+
nextHoles.map { hole ->
|
|
58
|
+
hole.coordinates.map { it.toLatLng() }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (prev.fillColor != next.fillColor) {
|
|
63
|
+
poly.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (prev.strokeColor != next.strokeColor) {
|
|
67
|
+
poly.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (prev.strokeWidth != next.strokeWidth) {
|
|
71
|
+
poly.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (prev.pressable != next.pressable) {
|
|
75
|
+
poly.isClickable = next.pressable ?: false
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (prev.geodesic != next.geodesic) {
|
|
79
|
+
poly.isGeodesic = next.geodesic ?: false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (prev.zIndex != next.zIndex) {
|
|
83
|
+
poly.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
84
|
+
}
|
|
38
85
|
}
|
|
39
86
|
}
|
|
@@ -5,18 +5,18 @@ import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
|
5
5
|
import com.google.android.gms.maps.model.ButtCap
|
|
6
6
|
import com.google.android.gms.maps.model.Cap
|
|
7
7
|
import com.google.android.gms.maps.model.JointType
|
|
8
|
-
import com.google.android.gms.maps.model.LatLng
|
|
9
8
|
import com.google.android.gms.maps.model.Polyline
|
|
10
9
|
import com.google.android.gms.maps.model.PolylineOptions
|
|
11
10
|
import com.google.android.gms.maps.model.RoundCap
|
|
12
11
|
import com.google.android.gms.maps.model.SquareCap
|
|
13
12
|
import com.rngooglemapsplus.extensions.toColor
|
|
13
|
+
import com.rngooglemapsplus.extensions.toLatLng
|
|
14
14
|
|
|
15
15
|
class MapPolylineBuilder {
|
|
16
16
|
fun build(pl: RNPolyline): PolylineOptions =
|
|
17
17
|
PolylineOptions().apply {
|
|
18
18
|
pl.coordinates.forEach { pt ->
|
|
19
|
-
add(
|
|
19
|
+
add(pt.toLatLng())
|
|
20
20
|
}
|
|
21
21
|
pl.width?.let { width(it.dpToPx()) }
|
|
22
22
|
pl.lineCap?.let {
|
|
@@ -25,23 +25,58 @@ class MapPolylineBuilder {
|
|
|
25
25
|
}
|
|
26
26
|
pl.lineJoin?.let { jointType(mapLineJoin(it)) }
|
|
27
27
|
pl.color?.let { color(it.toColor()) }
|
|
28
|
+
pl.geodesic?.let { geodesic(it) }
|
|
28
29
|
pl.pressable?.let { clickable(it) }
|
|
29
30
|
pl.zIndex?.let { zIndex(it.toFloat()) }
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
fun update(
|
|
33
|
-
|
|
34
|
+
prev: RNPolyline,
|
|
34
35
|
next: RNPolyline,
|
|
36
|
+
polyline: Polyline,
|
|
35
37
|
) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
val coordsChanged =
|
|
39
|
+
prev.coordinates.size != next.coordinates.size ||
|
|
40
|
+
!prev.coordinates.zip(next.coordinates).all { (a, b) ->
|
|
41
|
+
a.latitude == b.latitude && a.longitude == b.longitude
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (coordsChanged) {
|
|
45
|
+
polyline.points = next.coordinates.map { it.toLatLng() }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (prev.width != next.width) {
|
|
49
|
+
polyline.width = next.width?.dpToPx() ?: 1f
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
val newCap = mapLineCap(next.lineCap ?: RNLineCapType.BUTT)
|
|
53
|
+
val prevCap = mapLineCap(prev.lineCap ?: RNLineCapType.BUTT)
|
|
54
|
+
if (newCap != prevCap) {
|
|
55
|
+
polyline.startCap = newCap
|
|
56
|
+
polyline.endCap = newCap
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
val newJoin = mapLineJoin(next.lineJoin ?: RNLineJoinType.MITER)
|
|
60
|
+
val prevJoin = mapLineJoin(prev.lineJoin ?: RNLineJoinType.MITER)
|
|
61
|
+
if (newJoin != prevJoin) {
|
|
62
|
+
polyline.jointType = newJoin
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (prev.color != next.color) {
|
|
66
|
+
polyline.color = next.color?.toColor() ?: Color.BLACK
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (prev.pressable != next.pressable) {
|
|
70
|
+
polyline.isClickable = next.pressable ?: false
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (prev.geodesic != next.geodesic) {
|
|
74
|
+
polyline.isGeodesic = next.geodesic ?: false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (prev.zIndex != next.zIndex) {
|
|
78
|
+
polyline.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
79
|
+
}
|
|
45
80
|
}
|
|
46
81
|
|
|
47
82
|
private fun mapLineCap(type: RNLineCapType?): Cap =
|
|
@@ -3,6 +3,7 @@ package com.rngooglemapsplus
|
|
|
3
3
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
4
4
|
import com.facebook.react.bridge.UiThreadUtil
|
|
5
5
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.google.android.gms.maps.GoogleMapOptions
|
|
6
7
|
import com.google.android.gms.maps.model.MapStyleOptions
|
|
7
8
|
import com.margelo.nitro.core.Promise
|
|
8
9
|
import com.rngooglemapsplus.extensions.circleEquals
|
|
@@ -40,11 +41,13 @@ class RNGoogleMapsPlusView(
|
|
|
40
41
|
super.afterUpdate()
|
|
41
42
|
if (!propsInitialized) {
|
|
42
43
|
propsInitialized = true
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
val options =
|
|
45
|
+
GoogleMapOptions().apply {
|
|
46
|
+
initialProps?.mapId?.let { mapId(it) }
|
|
47
|
+
initialProps?.liteMode?.let { liteMode(it) }
|
|
48
|
+
initialProps?.camera?.let { camera(it.toCameraPosition()) }
|
|
49
|
+
}
|
|
50
|
+
view.initMapView(options)
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -154,7 +157,7 @@ class RNGoogleMapsPlusView(
|
|
|
154
157
|
} else if (!prev.markerEquals(next)) {
|
|
155
158
|
view.updateMarker(id) { marker ->
|
|
156
159
|
onUi {
|
|
157
|
-
markerBuilder.update(
|
|
160
|
+
markerBuilder.update(prev, next, marker)
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
}
|
|
@@ -178,7 +181,7 @@ class RNGoogleMapsPlusView(
|
|
|
178
181
|
} else if (!prev.polylineEquals(next)) {
|
|
179
182
|
view.updatePolyline(id) { polyline ->
|
|
180
183
|
onUi {
|
|
181
|
-
polylineBuilder.update(
|
|
184
|
+
polylineBuilder.update(prev, next, polyline)
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
187
|
}
|
|
@@ -202,7 +205,7 @@ class RNGoogleMapsPlusView(
|
|
|
202
205
|
view.addPolygon(id, polygonBuilder.build(next))
|
|
203
206
|
} else if (!prev.polygonEquals(next)) {
|
|
204
207
|
view.updatePolygon(id) { polygon ->
|
|
205
|
-
onUi { polygonBuilder.update(
|
|
208
|
+
onUi { polygonBuilder.update(prev, next, polygon) }
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
}
|
|
@@ -226,7 +229,7 @@ class RNGoogleMapsPlusView(
|
|
|
226
229
|
} else if (!prev.circleEquals(next)) {
|
|
227
230
|
view.updateCircle(id) { circle ->
|
|
228
231
|
onUi {
|
|
229
|
-
circleBuilder.update(
|
|
232
|
+
circleBuilder.update(prev, next, circle)
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.CameraPosition
|
|
4
|
+
import com.rngooglemapsplus.RNCamera
|
|
5
|
+
|
|
6
|
+
fun CameraPosition.toRnCamera(): RNCamera =
|
|
7
|
+
RNCamera(
|
|
8
|
+
center = target.toRnLatLng(),
|
|
9
|
+
zoom = zoom.toDouble(),
|
|
10
|
+
bearing = bearing.toDouble(),
|
|
11
|
+
tilt = tilt.toDouble(),
|
|
12
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.common.ConnectionResult
|
|
4
|
+
import com.rngooglemapsplus.RNMapErrorCode
|
|
5
|
+
|
|
6
|
+
fun Int.toRNMapErrorCodeOrNull(): RNMapErrorCode? =
|
|
7
|
+
when (this) {
|
|
8
|
+
ConnectionResult.SERVICE_MISSING ->
|
|
9
|
+
RNMapErrorCode.PLAY_SERVICES_MISSING
|
|
10
|
+
|
|
11
|
+
ConnectionResult.SERVICE_INVALID ->
|
|
12
|
+
RNMapErrorCode.PLAY_SERVICES_INVALID
|
|
13
|
+
|
|
14
|
+
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED ->
|
|
15
|
+
RNMapErrorCode.PLAY_SERVICES_OUTDATED
|
|
16
|
+
|
|
17
|
+
ConnectionResult.SERVICE_UPDATING ->
|
|
18
|
+
RNMapErrorCode.PLAY_SERVICE_UPDATING
|
|
19
|
+
|
|
20
|
+
ConnectionResult.SERVICE_DISABLED ->
|
|
21
|
+
RNMapErrorCode.PLAY_SERVICES_DISABLED
|
|
22
|
+
|
|
23
|
+
ConnectionResult.SUCCESS ->
|
|
24
|
+
null
|
|
25
|
+
|
|
26
|
+
else ->
|
|
27
|
+
RNMapErrorCode.UNKNOWN
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.LatLngBounds
|
|
4
|
+
import com.rngooglemapsplus.RNRegion
|
|
5
|
+
|
|
6
|
+
fun LatLngBounds.toRnRegion(): RNRegion {
|
|
7
|
+
val latDelta = northeast.latitude - southwest.latitude
|
|
8
|
+
val lngDelta = northeast.longitude - southwest.longitude
|
|
9
|
+
|
|
10
|
+
return RNRegion(
|
|
11
|
+
center = center.toRnLatLng(),
|
|
12
|
+
latitudeDelta = latDelta,
|
|
13
|
+
longitudeDelta = lngDelta,
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import android.location.Location
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import com.rngooglemapsplus.RNLatLng
|
|
6
|
+
import com.rngooglemapsplus.RNLocation
|
|
7
|
+
import com.rngooglemapsplus.RNLocationAndroid
|
|
8
|
+
|
|
9
|
+
fun Location.toRnLocation(): RNLocation =
|
|
10
|
+
RNLocation(
|
|
11
|
+
center = RNLatLng(latitude, longitude),
|
|
12
|
+
altitude = altitude,
|
|
13
|
+
accuracy = accuracy.toDouble(),
|
|
14
|
+
bearing = bearing.toDouble(),
|
|
15
|
+
speed = speed.toDouble(),
|
|
16
|
+
time = time.toDouble(),
|
|
17
|
+
android =
|
|
18
|
+
RNLocationAndroid(
|
|
19
|
+
provider = provider,
|
|
20
|
+
elapsedRealtimeNanos = elapsedRealtimeNanos.toDouble(),
|
|
21
|
+
bearingAccuracyDegrees =
|
|
22
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
23
|
+
bearingAccuracyDegrees.toDouble()
|
|
24
|
+
} else {
|
|
25
|
+
null
|
|
26
|
+
},
|
|
27
|
+
speedAccuracyMetersPerSecond =
|
|
28
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
29
|
+
speedAccuracyMetersPerSecond.toDouble()
|
|
30
|
+
} else {
|
|
31
|
+
null
|
|
32
|
+
},
|
|
33
|
+
verticalAccuracyMeters =
|
|
34
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
35
|
+
verticalAccuracyMeters.toDouble()
|
|
36
|
+
} else {
|
|
37
|
+
null
|
|
38
|
+
},
|
|
39
|
+
mslAltitudeMeters =
|
|
40
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
|
41
|
+
mslAltitudeMeters
|
|
42
|
+
} else {
|
|
43
|
+
null
|
|
44
|
+
},
|
|
45
|
+
mslAltitudeAccuracyMeters =
|
|
46
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
|
47
|
+
mslAltitudeAccuracyMeters.toDouble()
|
|
48
|
+
} else {
|
|
49
|
+
null
|
|
50
|
+
},
|
|
51
|
+
isMock =
|
|
52
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
53
|
+
isMock
|
|
54
|
+
} else {
|
|
55
|
+
isFromMockProvider
|
|
56
|
+
},
|
|
57
|
+
),
|
|
58
|
+
ios = null,
|
|
59
|
+
)
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
package com.rngooglemapsplus.extensions
|
|
2
2
|
|
|
3
3
|
import com.google.android.gms.maps.model.CameraPosition
|
|
4
|
-
import com.google.android.gms.maps.model.LatLng
|
|
5
4
|
import com.rngooglemapsplus.RNCamera
|
|
6
5
|
|
|
7
6
|
fun RNCamera.toCameraPosition(): CameraPosition {
|
|
8
7
|
val builder = CameraPosition.builder()
|
|
9
8
|
|
|
10
9
|
center?.let {
|
|
11
|
-
builder.target(
|
|
10
|
+
builder.target(it.toLatLng())
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
zoom?.let { builder.zoom(it.toFloat()) }
|
|
@@ -7,6 +7,14 @@ fun RNMarker.markerEquals(b: RNMarker): Boolean =
|
|
|
7
7
|
zIndex == b.zIndex &&
|
|
8
8
|
coordinate == b.coordinate &&
|
|
9
9
|
anchor == b.anchor &&
|
|
10
|
+
showInfoWindow == b.showInfoWindow &&
|
|
11
|
+
title == b.title &&
|
|
12
|
+
snippet == b.snippet &&
|
|
13
|
+
opacity == b.opacity &&
|
|
14
|
+
flat == b.flat &&
|
|
15
|
+
draggable == b.draggable &&
|
|
16
|
+
rotation == b.rotation &&
|
|
17
|
+
infoWindowAnchor == b.infoWindowAnchor &&
|
|
10
18
|
markerStyleEquals(b)
|
|
11
19
|
|
|
12
20
|
fun RNMarker.markerStyleEquals(b: RNMarker): Boolean = iconSvg == b.iconSvg
|
|
@@ -8,6 +8,8 @@ fun RNPolygon.polygonEquals(b: RNPolygon): Boolean {
|
|
|
8
8
|
if (strokeWidth != b.strokeWidth) return false
|
|
9
9
|
if (fillColor != b.fillColor) return false
|
|
10
10
|
if (strokeColor != b.strokeColor) return false
|
|
11
|
+
if (geodesic != b.geodesic) return false
|
|
12
|
+
if (!holes.contentEquals(b.holes)) return false
|
|
11
13
|
val ac = coordinates
|
|
12
14
|
val bc = b.coordinates
|
|
13
15
|
if (ac.size != bc.size) return false
|
|
@@ -8,6 +8,7 @@ fun RNPolyline.polylineEquals(b: RNPolyline): Boolean {
|
|
|
8
8
|
if ((width ?: 0.0) != (b.width ?: 0.0)) return false
|
|
9
9
|
if (lineCap != b.lineCap) return false
|
|
10
10
|
if (lineJoin != b.lineJoin) return false
|
|
11
|
+
if (geodesic != b.geodesic) return false
|
|
11
12
|
if (color != b.color) return false
|
|
12
13
|
val ac = coordinates
|
|
13
14
|
val bc = b.coordinates
|