react-native-google-maps-plus 1.3.0 → 1.4.0
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 +15 -23
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +4 -3
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +11 -7
- package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +18 -10
- package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +6 -4
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +8 -5
- package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngExtension.kt +6 -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 +18 -49
- package/ios/MapCircleBuilder.swift +2 -10
- package/ios/MapMarkerBuilder.swift +12 -10
- package/ios/MapPolygonBuilder.swift +17 -2
- package/ios/MapPolylineBuilder.swift +4 -2
- package/ios/RNGoogleMapsPlusView.swift +7 -5
- package/ios/extensions/CLLocationCoordinate2D+Extension.swift +7 -0
- package/ios/extensions/RNLatLng+Extension.swift +7 -0
- package/ios/extensions/RNMarker+Extension.swift +5 -0
- package/ios/extensions/RNPolygon+Extension.swift.swift +16 -1
- package/ios/extensions/RNPolyline+Extension.swift.swift +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/types.d.ts +8 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +4 -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/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 +1 -1
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +16 -16
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +51 -20
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +6 -3
- 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/RNLocationConfig.swift +2 -16
- 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 +8 -0
- package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +8 -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 +4 -4
- package/src/types.ts +9 -0
package/android/build.gradle
CHANGED
|
@@ -28,7 +28,7 @@ apply from: "./fix-prefab.gradle"
|
|
|
28
28
|
if (rootProject.name != "rngooglemapsplus.example") {
|
|
29
29
|
apply plugin: "com.facebook.react"
|
|
30
30
|
} else {
|
|
31
|
-
println("\u001B[
|
|
31
|
+
println("\u001B[33mSkipping React Native Gradle plugin in library (example build detected)\u001B[0m")
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
def getExtOrIntegerDefault(name) {
|
|
@@ -35,9 +35,11 @@ import com.google.android.gms.maps.model.TileOverlayOptions
|
|
|
35
35
|
import com.google.maps.android.data.kml.KmlLayer
|
|
36
36
|
import com.margelo.nitro.core.Promise
|
|
37
37
|
import com.rngooglemapsplus.extensions.toGooglePriority
|
|
38
|
+
import com.rngooglemapsplus.extensions.toLatLng
|
|
38
39
|
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
39
40
|
import com.rngooglemapsplus.extensions.toRNIndoorBuilding
|
|
40
41
|
import com.rngooglemapsplus.extensions.toRNIndoorLevel
|
|
42
|
+
import com.rngooglemapsplus.extensions.toRnLatLng
|
|
41
43
|
import java.io.ByteArrayInputStream
|
|
42
44
|
import java.io.ByteArrayOutputStream
|
|
43
45
|
import java.io.File
|
|
@@ -88,11 +90,7 @@ class GoogleMapsViewImpl(
|
|
|
88
90
|
reactContext.addLifecycleEventListener(this)
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
fun initMapView(
|
|
92
|
-
mapId: String?,
|
|
93
|
-
liteMode: Boolean?,
|
|
94
|
-
cameraPosition: CameraPosition?,
|
|
95
|
-
) {
|
|
93
|
+
fun initMapView(googleMapsOptions: GoogleMapOptions) {
|
|
96
94
|
if (initialized) return
|
|
97
95
|
initialized = true
|
|
98
96
|
val result = playServiceHandler.playServicesAvailability()
|
|
@@ -126,13 +124,7 @@ class GoogleMapsViewImpl(
|
|
|
126
124
|
mapView =
|
|
127
125
|
MapView(
|
|
128
126
|
reactContext,
|
|
129
|
-
|
|
130
|
-
mapId?.let { mapId(it) }
|
|
131
|
-
liteMode?.let { liteMode(it) }
|
|
132
|
-
cameraPosition?.let {
|
|
133
|
-
camera(it)
|
|
134
|
-
}
|
|
135
|
-
},
|
|
127
|
+
googleMapsOptions,
|
|
136
128
|
)
|
|
137
129
|
|
|
138
130
|
super.addView(mapView)
|
|
@@ -173,12 +165,12 @@ class GoogleMapsViewImpl(
|
|
|
173
165
|
|
|
174
166
|
onCameraChangeStart?.invoke(
|
|
175
167
|
RNRegion(
|
|
176
|
-
center =
|
|
168
|
+
center = bounds.center.toRnLatLng(),
|
|
177
169
|
latitudeDelta = latDelta,
|
|
178
170
|
longitudeDelta = lngDelta,
|
|
179
171
|
),
|
|
180
172
|
RNCamera(
|
|
181
|
-
center =
|
|
173
|
+
center = cameraPosition.target.toRnLatLng(),
|
|
182
174
|
zoom = cameraPosition.zoom.toDouble(),
|
|
183
175
|
bearing = cameraPosition.bearing.toDouble(),
|
|
184
176
|
tilt = cameraPosition.tilt.toDouble(),
|
|
@@ -205,12 +197,12 @@ class GoogleMapsViewImpl(
|
|
|
205
197
|
|
|
206
198
|
onCameraChange?.invoke(
|
|
207
199
|
RNRegion(
|
|
208
|
-
center =
|
|
200
|
+
center = bounds.center.toRnLatLng(),
|
|
209
201
|
latitudeDelta = latDelta,
|
|
210
202
|
longitudeDelta = lngDelta,
|
|
211
203
|
),
|
|
212
204
|
RNCamera(
|
|
213
|
-
center =
|
|
205
|
+
center = cameraPosition.target.toRnLatLng(),
|
|
214
206
|
zoom = cameraPosition.zoom.toDouble(),
|
|
215
207
|
bearing = cameraPosition.bearing.toDouble(),
|
|
216
208
|
tilt = cameraPosition.tilt.toDouble(),
|
|
@@ -233,12 +225,12 @@ class GoogleMapsViewImpl(
|
|
|
233
225
|
|
|
234
226
|
onCameraChangeComplete?.invoke(
|
|
235
227
|
RNRegion(
|
|
236
|
-
center =
|
|
228
|
+
center = bounds.center.toRnLatLng(),
|
|
237
229
|
latitudeDelta = latDelta,
|
|
238
230
|
longitudeDelta = lngDelta,
|
|
239
231
|
),
|
|
240
232
|
RNCamera(
|
|
241
|
-
center =
|
|
233
|
+
center = cameraPosition.target.toRnLatLng(),
|
|
242
234
|
zoom = cameraPosition.zoom.toDouble(),
|
|
243
235
|
bearing = cameraPosition.bearing.toDouble(),
|
|
244
236
|
tilt = cameraPosition.tilt.toDouble(),
|
|
@@ -544,7 +536,7 @@ class GoogleMapsViewImpl(
|
|
|
544
536
|
onUi {
|
|
545
537
|
val builder = LatLngBounds.Builder()
|
|
546
538
|
coordinates.forEach { coord ->
|
|
547
|
-
builder.include(
|
|
539
|
+
builder.include(coord.toLatLng())
|
|
548
540
|
}
|
|
549
541
|
val bounds = builder.build()
|
|
550
542
|
|
|
@@ -1069,28 +1061,28 @@ class GoogleMapsViewImpl(
|
|
|
1069
1061
|
|
|
1070
1062
|
override fun onMapClick(coordinates: LatLng) {
|
|
1071
1063
|
onMapPress?.invoke(
|
|
1072
|
-
|
|
1064
|
+
coordinates.toRnLatLng(),
|
|
1073
1065
|
)
|
|
1074
1066
|
}
|
|
1075
1067
|
|
|
1076
1068
|
override fun onMarkerDragStart(marker: Marker) {
|
|
1077
1069
|
onMarkerDragStart?.invoke(
|
|
1078
1070
|
marker.tag?.toString(),
|
|
1079
|
-
|
|
1071
|
+
marker.position.toRnLatLng(),
|
|
1080
1072
|
)
|
|
1081
1073
|
}
|
|
1082
1074
|
|
|
1083
1075
|
override fun onMarkerDrag(marker: Marker) {
|
|
1084
1076
|
onMarkerDrag?.invoke(
|
|
1085
1077
|
marker.tag?.toString(),
|
|
1086
|
-
|
|
1078
|
+
marker.position.toRnLatLng(),
|
|
1087
1079
|
)
|
|
1088
1080
|
}
|
|
1089
1081
|
|
|
1090
1082
|
override fun onMarkerDragEnd(marker: Marker) {
|
|
1091
1083
|
onMarkerDragEnd?.invoke(
|
|
1092
1084
|
marker.tag?.toString(),
|
|
1093
|
-
|
|
1085
|
+
marker.position.toRnLatLng(),
|
|
1094
1086
|
)
|
|
1095
1087
|
}
|
|
1096
1088
|
|
|
@@ -4,13 +4,13 @@ import android.graphics.Color
|
|
|
4
4
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
5
5
|
import com.google.android.gms.maps.model.Circle
|
|
6
6
|
import com.google.android.gms.maps.model.CircleOptions
|
|
7
|
-
import com.google.android.gms.maps.model.LatLng
|
|
8
7
|
import com.rngooglemapsplus.extensions.toColor
|
|
8
|
+
import com.rngooglemapsplus.extensions.toLatLng
|
|
9
9
|
|
|
10
10
|
class MapCircleBuilder {
|
|
11
11
|
fun build(circle: RNCircle): CircleOptions =
|
|
12
12
|
CircleOptions().apply {
|
|
13
|
-
center(
|
|
13
|
+
center(circle.center.toLatLng())
|
|
14
14
|
radius(circle.radius)
|
|
15
15
|
circle.strokeWidth?.let { strokeWidth(it.dpToPx()) }
|
|
16
16
|
circle.strokeColor?.let { strokeColor(it.toColor()) }
|
|
@@ -23,11 +23,12 @@ class MapCircleBuilder {
|
|
|
23
23
|
circle: Circle,
|
|
24
24
|
next: RNCircle,
|
|
25
25
|
) {
|
|
26
|
-
circle.center =
|
|
26
|
+
circle.center = next.center.toLatLng()
|
|
27
27
|
circle.radius = next.radius
|
|
28
28
|
circle.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
29
29
|
circle.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
30
30
|
circle.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
31
|
+
circle.isClickable = next.pressable ?: false
|
|
31
32
|
circle.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -8,11 +8,11 @@ import com.caverock.androidsvg.SVG
|
|
|
8
8
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
9
9
|
import com.google.android.gms.maps.model.BitmapDescriptor
|
|
10
10
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
|
11
|
-
import com.google.android.gms.maps.model.LatLng
|
|
12
11
|
import com.google.android.gms.maps.model.Marker
|
|
13
12
|
import com.google.android.gms.maps.model.MarkerOptions
|
|
14
13
|
import com.rngooglemapsplus.extensions.markerStyleEquals
|
|
15
14
|
import com.rngooglemapsplus.extensions.styleHash
|
|
15
|
+
import com.rngooglemapsplus.extensions.toLatLng
|
|
16
16
|
import kotlinx.coroutines.CoroutineScope
|
|
17
17
|
import kotlinx.coroutines.Dispatchers
|
|
18
18
|
import kotlinx.coroutines.Job
|
|
@@ -40,13 +40,15 @@ class MapMarkerBuilder(
|
|
|
40
40
|
icon: BitmapDescriptor?,
|
|
41
41
|
): MarkerOptions =
|
|
42
42
|
MarkerOptions().apply {
|
|
43
|
-
position(
|
|
43
|
+
position(m.coordinate.toLatLng())
|
|
44
44
|
icon(icon)
|
|
45
45
|
m.title?.let { title(it) }
|
|
46
46
|
m.snippet?.let { snippet(it) }
|
|
47
47
|
m.opacity?.let { alpha(it.toFloat()) }
|
|
48
48
|
m.flat?.let { flat(it) }
|
|
49
49
|
m.draggable?.let { draggable(it) }
|
|
50
|
+
m.rotation?.let { rotation(it.toFloat()) }
|
|
51
|
+
m.infoWindowAnchor?.let { infoWindowAnchor(it.x.toFloat(), it.y.toFloat()) }
|
|
50
52
|
m.anchor?.let { anchor((m.anchor.x).toFloat(), (m.anchor.y).toFloat()) }
|
|
51
53
|
m.zIndex?.let { zIndex(it.toFloat()) }
|
|
52
54
|
}
|
|
@@ -57,10 +59,7 @@ class MapMarkerBuilder(
|
|
|
57
59
|
next: RNMarker,
|
|
58
60
|
) {
|
|
59
61
|
marker.position =
|
|
60
|
-
|
|
61
|
-
next.coordinate.latitude,
|
|
62
|
-
next.coordinate.longitude,
|
|
63
|
-
)
|
|
62
|
+
next.coordinate.toLatLng()
|
|
64
63
|
|
|
65
64
|
if (!prev.markerStyleEquals(next)) {
|
|
66
65
|
buildIconAsync(marker.id, next) { icon ->
|
|
@@ -69,9 +68,14 @@ class MapMarkerBuilder(
|
|
|
69
68
|
}
|
|
70
69
|
marker.title = next.title
|
|
71
70
|
marker.snippet = next.snippet
|
|
72
|
-
marker.alpha = next.opacity?.toFloat() ?:
|
|
71
|
+
marker.alpha = next.opacity?.toFloat() ?: 1f
|
|
73
72
|
marker.isFlat = next.flat ?: false
|
|
74
73
|
marker.isDraggable = next.draggable ?: false
|
|
74
|
+
marker.rotation = next.rotation?.toFloat() ?: 0f
|
|
75
|
+
marker.setInfoWindowAnchor(
|
|
76
|
+
(next.infoWindowAnchor?.x ?: 0.5).toFloat(),
|
|
77
|
+
(next.infoWindowAnchor?.y ?: 0).toFloat(),
|
|
78
|
+
)
|
|
75
79
|
marker.setAnchor(
|
|
76
80
|
(next.anchor?.x ?: 0.5).toFloat(),
|
|
77
81
|
(next.anchor?.y ?: 1.0).toFloat(),
|
|
@@ -2,38 +2,46 @@ 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
|
+
poly: Polygon,
|
|
28
31
|
next: RNPolygon,
|
|
29
32
|
) {
|
|
30
|
-
|
|
33
|
+
poly.points =
|
|
31
34
|
next.coordinates.map {
|
|
32
|
-
|
|
35
|
+
it.toLatLng()
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
poly.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
38
|
+
poly.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
39
|
+
poly.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
40
|
+
poly.isClickable = next.pressable ?: false
|
|
41
|
+
poly.isGeodesic = next.geodesic ?: false
|
|
42
|
+
poly.holes = next.holes?.map { hole ->
|
|
43
|
+
hole.coordinates.map { it.toLatLng() }
|
|
44
|
+
} ?: emptyList()
|
|
45
|
+
poly.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
38
46
|
}
|
|
39
47
|
}
|
|
@@ -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,6 +25,7 @@ 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
|
}
|
|
@@ -33,14 +34,15 @@ class MapPolylineBuilder {
|
|
|
33
34
|
polyline: Polyline,
|
|
34
35
|
next: RNPolyline,
|
|
35
36
|
) {
|
|
36
|
-
polyline.points = next.coordinates.map {
|
|
37
|
-
|
|
37
|
+
polyline.points = next.coordinates.map { it.toLatLng() }
|
|
38
38
|
polyline.width = next.width?.dpToPx() ?: 1f
|
|
39
39
|
val cap = mapLineCap(next.lineCap ?: RNLineCapType.BUTT)
|
|
40
40
|
polyline.startCap = cap
|
|
41
41
|
polyline.endCap = cap
|
|
42
42
|
polyline.jointType = mapLineJoin(next.lineJoin ?: RNLineJoinType.MITER)
|
|
43
43
|
polyline.color = next.color?.toColor() ?: Color.BLACK
|
|
44
|
+
polyline.isClickable = next.pressable ?: false
|
|
45
|
+
polyline.isGeodesic = next.geodesic ?: false
|
|
44
46
|
polyline.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -62,17 +62,12 @@ GMSIndoorDisplayDelegate {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@MainActor
|
|
65
|
-
func initMapView(
|
|
65
|
+
func initMapView(googleMapOptions: GMSMapViewOptions) {
|
|
66
66
|
if initialized { return }
|
|
67
67
|
initialized = true
|
|
68
|
-
|
|
69
|
-
options.frame = bounds
|
|
68
|
+
googleMapOptions.frame = bounds
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
liteMode.map { _ in /* not supported */ }
|
|
73
|
-
camera.map { options.camera = $0 }
|
|
74
|
-
|
|
75
|
-
mapView = GMSMapView.init(options: options)
|
|
70
|
+
mapView = GMSMapView.init(options: googleMapOptions)
|
|
76
71
|
mapView?.delegate = self
|
|
77
72
|
mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
78
73
|
mapView?.paddingAdjustmentBehavior = .never
|
|
@@ -93,10 +88,7 @@ GMSIndoorDisplayDelegate {
|
|
|
93
88
|
!= loc.coordinate.longitude {
|
|
94
89
|
self.onLocationUpdate?(
|
|
95
90
|
RNLocation(
|
|
96
|
-
|
|
97
|
-
latitude: loc.coordinate.latitude,
|
|
98
|
-
longitude: loc.coordinate.longitude
|
|
99
|
-
),
|
|
91
|
+
loc.coordinate.toRNLatLng(),
|
|
100
92
|
loc.course
|
|
101
93
|
)
|
|
102
94
|
)
|
|
@@ -348,27 +340,16 @@ GMSIndoorDisplayDelegate {
|
|
|
348
340
|
animated: Bool,
|
|
349
341
|
durationMs: Double
|
|
350
342
|
) {
|
|
351
|
-
|
|
343
|
+
guard let firstCoordinates = coordinates.first else {
|
|
352
344
|
return
|
|
353
345
|
}
|
|
354
346
|
var bounds = GMSCoordinateBounds(
|
|
355
|
-
coordinate:
|
|
356
|
-
|
|
357
|
-
longitude: coordinates[0].longitude
|
|
358
|
-
),
|
|
359
|
-
coordinate: CLLocationCoordinate2D(
|
|
360
|
-
latitude: coordinates[0].latitude,
|
|
361
|
-
longitude: coordinates[0].longitude
|
|
362
|
-
)
|
|
347
|
+
coordinate: firstCoordinates.toCLLocationCoordinate2D(),
|
|
348
|
+
coordinate: firstCoordinates.toCLLocationCoordinate2D()
|
|
363
349
|
)
|
|
364
350
|
|
|
365
351
|
for coord in coordinates.dropFirst() {
|
|
366
|
-
bounds = bounds.includingCoordinate(
|
|
367
|
-
CLLocationCoordinate2D(
|
|
368
|
-
latitude: coord.latitude,
|
|
369
|
-
longitude: coord.longitude
|
|
370
|
-
)
|
|
371
|
-
)
|
|
352
|
+
bounds = bounds.includingCoordinate(coord.toCLLocationCoordinate2D())
|
|
372
353
|
}
|
|
373
354
|
|
|
374
355
|
let insets = UIEdgeInsets(
|
|
@@ -736,15 +717,12 @@ GMSIndoorDisplayDelegate {
|
|
|
736
717
|
|
|
737
718
|
let cp = mapView.camera
|
|
738
719
|
let region = RNRegion(
|
|
739
|
-
center:
|
|
720
|
+
center: center.toRNLatLng(),
|
|
740
721
|
latitudeDelta: latDelta,
|
|
741
722
|
longitudeDelta: lngDelta
|
|
742
723
|
)
|
|
743
724
|
let cam = RNCamera(
|
|
744
|
-
center:
|
|
745
|
-
latitude: cp.target.latitude,
|
|
746
|
-
longitude: cp.target.longitude
|
|
747
|
-
),
|
|
725
|
+
center: cp.target.toRNLatLng(),
|
|
748
726
|
zoom: Double(cp.zoom),
|
|
749
727
|
bearing: cp.bearing,
|
|
750
728
|
tilt: cp.viewingAngle
|
|
@@ -781,15 +759,12 @@ GMSIndoorDisplayDelegate {
|
|
|
781
759
|
|
|
782
760
|
let cp = mapView.camera
|
|
783
761
|
let region = RNRegion(
|
|
784
|
-
center:
|
|
762
|
+
center: center.toRNLatLng(),
|
|
785
763
|
latitudeDelta: latDelta,
|
|
786
764
|
longitudeDelta: lngDelta
|
|
787
765
|
)
|
|
788
766
|
let cam = RNCamera(
|
|
789
|
-
center:
|
|
790
|
-
latitude: cp.target.latitude,
|
|
791
|
-
longitude: cp.target.longitude
|
|
792
|
-
),
|
|
767
|
+
center: cp.target.toRNLatLng(),
|
|
793
768
|
zoom: Double(cp.zoom),
|
|
794
769
|
bearing: cp.bearing,
|
|
795
770
|
tilt: cp.viewingAngle
|
|
@@ -814,15 +789,12 @@ GMSIndoorDisplayDelegate {
|
|
|
814
789
|
|
|
815
790
|
let cp = mapView.camera
|
|
816
791
|
let region = RNRegion(
|
|
817
|
-
center:
|
|
792
|
+
center: center.toRNLatLng(),
|
|
818
793
|
latitudeDelta: latDelta,
|
|
819
794
|
longitudeDelta: lngDelta
|
|
820
795
|
)
|
|
821
796
|
let cam = RNCamera(
|
|
822
|
-
center:
|
|
823
|
-
latitude: cp.target.latitude,
|
|
824
|
-
longitude: cp.target.longitude
|
|
825
|
-
),
|
|
797
|
+
center: cp.target.toRNLatLng(),
|
|
826
798
|
zoom: Double(cp.zoom),
|
|
827
799
|
bearing: cp.bearing,
|
|
828
800
|
tilt: cp.viewingAngle
|
|
@@ -837,10 +809,7 @@ GMSIndoorDisplayDelegate {
|
|
|
837
809
|
) {
|
|
838
810
|
onMain {
|
|
839
811
|
self.onMapPress?(
|
|
840
|
-
|
|
841
|
-
latitude: coordinate.latitude,
|
|
842
|
-
longitude: coordinate.longitude
|
|
843
|
-
)
|
|
812
|
+
coordinate.toRNLatLng(),
|
|
844
813
|
)
|
|
845
814
|
}
|
|
846
815
|
}
|
|
@@ -875,7 +844,7 @@ GMSIndoorDisplayDelegate {
|
|
|
875
844
|
onMain {
|
|
876
845
|
self.onMarkerDragStart?(
|
|
877
846
|
marker.userData as? String,
|
|
878
|
-
|
|
847
|
+
marker.position.toRNLatLng()
|
|
879
848
|
)
|
|
880
849
|
}
|
|
881
850
|
}
|
|
@@ -884,7 +853,7 @@ GMSIndoorDisplayDelegate {
|
|
|
884
853
|
onMain {
|
|
885
854
|
self.onMarkerDrag?(
|
|
886
855
|
marker.userData as? String,
|
|
887
|
-
|
|
856
|
+
marker.position.toRNLatLng()
|
|
888
857
|
)
|
|
889
858
|
}
|
|
890
859
|
}
|
|
@@ -893,7 +862,7 @@ GMSIndoorDisplayDelegate {
|
|
|
893
862
|
onMain {
|
|
894
863
|
self.onMarkerDragEnd?(
|
|
895
864
|
marker.userData as? String,
|
|
896
|
-
|
|
865
|
+
marker.position.toRNLatLng()
|
|
897
866
|
)
|
|
898
867
|
}
|
|
899
868
|
}
|
|
@@ -3,11 +3,7 @@ import GoogleMaps
|
|
|
3
3
|
final class MapCircleBuilder {
|
|
4
4
|
func build(_ c: RNCircle) -> GMSCircle {
|
|
5
5
|
let circle = GMSCircle()
|
|
6
|
-
circle.position =
|
|
7
|
-
latitude: c.center.latitude,
|
|
8
|
-
longitude: c.center.longitude
|
|
9
|
-
)
|
|
10
|
-
|
|
6
|
+
circle.position = c.center.toCLLocationCoordinate2D()
|
|
11
7
|
circle.radius = c.radius
|
|
12
8
|
c.fillColor.map { circle.fillColor = $0.toUIColor() }
|
|
13
9
|
c.strokeColor.map { circle.strokeColor = $0.toUIColor() }
|
|
@@ -19,11 +15,7 @@ final class MapCircleBuilder {
|
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
func update(_ next: RNCircle, _ c: GMSCircle) {
|
|
22
|
-
c.position =
|
|
23
|
-
latitude: next.center.latitude,
|
|
24
|
-
longitude: next.center.longitude
|
|
25
|
-
)
|
|
26
|
-
|
|
18
|
+
c.position = next.center.toCLLocationCoordinate2D()
|
|
27
19
|
c.radius = next.radius
|
|
28
20
|
c.fillColor = next.fillColor?.toUIColor() ?? nil
|
|
29
21
|
c.strokeColor = next.strokeColor?.toUIColor() ?? .black
|
|
@@ -13,10 +13,7 @@ final class MapMarkerBuilder {
|
|
|
13
13
|
|
|
14
14
|
func build(_ m: RNMarker, icon: UIImage?) -> GMSMarker {
|
|
15
15
|
let marker = GMSMarker(
|
|
16
|
-
position:
|
|
17
|
-
latitude: m.coordinate.latitude,
|
|
18
|
-
longitude: m.coordinate.longitude
|
|
19
|
-
)
|
|
16
|
+
position: m.coordinate.toCLLocationCoordinate2D()
|
|
20
17
|
)
|
|
21
18
|
marker.userData = m.id
|
|
22
19
|
marker.tracksViewChanges = true
|
|
@@ -26,6 +23,10 @@ final class MapMarkerBuilder {
|
|
|
26
23
|
m.opacity.map { marker.iconView?.alpha = CGFloat($0) }
|
|
27
24
|
m.flat.map { marker.isFlat = $0 }
|
|
28
25
|
m.draggable.map { marker.isDraggable = $0 }
|
|
26
|
+
m.rotation.map { marker.rotation = $0 }
|
|
27
|
+
m.infoWindowAnchor.map {
|
|
28
|
+
marker.infoWindowAnchor = CGPoint(x: $0.x, y: $0.y)
|
|
29
|
+
}
|
|
29
30
|
m.anchor.map {
|
|
30
31
|
marker.groundAnchor = CGPoint(
|
|
31
32
|
x: $0.x,
|
|
@@ -43,16 +44,17 @@ final class MapMarkerBuilder {
|
|
|
43
44
|
|
|
44
45
|
@MainActor
|
|
45
46
|
func update(_ prev: RNMarker, _ next: RNMarker, _ m: GMSMarker) {
|
|
46
|
-
m.position =
|
|
47
|
-
latitude: next.coordinate.latitude,
|
|
48
|
-
longitude: next.coordinate.longitude
|
|
49
|
-
)
|
|
50
|
-
|
|
47
|
+
m.position = next.coordinate.toCLLocationCoordinate2D()
|
|
51
48
|
m.title = next.title
|
|
52
49
|
m.snippet = next.snippet
|
|
53
|
-
m.iconView?.alpha = CGFloat(next.opacity ??
|
|
50
|
+
m.iconView?.alpha = CGFloat(next.opacity ?? 1)
|
|
54
51
|
m.isFlat = next.flat ?? false
|
|
55
52
|
m.isDraggable = next.draggable ?? false
|
|
53
|
+
m.rotation = next.rotation ?? 0
|
|
54
|
+
m.infoWindowAnchor = CGPoint(
|
|
55
|
+
x: next.infoWindowAnchor?.x ?? 0.5,
|
|
56
|
+
y: next.infoWindowAnchor?.y ?? 0
|
|
57
|
+
)
|
|
56
58
|
m.zIndex = Int32(next.zIndex ?? 0)
|
|
57
59
|
m.groundAnchor = CGPoint(
|
|
58
60
|
x: next.anchor?.x ?? 0.5,
|