react-native-google-maps-plus 1.3.0-dev.3 → 1.3.0-dev.5
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/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +21 -26
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +4 -3
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +10 -6
- 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 +17 -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/ios/GoogleMapViewImpl.swift +42 -63
- package/ios/MapCircleBuilder.swift +2 -10
- package/ios/MapMarkerBuilder.swift +11 -9
- package/ios/MapPolygonBuilder.swift +17 -2
- package/ios/MapPolylineBuilder.swift +4 -2
- package/ios/RNGoogleMapsPlusView.swift +16 -11
- package/ios/extensions/CLLocationCoordinate2D+Extension.swift +7 -0
- package/ios/extensions/RNLatLng+Extension.swift +7 -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/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +29 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +7 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +54 -1
- 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/shared/c++/RNMarker.hpp +9 -1
- package/nitrogen/generated/shared/c++/RNPolygon.hpp +13 -2
- package/nitrogen/generated/shared/c++/RNPolygonHole.hpp +69 -0
- package/nitrogen/generated/shared/c++/RNPolyline.hpp +5 -1
- package/package.json +1 -1
- package/src/types.ts +9 -0
|
@@ -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)
|
|
@@ -153,9 +145,9 @@ class GoogleMapsViewImpl(
|
|
|
153
145
|
}
|
|
154
146
|
initLocationCallbacks()
|
|
155
147
|
applyPending()
|
|
148
|
+
mapReady = true
|
|
149
|
+
onMapReady?.invoke(true)
|
|
156
150
|
}
|
|
157
|
-
mapReady = true
|
|
158
|
-
onMapReady?.invoke(true)
|
|
159
151
|
}
|
|
160
152
|
|
|
161
153
|
override fun onCameraMoveStarted(reason: Int) {
|
|
@@ -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(),
|
|
@@ -372,6 +364,8 @@ class GoogleMapsViewImpl(
|
|
|
372
364
|
}
|
|
373
365
|
}
|
|
374
366
|
|
|
367
|
+
var initialProps: RNInitialProps? = null
|
|
368
|
+
|
|
375
369
|
var uiSettings: RNMapUiSettings? = null
|
|
376
370
|
set(value) {
|
|
377
371
|
field = value
|
|
@@ -542,7 +536,7 @@ class GoogleMapsViewImpl(
|
|
|
542
536
|
onUi {
|
|
543
537
|
val builder = LatLngBounds.Builder()
|
|
544
538
|
coordinates.forEach { coord ->
|
|
545
|
-
builder.include(
|
|
539
|
+
builder.include(coord.toLatLng())
|
|
546
540
|
}
|
|
547
541
|
val bounds = builder.build()
|
|
548
542
|
|
|
@@ -975,6 +969,7 @@ class GoogleMapsViewImpl(
|
|
|
975
969
|
|
|
976
970
|
fun destroyInternal() {
|
|
977
971
|
onUi {
|
|
972
|
+
locationHandler.stop()
|
|
978
973
|
markerBuilder.cancelAllJobs()
|
|
979
974
|
clearMarkers()
|
|
980
975
|
clearPolylines()
|
|
@@ -982,7 +977,6 @@ class GoogleMapsViewImpl(
|
|
|
982
977
|
clearCircles()
|
|
983
978
|
clearHeatmaps()
|
|
984
979
|
clearKmlLayer()
|
|
985
|
-
locationHandler.stop()
|
|
986
980
|
googleMap?.apply {
|
|
987
981
|
setOnCameraMoveStartedListener(null)
|
|
988
982
|
setOnCameraMoveListener(null)
|
|
@@ -1003,6 +997,7 @@ class GoogleMapsViewImpl(
|
|
|
1003
997
|
}
|
|
1004
998
|
super.removeAllViews()
|
|
1005
999
|
reactContext.removeLifecycleEventListener(this)
|
|
1000
|
+
initialized = false
|
|
1006
1001
|
}
|
|
1007
1002
|
}
|
|
1008
1003
|
|
|
@@ -1066,28 +1061,28 @@ class GoogleMapsViewImpl(
|
|
|
1066
1061
|
|
|
1067
1062
|
override fun onMapClick(coordinates: LatLng) {
|
|
1068
1063
|
onMapPress?.invoke(
|
|
1069
|
-
|
|
1064
|
+
coordinates.toRnLatLng(),
|
|
1070
1065
|
)
|
|
1071
1066
|
}
|
|
1072
1067
|
|
|
1073
1068
|
override fun onMarkerDragStart(marker: Marker) {
|
|
1074
1069
|
onMarkerDragStart?.invoke(
|
|
1075
1070
|
marker.tag?.toString(),
|
|
1076
|
-
|
|
1071
|
+
marker.position.toRnLatLng(),
|
|
1077
1072
|
)
|
|
1078
1073
|
}
|
|
1079
1074
|
|
|
1080
1075
|
override fun onMarkerDrag(marker: Marker) {
|
|
1081
1076
|
onMarkerDrag?.invoke(
|
|
1082
1077
|
marker.tag?.toString(),
|
|
1083
|
-
|
|
1078
|
+
marker.position.toRnLatLng(),
|
|
1084
1079
|
)
|
|
1085
1080
|
}
|
|
1086
1081
|
|
|
1087
1082
|
override fun onMarkerDragEnd(marker: Marker) {
|
|
1088
1083
|
onMarkerDragEnd?.invoke(
|
|
1089
1084
|
marker.tag?.toString(),
|
|
1090
|
-
|
|
1085
|
+
marker.position.toRnLatLng(),
|
|
1091
1086
|
)
|
|
1092
1087
|
}
|
|
1093
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 ->
|
|
@@ -72,6 +71,11 @@ class MapMarkerBuilder(
|
|
|
72
71
|
marker.alpha = next.opacity?.toFloat() ?: 0f
|
|
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
|
|
@@ -21,6 +22,7 @@ import com.rngooglemapsplus.extensions.toSize
|
|
|
21
22
|
class RNGoogleMapsPlusView(
|
|
22
23
|
val context: ThemedReactContext,
|
|
23
24
|
) : HybridRNGoogleMapsPlusViewSpec() {
|
|
25
|
+
private var propsInitialized = false
|
|
24
26
|
private var currentCustomMapStyle: String? = null
|
|
25
27
|
private var permissionHandler = PermissionHandler(context)
|
|
26
28
|
private var locationHandler = LocationHandler(context)
|
|
@@ -35,15 +37,25 @@ class RNGoogleMapsPlusView(
|
|
|
35
37
|
override val view =
|
|
36
38
|
GoogleMapsViewImpl(context, locationHandler, playServiceHandler, markerBuilder)
|
|
37
39
|
|
|
40
|
+
override fun afterUpdate() {
|
|
41
|
+
super.afterUpdate()
|
|
42
|
+
if (!propsInitialized) {
|
|
43
|
+
propsInitialized = true
|
|
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)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
38
54
|
override var initialProps: RNInitialProps? = null
|
|
39
55
|
set(value) {
|
|
40
56
|
if (field == value) return
|
|
41
57
|
field = value
|
|
42
|
-
view.
|
|
43
|
-
value?.mapId,
|
|
44
|
-
value?.liteMode,
|
|
45
|
-
value?.camera?.toCameraPosition(),
|
|
46
|
-
)
|
|
58
|
+
view.initialProps = value
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
override var uiSettings: RNMapUiSettings? = null
|
|
@@ -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()) }
|
|
@@ -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
|
)
|
|
@@ -198,6 +190,11 @@ GMSIndoorDisplayDelegate {
|
|
|
198
190
|
mapView?.camera
|
|
199
191
|
}
|
|
200
192
|
|
|
193
|
+
@MainActor
|
|
194
|
+
var initialProps: RNInitialProps? {
|
|
195
|
+
didSet {}
|
|
196
|
+
}
|
|
197
|
+
|
|
201
198
|
@MainActor
|
|
202
199
|
var uiSettings: RNMapUiSettings? {
|
|
203
200
|
didSet {
|
|
@@ -343,27 +340,16 @@ GMSIndoorDisplayDelegate {
|
|
|
343
340
|
animated: Bool,
|
|
344
341
|
durationMs: Double
|
|
345
342
|
) {
|
|
346
|
-
|
|
343
|
+
guard let firstCoordinates = coordinates.first else {
|
|
347
344
|
return
|
|
348
345
|
}
|
|
349
346
|
var bounds = GMSCoordinateBounds(
|
|
350
|
-
coordinate:
|
|
351
|
-
|
|
352
|
-
longitude: coordinates[0].longitude
|
|
353
|
-
),
|
|
354
|
-
coordinate: CLLocationCoordinate2D(
|
|
355
|
-
latitude: coordinates[0].latitude,
|
|
356
|
-
longitude: coordinates[0].longitude
|
|
357
|
-
)
|
|
347
|
+
coordinate: firstCoordinates.toCLLocationCoordinate2D(),
|
|
348
|
+
coordinate: firstCoordinates.toCLLocationCoordinate2D()
|
|
358
349
|
)
|
|
359
350
|
|
|
360
351
|
for coord in coordinates.dropFirst() {
|
|
361
|
-
bounds = bounds.includingCoordinate(
|
|
362
|
-
CLLocationCoordinate2D(
|
|
363
|
-
latitude: coord.latitude,
|
|
364
|
-
longitude: coord.longitude
|
|
365
|
-
)
|
|
366
|
-
)
|
|
352
|
+
bounds = bounds.includingCoordinate(coord.toCLLocationCoordinate2D())
|
|
367
353
|
}
|
|
368
354
|
|
|
369
355
|
let insets = UIEdgeInsets(
|
|
@@ -629,7 +615,10 @@ GMSIndoorDisplayDelegate {
|
|
|
629
615
|
|
|
630
616
|
@MainActor
|
|
631
617
|
func clearHeatmaps() {
|
|
632
|
-
heatmapsById.values.forEach {
|
|
618
|
+
heatmapsById.values.forEach {
|
|
619
|
+
$0.clearTileCache()
|
|
620
|
+
$0.map = nil
|
|
621
|
+
}
|
|
633
622
|
heatmapsById.removeAll()
|
|
634
623
|
pendingHeatmaps.removeAll()
|
|
635
624
|
}
|
|
@@ -671,16 +660,21 @@ GMSIndoorDisplayDelegate {
|
|
|
671
660
|
}
|
|
672
661
|
|
|
673
662
|
func deinitInternal() {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
663
|
+
onMain {
|
|
664
|
+
self.locationHandler.stop()
|
|
665
|
+
self.markerBuilder.cancelAllIconTasks()
|
|
666
|
+
self.clearMarkers()
|
|
667
|
+
self.clearPolylines()
|
|
668
|
+
self.clearPolygons()
|
|
669
|
+
self.clearCircles()
|
|
670
|
+
self.clearHeatmaps()
|
|
671
|
+
self.clearKmlLayers()
|
|
672
|
+
self.mapView?.clear()
|
|
673
|
+
self.mapView?.indoorDisplay.delegate = nil
|
|
674
|
+
self.mapView?.delegate = nil
|
|
675
|
+
self.mapView = nil
|
|
676
|
+
self.initialized = false
|
|
677
|
+
}
|
|
684
678
|
}
|
|
685
679
|
|
|
686
680
|
@objc private func appDidBecomeActive() {
|
|
@@ -696,9 +690,6 @@ GMSIndoorDisplayDelegate {
|
|
|
696
690
|
override func didMoveToWindow() {
|
|
697
691
|
super.didMoveToWindow()
|
|
698
692
|
if window != nil {
|
|
699
|
-
if mapView != nil && mapReady {
|
|
700
|
-
onMapReady?(true)
|
|
701
|
-
}
|
|
702
693
|
locationHandler.start()
|
|
703
694
|
} else {
|
|
704
695
|
locationHandler.stop()
|
|
@@ -726,15 +717,12 @@ GMSIndoorDisplayDelegate {
|
|
|
726
717
|
|
|
727
718
|
let cp = mapView.camera
|
|
728
719
|
let region = RNRegion(
|
|
729
|
-
center:
|
|
720
|
+
center: center.toRNLatLng(),
|
|
730
721
|
latitudeDelta: latDelta,
|
|
731
722
|
longitudeDelta: lngDelta
|
|
732
723
|
)
|
|
733
724
|
let cam = RNCamera(
|
|
734
|
-
center:
|
|
735
|
-
latitude: cp.target.latitude,
|
|
736
|
-
longitude: cp.target.longitude
|
|
737
|
-
),
|
|
725
|
+
center: cp.target.toRNLatLng(),
|
|
738
726
|
zoom: Double(cp.zoom),
|
|
739
727
|
bearing: cp.bearing,
|
|
740
728
|
tilt: cp.viewingAngle
|
|
@@ -771,15 +759,12 @@ GMSIndoorDisplayDelegate {
|
|
|
771
759
|
|
|
772
760
|
let cp = mapView.camera
|
|
773
761
|
let region = RNRegion(
|
|
774
|
-
center:
|
|
762
|
+
center: center.toRNLatLng(),
|
|
775
763
|
latitudeDelta: latDelta,
|
|
776
764
|
longitudeDelta: lngDelta
|
|
777
765
|
)
|
|
778
766
|
let cam = RNCamera(
|
|
779
|
-
center:
|
|
780
|
-
latitude: cp.target.latitude,
|
|
781
|
-
longitude: cp.target.longitude
|
|
782
|
-
),
|
|
767
|
+
center: cp.target.toRNLatLng(),
|
|
783
768
|
zoom: Double(cp.zoom),
|
|
784
769
|
bearing: cp.bearing,
|
|
785
770
|
tilt: cp.viewingAngle
|
|
@@ -804,15 +789,12 @@ GMSIndoorDisplayDelegate {
|
|
|
804
789
|
|
|
805
790
|
let cp = mapView.camera
|
|
806
791
|
let region = RNRegion(
|
|
807
|
-
center:
|
|
792
|
+
center: center.toRNLatLng(),
|
|
808
793
|
latitudeDelta: latDelta,
|
|
809
794
|
longitudeDelta: lngDelta
|
|
810
795
|
)
|
|
811
796
|
let cam = RNCamera(
|
|
812
|
-
center:
|
|
813
|
-
latitude: cp.target.latitude,
|
|
814
|
-
longitude: cp.target.longitude
|
|
815
|
-
),
|
|
797
|
+
center: cp.target.toRNLatLng(),
|
|
816
798
|
zoom: Double(cp.zoom),
|
|
817
799
|
bearing: cp.bearing,
|
|
818
800
|
tilt: cp.viewingAngle
|
|
@@ -827,10 +809,7 @@ GMSIndoorDisplayDelegate {
|
|
|
827
809
|
) {
|
|
828
810
|
onMain {
|
|
829
811
|
self.onMapPress?(
|
|
830
|
-
|
|
831
|
-
latitude: coordinate.latitude,
|
|
832
|
-
longitude: coordinate.longitude
|
|
833
|
-
)
|
|
812
|
+
coordinate.toRNLatLng(),
|
|
834
813
|
)
|
|
835
814
|
}
|
|
836
815
|
}
|
|
@@ -865,7 +844,7 @@ GMSIndoorDisplayDelegate {
|
|
|
865
844
|
onMain {
|
|
866
845
|
self.onMarkerDragStart?(
|
|
867
846
|
marker.userData as? String,
|
|
868
|
-
|
|
847
|
+
marker.position.toRNLatLng()
|
|
869
848
|
)
|
|
870
849
|
}
|
|
871
850
|
}
|
|
@@ -874,7 +853,7 @@ GMSIndoorDisplayDelegate {
|
|
|
874
853
|
onMain {
|
|
875
854
|
self.onMarkerDrag?(
|
|
876
855
|
marker.userData as? String,
|
|
877
|
-
|
|
856
|
+
marker.position.toRNLatLng()
|
|
878
857
|
)
|
|
879
858
|
}
|
|
880
859
|
}
|
|
@@ -883,7 +862,7 @@ GMSIndoorDisplayDelegate {
|
|
|
883
862
|
onMain {
|
|
884
863
|
self.onMarkerDragEnd?(
|
|
885
864
|
marker.userData as? String,
|
|
886
|
-
|
|
865
|
+
marker.position.toRNLatLng()
|
|
887
866
|
)
|
|
888
867
|
}
|
|
889
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
|