react-native-google-maps-plus 1.4.1 → 1.6.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +41 -144
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +38 -36
- 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/LocationExtension.kt +59 -0
- package/app.plugin.js +1 -0
- package/expoConfig/build/android/withAndroidGoogleMapsPlus.js +21 -0
- package/expoConfig/build/index.js +17 -0
- package/expoConfig/build/ios/withIosGoogleMapsPlus.js +91 -0
- package/expoConfig/build/types.js +2 -0
- package/ios/GoogleMapViewImpl.swift +28 -138
- package/ios/LocationHandler.swift +5 -13
- package/ios/MapHelper.swift +20 -0
- package/ios/MapMarkerBuilder.swift +44 -69
- package/ios/RNGoogleMapsPlusView.swift +12 -8
- package/ios/extensions/CLError+Extension.swift +14 -0
- package/ios/extensions/CLLocation+Extension.swift +27 -0
- package/ios/extensions/GMSCameraPosition+Extension.swift +12 -0
- package/ios/extensions/GMSCoordinateBounds+Extension.swift +19 -0
- package/ios/extensions/RNMarker+Extension.swift +2 -3
- 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 +25 -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 +8 -0
- package/nitrogen/generated/android/c++/JRNAndroidLocationConfig.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNCamera.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNCircle.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNHeatmap.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNHeatmapGradient.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNHeatmapPoint.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNIOSLocationConfig.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNIndoorBuilding.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNIndoorLevel.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNInitialProps.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNKMLayer.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNLatLng.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNLatLngBounds.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNLocation.hpp +37 -3
- package/nitrogen/generated/android/c++/JRNLocationAndroid.hpp +86 -0
- package/nitrogen/generated/android/c++/JRNLocationConfig.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNLocationIOS.hpp +81 -0
- package/nitrogen/generated/android/c++/JRNLocationPermissionResult.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNMapPadding.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNMapUiSettings.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNMapZoomConfig.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNMarker.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNMarkerSvg.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNPolygon.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNPolygonHole.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNPolyline.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNPosition.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNRegion.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNSize.hpp +5 -1
- package/nitrogen/generated/android/c++/JRNSnapshotOptions.hpp +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusModuleSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationConfig.kt +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCamera.kt +22 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +36 -28
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmap.kt +31 -23
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmapGradient.kt +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmapPoint.kt +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationConfig.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIndoorBuilding.kt +22 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIndoorLevel.kt +22 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNInitialProps.kt +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNKMLayer.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLatLng.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLatLngBounds.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocation.kt +34 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationAndroid.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationConfig.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationIOS.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationPermissionResult.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapPadding.kt +22 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapUiSettings.kt +43 -35
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapZoomConfig.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +49 -41
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarkerSvg.kt +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygon.kt +39 -31
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygonHole.kt +13 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolyline.kt +39 -31
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPosition.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNRegion.kt +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSize.kt +16 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotOptions.kt +22 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +7 -2
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +36 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +8 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +56 -7
- package/nitrogen/generated/ios/swift/RNCircle.swift +8 -1
- package/nitrogen/generated/ios/swift/RNHeatmap.swift +8 -1
- package/nitrogen/generated/ios/swift/RNIndoorBuilding.swift +8 -1
- package/nitrogen/generated/ios/swift/RNIndoorLevel.swift +8 -1
- package/nitrogen/generated/ios/swift/RNInitialProps.swift +8 -1
- package/nitrogen/generated/ios/swift/RNLocation.swift +92 -2
- package/nitrogen/generated/ios/swift/RNLocationAndroid.swift +222 -0
- package/nitrogen/generated/ios/swift/RNLocationIOS.swift +192 -0
- package/nitrogen/generated/ios/swift/RNMapUiSettings.swift +88 -11
- package/nitrogen/generated/ios/swift/RNMarker.swift +24 -3
- package/nitrogen/generated/ios/swift/RNPolygon.swift +16 -2
- package/nitrogen/generated/ios/swift/RNPolyline.swift +16 -2
- package/nitrogen/generated/shared/c++/RNLocation.hpp +33 -2
- package/nitrogen/generated/shared/c++/RNLocationAndroid.hpp +104 -0
- package/nitrogen/generated/shared/c++/RNLocationIOS.hpp +99 -0
- package/package.json +20 -17
- package/src/GoogleMapsPlus.tsx +20 -0
- package/src/index.tsx +6 -14
- package/src/types.ts +27 -0
- package/lib/module/package.json +0 -1
- package/lib/typescript/package.json +0 -1
package/README.md
CHANGED
|
@@ -22,6 +22,27 @@ React-native wrapper for android & IOS google maps sdk
|
|
|
22
22
|
yarn add react-native-google-maps-plus react-native-nitro-modules
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
### Expo Projects
|
|
26
|
+
|
|
27
|
+
Add your keys to the `app.json`.
|
|
28
|
+
The config plugin automatically injects them into your native Android and iOS builds during `expo prebuild`.
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"expo": {
|
|
33
|
+
"plugins": [
|
|
34
|
+
[
|
|
35
|
+
"react-native-google-maps-plus",
|
|
36
|
+
{
|
|
37
|
+
"googleMapsAndroidApiKey": "YOUR_ANDROID_MAPS_API_KEY",
|
|
38
|
+
"googleMapsIosApiKey": "YOUR_IOS_MAPS_API_KEY"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
25
46
|
# Dependencies
|
|
26
47
|
|
|
27
48
|
This package builds on native libraries for SVG rendering and Google Maps integration:
|
|
@@ -2,7 +2,6 @@ package com.rngooglemapsplus
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.graphics.Bitmap
|
|
5
|
-
import android.location.Location
|
|
6
5
|
import android.util.Base64
|
|
7
6
|
import android.util.Size
|
|
8
7
|
import android.widget.FrameLayout
|
|
@@ -11,7 +10,6 @@ import com.facebook.react.bridge.LifecycleEventListener
|
|
|
11
10
|
import com.facebook.react.bridge.UiThreadUtil
|
|
12
11
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
13
12
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
14
|
-
import com.google.android.gms.common.ConnectionResult
|
|
15
13
|
import com.google.android.gms.maps.CameraUpdateFactory
|
|
16
14
|
import com.google.android.gms.maps.GoogleMap
|
|
17
15
|
import com.google.android.gms.maps.GoogleMapOptions
|
|
@@ -39,7 +37,11 @@ import com.rngooglemapsplus.extensions.toLatLng
|
|
|
39
37
|
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
40
38
|
import com.rngooglemapsplus.extensions.toRNIndoorBuilding
|
|
41
39
|
import com.rngooglemapsplus.extensions.toRNIndoorLevel
|
|
40
|
+
import com.rngooglemapsplus.extensions.toRNMapErrorCodeOrNull
|
|
41
|
+
import com.rngooglemapsplus.extensions.toRnCamera
|
|
42
42
|
import com.rngooglemapsplus.extensions.toRnLatLng
|
|
43
|
+
import com.rngooglemapsplus.extensions.toRnLocation
|
|
44
|
+
import com.rngooglemapsplus.extensions.toRnRegion
|
|
43
45
|
import java.io.ByteArrayInputStream
|
|
44
46
|
import java.io.ByteArrayOutputStream
|
|
45
47
|
import java.io.File
|
|
@@ -65,6 +67,7 @@ class GoogleMapsViewImpl(
|
|
|
65
67
|
LifecycleEventListener {
|
|
66
68
|
private var initialized = false
|
|
67
69
|
private var mapReady = false
|
|
70
|
+
private var destroyed = false
|
|
68
71
|
private var googleMap: GoogleMap? = null
|
|
69
72
|
private var mapView: MapView? = null
|
|
70
73
|
|
|
@@ -83,7 +86,6 @@ class GoogleMapsViewImpl(
|
|
|
83
86
|
private val kmlLayersById = mutableMapOf<String, KmlLayer>()
|
|
84
87
|
|
|
85
88
|
private var cameraMoveReason = -1
|
|
86
|
-
private var lastSubmittedLocation: Location? = null
|
|
87
89
|
private var lastSubmittedCameraPosition: CameraPosition? = null
|
|
88
90
|
|
|
89
91
|
init {
|
|
@@ -94,31 +96,16 @@ class GoogleMapsViewImpl(
|
|
|
94
96
|
if (initialized) return
|
|
95
97
|
initialized = true
|
|
96
98
|
val result = playServiceHandler.playServicesAvailability()
|
|
99
|
+
val errorCode = result.toRNMapErrorCodeOrNull()
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
onMapError?.invoke(RNMapErrorCode.PLAY_SERVICES_MISSING)
|
|
101
|
-
return
|
|
102
|
-
}
|
|
101
|
+
if (errorCode != null) {
|
|
102
|
+
onMapError?.invoke(errorCode)
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if (errorCode == RNMapErrorCode.PLAY_SERVICES_MISSING ||
|
|
105
|
+
errorCode == RNMapErrorCode.PLAY_SERVICES_INVALID
|
|
106
|
+
) {
|
|
106
107
|
return
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED ->
|
|
110
|
-
onMapError?.invoke(RNMapErrorCode.PLAY_SERVICES_OUTDATED)
|
|
111
|
-
|
|
112
|
-
ConnectionResult.SERVICE_UPDATING ->
|
|
113
|
-
onMapError?.invoke(RNMapErrorCode.PLAY_SERVICE_UPDATING)
|
|
114
|
-
|
|
115
|
-
ConnectionResult.SERVICE_DISABLED ->
|
|
116
|
-
onMapError?.invoke(RNMapErrorCode.PLAY_SERVICES_DISABLED)
|
|
117
|
-
|
|
118
|
-
ConnectionResult.SUCCESS -> {}
|
|
119
|
-
|
|
120
|
-
else ->
|
|
121
|
-
onMapError?.invoke(RNMapErrorCode.UNKNOWN)
|
|
122
109
|
}
|
|
123
110
|
|
|
124
111
|
mapView =
|
|
@@ -143,8 +130,8 @@ class GoogleMapsViewImpl(
|
|
|
143
130
|
googleMap?.setOnMapClickListener(this@GoogleMapsViewImpl)
|
|
144
131
|
googleMap?.setOnMarkerDragListener(this@GoogleMapsViewImpl)
|
|
145
132
|
}
|
|
133
|
+
applyProps()
|
|
146
134
|
initLocationCallbacks()
|
|
147
|
-
applyPending()
|
|
148
135
|
mapReady = true
|
|
149
136
|
onMapReady?.invoke(true)
|
|
150
137
|
}
|
|
@@ -160,21 +147,9 @@ class GoogleMapsViewImpl(
|
|
|
160
147
|
}
|
|
161
148
|
val isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == reason
|
|
162
149
|
|
|
163
|
-
val latDelta = bounds.northeast.latitude - bounds.southwest.latitude
|
|
164
|
-
val lngDelta = bounds.northeast.longitude - bounds.southwest.longitude
|
|
165
|
-
|
|
166
150
|
onCameraChangeStart?.invoke(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
latitudeDelta = latDelta,
|
|
170
|
-
longitudeDelta = lngDelta,
|
|
171
|
-
),
|
|
172
|
-
RNCamera(
|
|
173
|
-
center = cameraPosition.target.toRnLatLng(),
|
|
174
|
-
zoom = cameraPosition.zoom.toDouble(),
|
|
175
|
-
bearing = cameraPosition.bearing.toDouble(),
|
|
176
|
-
tilt = cameraPosition.tilt.toDouble(),
|
|
177
|
-
),
|
|
151
|
+
bounds.toRnRegion(),
|
|
152
|
+
cameraPosition.toRnCamera(),
|
|
178
153
|
isGesture,
|
|
179
154
|
)
|
|
180
155
|
}
|
|
@@ -192,21 +167,9 @@ class GoogleMapsViewImpl(
|
|
|
192
167
|
|
|
193
168
|
val isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason
|
|
194
169
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
onCameraChange?.invoke(
|
|
199
|
-
RNRegion(
|
|
200
|
-
center = bounds.center.toRnLatLng(),
|
|
201
|
-
latitudeDelta = latDelta,
|
|
202
|
-
longitudeDelta = lngDelta,
|
|
203
|
-
),
|
|
204
|
-
RNCamera(
|
|
205
|
-
center = cameraPosition.target.toRnLatLng(),
|
|
206
|
-
zoom = cameraPosition.zoom.toDouble(),
|
|
207
|
-
bearing = cameraPosition.bearing.toDouble(),
|
|
208
|
-
tilt = cameraPosition.tilt.toDouble(),
|
|
209
|
-
),
|
|
170
|
+
onCameraChangeStart?.invoke(
|
|
171
|
+
bounds.toRnRegion(),
|
|
172
|
+
cameraPosition.toRnCamera(),
|
|
210
173
|
isGesture,
|
|
211
174
|
)
|
|
212
175
|
}
|
|
@@ -220,39 +183,16 @@ class GoogleMapsViewImpl(
|
|
|
220
183
|
}
|
|
221
184
|
val isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason
|
|
222
185
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
onCameraChangeComplete?.invoke(
|
|
227
|
-
RNRegion(
|
|
228
|
-
center = bounds.center.toRnLatLng(),
|
|
229
|
-
latitudeDelta = latDelta,
|
|
230
|
-
longitudeDelta = lngDelta,
|
|
231
|
-
),
|
|
232
|
-
RNCamera(
|
|
233
|
-
center = cameraPosition.target.toRnLatLng(),
|
|
234
|
-
zoom = cameraPosition.zoom.toDouble(),
|
|
235
|
-
bearing = cameraPosition.bearing.toDouble(),
|
|
236
|
-
tilt = cameraPosition.tilt.toDouble(),
|
|
237
|
-
),
|
|
186
|
+
onCameraChangeStart?.invoke(
|
|
187
|
+
bounds.toRnRegion(),
|
|
188
|
+
cameraPosition.toRnCamera(),
|
|
238
189
|
isGesture,
|
|
239
190
|
)
|
|
240
191
|
}
|
|
241
192
|
|
|
242
193
|
fun initLocationCallbacks() {
|
|
243
194
|
locationHandler.onUpdate = { location ->
|
|
244
|
-
|
|
245
|
-
if (lastSubmittedLocation?.latitude != location.latitude || lastSubmittedLocation?.longitude != location.longitude ||
|
|
246
|
-
lastSubmittedLocation?.bearing != location.bearing
|
|
247
|
-
) {
|
|
248
|
-
onLocationUpdate?.invoke(
|
|
249
|
-
RNLocation(
|
|
250
|
-
RNLatLng(location.latitude, location.longitude),
|
|
251
|
-
location.bearing.toDouble(),
|
|
252
|
-
),
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
lastSubmittedLocation = location
|
|
195
|
+
onLocationUpdate?.invoke(location.toRnLocation())
|
|
256
196
|
}
|
|
257
197
|
|
|
258
198
|
locationHandler.onError = { error ->
|
|
@@ -261,65 +201,18 @@ class GoogleMapsViewImpl(
|
|
|
261
201
|
locationHandler.start()
|
|
262
202
|
}
|
|
263
203
|
|
|
264
|
-
fun
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
googleMap?.uiSettings?.apply {
|
|
277
|
-
v.allGesturesEnabled?.let { setAllGesturesEnabled(it) }
|
|
278
|
-
v.compassEnabled?.let { isCompassEnabled = it }
|
|
279
|
-
v.indoorLevelPickerEnabled?.let { isIndoorLevelPickerEnabled = it }
|
|
280
|
-
v.mapToolbarEnabled?.let { isMapToolbarEnabled = it }
|
|
281
|
-
v.myLocationButtonEnabled?.let {
|
|
282
|
-
googleMap?.setLocationSource(locationHandler)
|
|
283
|
-
isMyLocationButtonEnabled = it
|
|
284
|
-
}
|
|
285
|
-
v.rotateEnabled?.let { isRotateGesturesEnabled = it }
|
|
286
|
-
v.scrollEnabled?.let { isScrollGesturesEnabled = it }
|
|
287
|
-
v.scrollDuringRotateOrZoomEnabled?.let {
|
|
288
|
-
isScrollGesturesEnabledDuringRotateOrZoom = it
|
|
289
|
-
}
|
|
290
|
-
v.tiltEnabled?.let { isTiltGesturesEnabled = it }
|
|
291
|
-
v.zoomControlsEnabled?.let { isZoomControlsEnabled = it }
|
|
292
|
-
v.zoomGesturesEnabled?.let { isZoomGesturesEnabled = it }
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
buildingEnabled?.let {
|
|
297
|
-
googleMap?.isBuildingsEnabled = it
|
|
298
|
-
}
|
|
299
|
-
trafficEnabled?.let {
|
|
300
|
-
googleMap?.isTrafficEnabled = it
|
|
301
|
-
}
|
|
302
|
-
indoorEnabled?.let {
|
|
303
|
-
googleMap?.isIndoorEnabled = it
|
|
304
|
-
}
|
|
305
|
-
googleMap?.setMapStyle(customMapStyle)
|
|
306
|
-
mapType?.let {
|
|
307
|
-
googleMap?.mapType = it
|
|
308
|
-
}
|
|
309
|
-
userInterfaceStyle?.let {
|
|
310
|
-
googleMap?.mapColorScheme = it
|
|
311
|
-
}
|
|
312
|
-
mapZoomConfig?.let {
|
|
313
|
-
googleMap?.setMinZoomPreference(it.min?.toFloat() ?: 2.0f)
|
|
314
|
-
googleMap?.setMaxZoomPreference(it.max?.toFloat() ?: 21.0f)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
locationConfig?.let {
|
|
319
|
-
locationHandler.priority = it.android?.priority?.toGooglePriority()
|
|
320
|
-
locationHandler.interval = it.android?.interval?.toLong()
|
|
321
|
-
locationHandler.minUpdateInterval = it.android?.minUpdateInterval?.toLong()
|
|
322
|
-
}
|
|
204
|
+
fun applyProps() {
|
|
205
|
+
mapPadding = mapPadding
|
|
206
|
+
uiSettings = uiSettings
|
|
207
|
+
myLocationEnabled = myLocationEnabled
|
|
208
|
+
buildingEnabled = buildingEnabled
|
|
209
|
+
trafficEnabled = trafficEnabled
|
|
210
|
+
indoorEnabled = indoorEnabled
|
|
211
|
+
customMapStyle = customMapStyle
|
|
212
|
+
mapType = mapType
|
|
213
|
+
userInterfaceStyle = userInterfaceStyle
|
|
214
|
+
mapZoomConfig = mapZoomConfig
|
|
215
|
+
locationConfig = locationConfig
|
|
323
216
|
|
|
324
217
|
if (pendingMarkers.isNotEmpty()) {
|
|
325
218
|
pendingMarkers.forEach { (id, opts) ->
|
|
@@ -480,9 +373,11 @@ class GoogleMapsViewImpl(
|
|
|
480
373
|
var locationConfig: RNLocationConfig? = null
|
|
481
374
|
set(value) {
|
|
482
375
|
field = value
|
|
483
|
-
locationHandler.
|
|
484
|
-
|
|
485
|
-
|
|
376
|
+
locationHandler.updateConfig(
|
|
377
|
+
value?.android?.priority?.toGooglePriority(),
|
|
378
|
+
value?.android?.interval?.toLong(),
|
|
379
|
+
value?.android?.minUpdateInterval?.toLong(),
|
|
380
|
+
)
|
|
486
381
|
}
|
|
487
382
|
|
|
488
383
|
var onMapError: ((RNMapErrorCode) -> Unit)? = null
|
|
@@ -919,7 +814,7 @@ class GoogleMapsViewImpl(
|
|
|
919
814
|
onUi {
|
|
920
815
|
heatmapsById.values.forEach { it.remove() }
|
|
921
816
|
}
|
|
922
|
-
|
|
817
|
+
heatmapsById.clear()
|
|
923
818
|
pendingHeatmaps.clear()
|
|
924
819
|
}
|
|
925
820
|
|
|
@@ -968,6 +863,8 @@ class GoogleMapsViewImpl(
|
|
|
968
863
|
}
|
|
969
864
|
|
|
970
865
|
fun destroyInternal() {
|
|
866
|
+
if (destroyed) return
|
|
867
|
+
destroyed = true
|
|
971
868
|
onUi {
|
|
972
869
|
locationHandler.stop()
|
|
973
870
|
markerBuilder.cancelAllJobs()
|
|
@@ -35,30 +35,28 @@ class LocationHandler(
|
|
|
35
35
|
private var listener: LocationSource.OnLocationChangedListener? = null
|
|
36
36
|
private var locationRequest: LocationRequest? = null
|
|
37
37
|
private var locationCallback: LocationCallback? = null
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var interval: Long? = INTERVAL_DEFAULT
|
|
46
|
-
set(value) {
|
|
47
|
-
field = value ?: INTERVAL_DEFAULT
|
|
48
|
-
buildLocationRequest()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var minUpdateInterval: Long? = MIN_UPDATE_INTERVAL
|
|
52
|
-
set(value) {
|
|
53
|
-
field = value ?: MIN_UPDATE_INTERVAL
|
|
54
|
-
buildLocationRequest()
|
|
55
|
-
}
|
|
38
|
+
private var priority: Int = PRIORITY_DEFAULT
|
|
39
|
+
private var interval: Long = INTERVAL_DEFAULT
|
|
40
|
+
private var minUpdateInterval: Long = MIN_UPDATE_INTERVAL
|
|
41
|
+
private var lastSubmittedLocation: Location? = null
|
|
42
|
+
private var isActive = false
|
|
56
43
|
|
|
57
44
|
var onUpdate: ((Location) -> Unit)? = null
|
|
58
45
|
var onError: ((RNLocationErrorCode) -> Unit)? = null
|
|
59
46
|
|
|
60
47
|
init {
|
|
61
|
-
buildLocationRequest()
|
|
48
|
+
buildLocationRequest(priority, interval, minUpdateInterval)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fun updateConfig(
|
|
52
|
+
priority: Int? = null,
|
|
53
|
+
interval: Long? = null,
|
|
54
|
+
minUpdateInterval: Long? = null,
|
|
55
|
+
) {
|
|
56
|
+
this.priority = priority ?: PRIORITY_DEFAULT
|
|
57
|
+
this.interval = interval ?: INTERVAL_DEFAULT
|
|
58
|
+
this.minUpdateInterval = minUpdateInterval ?: MIN_UPDATE_INTERVAL
|
|
59
|
+
buildLocationRequest(this.priority, this.interval, this.minUpdateInterval)
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
fun showLocationDialog() {
|
|
@@ -108,11 +106,11 @@ class LocationHandler(
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
@Suppress("deprecation")
|
|
111
|
-
private fun buildLocationRequest(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
private fun buildLocationRequest(
|
|
110
|
+
priority: Int,
|
|
111
|
+
interval: Long,
|
|
112
|
+
minUpdateInterval: Long,
|
|
113
|
+
) {
|
|
116
114
|
locationRequest =
|
|
117
115
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
118
116
|
LocationRequest
|
|
@@ -126,11 +124,13 @@ class LocationHandler(
|
|
|
126
124
|
.setInterval(interval)
|
|
127
125
|
.setFastestInterval(minUpdateInterval)
|
|
128
126
|
}
|
|
129
|
-
restartLocationUpdates()
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
@SuppressLint("MissingPermission")
|
|
130
|
+
fun start() {
|
|
131
|
+
if (isActive) return
|
|
132
|
+
isActive = true
|
|
133
|
+
|
|
134
134
|
val playServicesStatus =
|
|
135
135
|
GoogleApiAvailability
|
|
136
136
|
.getInstance()
|
|
@@ -139,17 +139,13 @@ class LocationHandler(
|
|
|
139
139
|
onError?.invoke(RNLocationErrorCode.PLAY_SERVICE_NOT_AVAILABLE)
|
|
140
140
|
return
|
|
141
141
|
}
|
|
142
|
-
start()
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
@SuppressLint("MissingPermission")
|
|
146
|
-
fun start() {
|
|
147
142
|
try {
|
|
148
143
|
fusedLocationClientProviderClient.lastLocation
|
|
149
144
|
.addOnSuccessListener(
|
|
150
145
|
OnSuccessListener { location ->
|
|
151
|
-
if (location != null) {
|
|
146
|
+
if (location != null && location != lastSubmittedLocation) {
|
|
152
147
|
onUpdate?.invoke(location)
|
|
148
|
+
lastSubmittedLocation = location
|
|
153
149
|
}
|
|
154
150
|
},
|
|
155
151
|
).addOnFailureListener { e ->
|
|
@@ -161,8 +157,11 @@ class LocationHandler(
|
|
|
161
157
|
override fun onLocationResult(locationResult: LocationResult) {
|
|
162
158
|
val location = locationResult.lastLocation
|
|
163
159
|
if (location != null) {
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
if (location != lastSubmittedLocation) {
|
|
161
|
+
lastSubmittedLocation = location
|
|
162
|
+
listener?.onLocationChanged(location)
|
|
163
|
+
onUpdate?.invoke(location)
|
|
164
|
+
}
|
|
166
165
|
} else {
|
|
167
166
|
onError?.invoke(RNLocationErrorCode.POSITION_UNAVAILABLE)
|
|
168
167
|
}
|
|
@@ -186,9 +185,11 @@ class LocationHandler(
|
|
|
186
185
|
}
|
|
187
186
|
|
|
188
187
|
fun stop() {
|
|
189
|
-
|
|
188
|
+
if (!isActive) return
|
|
189
|
+
isActive = false
|
|
190
190
|
if (locationCallback != null) {
|
|
191
191
|
fusedLocationClientProviderClient.removeLocationUpdates(locationCallback!!)
|
|
192
|
+
fusedLocationClientProviderClient.flushLocations()
|
|
192
193
|
locationCallback = null
|
|
193
194
|
}
|
|
194
195
|
}
|
|
@@ -199,6 +200,7 @@ class LocationHandler(
|
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
override fun deactivate() {
|
|
203
|
+
listener = null
|
|
202
204
|
stop()
|
|
203
205
|
}
|
|
204
206
|
}
|
|
@@ -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
|
+
)
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./expoConfig/build');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
+
var Manifest_1 = require("@expo/config-plugins/build/android/Manifest");
|
|
5
|
+
var withMapsAndroid = function (config, props) {
|
|
6
|
+
return (0, config_plugins_1.withAndroidManifest)(config, function (conf) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var manifest = conf.modResults;
|
|
9
|
+
var mainApplication = (0, Manifest_1.getMainApplicationOrThrow)(manifest);
|
|
10
|
+
var apiKey = (_b = (_a = props.googleMapsAndroidApiKey) !== null && _a !== void 0 ? _a : process.env.GOOGLE_MAPS_API_KEY_ANDROID) !== null && _b !== void 0 ? _b : null;
|
|
11
|
+
if (apiKey) {
|
|
12
|
+
(0, Manifest_1.addMetaDataItemToMainApplication)(mainApplication, 'com.google.android.geo.API_KEY', apiKey);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
(0, Manifest_1.removeMetaDataItemFromMainApplication)(mainApplication, 'com.google.android.geo.API_KEY');
|
|
16
|
+
console.warn('[react-native-google-maps-plus] No Android API key provided. Removed existing entry.');
|
|
17
|
+
}
|
|
18
|
+
return conf;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.default = withMapsAndroid;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var fs_1 = __importDefault(require("fs"));
|
|
7
|
+
var path_1 = __importDefault(require("path"));
|
|
8
|
+
var pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(__dirname, '../../package.json'), 'utf8'));
|
|
9
|
+
var config_plugins_1 = require("@expo/config-plugins");
|
|
10
|
+
var withIosGoogleMapsPlus_1 = __importDefault(require("./ios/withIosGoogleMapsPlus"));
|
|
11
|
+
var withAndroidGoogleMapsPlus_1 = __importDefault(require("./android/withAndroidGoogleMapsPlus"));
|
|
12
|
+
var withGoogleMapsPlus = function (config, props) {
|
|
13
|
+
config = (0, withAndroidGoogleMapsPlus_1.default)(config, props);
|
|
14
|
+
config = (0, withIosGoogleMapsPlus_1.default)(config, props);
|
|
15
|
+
return config;
|
|
16
|
+
};
|
|
17
|
+
module.exports = (0, config_plugins_1.createRunOncePlugin)(withGoogleMapsPlus, pkg.name, pkg.version);
|