Skip to content

Commit 63d2aa2

Browse files
authored
chore: merge dev into main
2 parents c979465 + 41f293e commit 63d2aa2

13 files changed

Lines changed: 102 additions & 74 deletions

File tree

android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ android {
4444
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
4545
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
4646

47+
consumerProguardFiles "proguard-rules.pro"
48+
4749
externalNativeBuild {
4850
cmake {
4951
cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"

android/proguard-rules.pro

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-keep class com.google.android.gms.** { *; }
2+
-keep interface com.google.android.gms.** { *; }
3+
-dontwarn com.google.android.gms.**
4+
-dontnote com.google.android.gms.**
5+
6+
-keep class * implements android.os.Parcelable { *; }
7+
8+
-keepclassmembers class **$Companion {
9+
public *;
10+
}
11+
12+
-keep class com.google.maps.android.** { *; }
13+
-keep interface com.google.maps.android.** { *; }
14+
-dontwarn com.google.maps.android.**
15+
16+
-keep @androidx.annotation.Keep class * { *; }
17+
-keepclassmembers class * {
18+
@androidx.annotation.Keep *;
19+
}
20+
21+
-keep class com.caverock.androidsvg.** { *; }
22+
-dontwarn com.caverock.androidsvg.**
23+
24+
-keepclassmembers class com.caverock.androidsvg.** {
25+
public *;
26+
protected *;
27+
}
28+
29+
-keep class com.rngooglemapsplus.** { *; }

android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ class GoogleMapsViewImpl(
250250
}
251251
}
252252

253+
val currentCamera: CameraPosition?
254+
get() = googleMap?.cameraPosition
255+
253256
var initialProps: RNInitialProps? = null
254257

255258
var uiSettings: RNMapUiSettings? = null

android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class RNGoogleMapsPlusView(
4545
GoogleMapOptions().apply {
4646
initialProps?.mapId?.let { mapId(it) }
4747
initialProps?.liteMode?.let { liteMode(it) }
48-
initialProps?.camera?.let { camera(it.toCameraPosition()) }
48+
initialProps?.camera?.let { camera(it.toCameraPosition(current = null)) }
4949
}
5050
view.initMapView(options)
5151
}
@@ -361,7 +361,14 @@ class RNGoogleMapsPlusView(
361361
animated: Boolean?,
362362
durationMs: Double?,
363363
) {
364-
view.setCamera(camera.toCameraPosition(), animated == true, durationMs?.toInt() ?: 3000)
364+
onUi {
365+
val current = view.currentCamera
366+
view.setCamera(
367+
camera.toCameraPosition(current),
368+
animated == true,
369+
durationMs?.toInt() ?: 3000,
370+
)
371+
}
365372
}
366373

367374
override fun setCameraToCoordinates(

android/src/main/java/com/rngooglemapsplus/extensions/LocationExtension.kt

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,44 @@ fun Location.toRnLocation(): RNLocation =
1919
provider = provider,
2020
elapsedRealtimeNanos = elapsedRealtimeNanos.toDouble(),
2121
bearingAccuracyDegrees =
22-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
23-
bearingAccuracyDegrees.toDouble()
24-
} else {
25-
null
22+
when {
23+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ->
24+
bearingAccuracyDegrees.toDouble()
25+
26+
else -> null
2627
},
2728
speedAccuracyMetersPerSecond =
28-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
29-
speedAccuracyMetersPerSecond.toDouble()
30-
} else {
31-
null
29+
when {
30+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ->
31+
speedAccuracyMetersPerSecond.toDouble()
32+
33+
else -> null
3234
},
3335
verticalAccuracyMeters =
34-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
35-
verticalAccuracyMeters.toDouble()
36-
} else {
37-
null
36+
when {
37+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ->
38+
verticalAccuracyMeters.toDouble()
39+
40+
else -> null
3841
},
3942
mslAltitudeMeters =
40-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
41-
mslAltitudeMeters
42-
} else {
43-
null
43+
when {
44+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE ->
45+
mslAltitudeMeters
46+
47+
else -> null
4448
},
4549
mslAltitudeAccuracyMeters =
46-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
47-
mslAltitudeAccuracyMeters.toDouble()
48-
} else {
49-
null
50+
when {
51+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE ->
52+
mslAltitudeAccuracyMeters.toDouble()
53+
54+
else -> null
5055
},
5156
isMock =
52-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
53-
isMock
54-
} else {
55-
isFromMockProvider
57+
when {
58+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> isMock
59+
else -> isFromMockProvider
5660
},
5761
),
5862
ios = null,
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
package com.rngooglemapsplus.extensions
22

33
import com.google.android.gms.maps.model.CameraPosition
4+
import com.google.android.gms.maps.model.LatLng
45
import com.rngooglemapsplus.RNCamera
56

6-
fun RNCamera.toCameraPosition(): CameraPosition {
7-
val builder = CameraPosition.builder()
8-
9-
center?.let {
10-
builder.target(it.toLatLng())
11-
}
12-
13-
zoom?.let { builder.zoom(it.toFloat()) }
14-
bearing?.let { builder.bearing(it.toFloat()) }
15-
tilt?.let { builder.tilt(it.toFloat()) }
16-
17-
return builder.build()
18-
}
7+
fun RNCamera.toCameraPosition(current: CameraPosition?) =
8+
CameraPosition
9+
.builder()
10+
.target(center?.toLatLng() ?: current?.target ?: LatLng(0.0, 0.0))
11+
.zoom(zoom?.toFloat() ?: current?.zoom ?: 0f)
12+
.bearing(bearing?.toFloat() ?: current?.bearing ?: 0f)
13+
.tilt(tilt?.toFloat() ?: current?.tilt ?: 0f)
14+
.build()

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ react {
5858
/**
5959
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
6060
*/
61-
def enableProguardInReleaseBuilds = false
61+
def enableProguardInReleaseBuilds = true
6262

6363
/**
6464
* The preferred build flavor of JavaScriptCore (JSC)

example/src/components/MapWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function MapWrapper(props: Props) {
7373
const locationConfig = useMemo(
7474
() => ({
7575
android: {
76-
priority: RNAndroidLocationPriority.PRIORITY_BALANCED_POWER_ACCURACY,
76+
priority: RNAndroidLocationPriority.PRIORITY_HIGH_ACCURACY,
7777
interval: 5000,
7878
minUpdateInterval: 5000,
7979
},

example/src/screens/BasicMapScreen.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import React, { useRef, useState } from 'react';
22
import MapWrapper from '../components/MapWrapper';
3-
import {
4-
type GoogleMapsViewRef,
5-
RNAndroidLocationPriority,
6-
RNIOSLocationAccuracy,
7-
} from 'react-native-google-maps-plus';
3+
import type { GoogleMapsViewRef } from 'react-native-google-maps-plus';
84
import ControlPanel from '../components/ControlPanel';
95
import MapConfigDialog from '../components/maptConfigDialog/MapConfigDialog';
106
import type { RNBasicMapConfig } from '../types/basicMapConfig';
@@ -49,17 +45,6 @@ export default function BasicMapScreen() {
4945
mapZoomConfig: { min: 0, max: 20 },
5046
mapPadding: { top: 20, left: 20, bottom: layout.bottom + 80, right: 20 },
5147
mapType: 'normal',
52-
locationConfig: {
53-
android: {
54-
priority: RNAndroidLocationPriority.PRIORITY_HIGH_ACCURACY,
55-
interval: 5000,
56-
minUpdateInterval: 5000,
57-
},
58-
ios: {
59-
desiredAccuracy: RNIOSLocationAccuracy.ACCURACY_BEST,
60-
distanceFilterMeters: 10,
61-
},
62-
},
6348
});
6449

6550
const [dialogVisible, setDialogVisible] = useState(true);

ios/GoogleMapViewImpl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ GMSIndoorDisplayDelegate {
278278
disableActions: false,
279279
duration: durationMs / 1000.0
280280
) {
281-
mapView?.animate(to: camera)
281+
self.mapView?.animate(to: camera)
282282
}
283283
} else {
284284
let update = GMSCameraUpdate.setCamera(camera)
@@ -318,7 +318,7 @@ GMSIndoorDisplayDelegate {
318318
disableActions: false,
319319
duration: durationMs / 1000.0
320320
) {
321-
mapView?.animate(with: update)
321+
self.mapView?.animate(with: update)
322322
}
323323
} else {
324324
mapView?.moveCamera(update)

0 commit comments

Comments
 (0)