react-native-google-maps-plus 1.6.1 → 1.6.2

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.
@@ -44,6 +44,8 @@ android {
44
44
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
45
45
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
46
46
 
47
+ consumerProguardFiles "proguard-rules.pro"
48
+
47
49
  externalNativeBuild {
48
50
  cmake {
49
51
  cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"
@@ -250,6 +250,9 @@ class GoogleMapsViewImpl(
250
250
  }
251
251
  }
252
252
 
253
+ val currentCamera: CameraPosition?
254
+ get() = googleMap?.cameraPosition
255
+
253
256
  var initialProps: RNInitialProps? = null
254
257
 
255
258
  var uiSettings: RNMapUiSettings? = null
@@ -45,7 +45,7 @@ class RNGoogleMapsPlusView(
45
45
  GoogleMapOptions().apply {
46
46
  initialProps?.mapId?.let { mapId(it) }
47
47
  initialProps?.liteMode?.let { liteMode(it) }
48
- initialProps?.camera?.let { camera(it.toCameraPosition()) }
48
+ initialProps?.camera?.let { camera(it.toCameraPosition(current = null)) }
49
49
  }
50
50
  view.initMapView(options)
51
51
  }
@@ -361,7 +361,14 @@ class RNGoogleMapsPlusView(
361
361
  animated: Boolean?,
362
362
  durationMs: Double?,
363
363
  ) {
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
+ }
365
372
  }
366
373
 
367
374
  override fun setCameraToCoordinates(
@@ -19,40 +19,44 @@ fun Location.toRnLocation(): RNLocation =
19
19
  provider = provider,
20
20
  elapsedRealtimeNanos = elapsedRealtimeNanos.toDouble(),
21
21
  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
26
27
  },
27
28
  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
32
34
  },
33
35
  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
38
41
  },
39
42
  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
44
48
  },
45
49
  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
50
55
  },
51
56
  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
56
60
  },
57
61
  ),
58
62
  ios = null,
@@ -1,18 +1,14 @@
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
4
5
  import com.rngooglemapsplus.RNCamera
5
6
 
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()
@@ -278,7 +278,7 @@ GMSIndoorDisplayDelegate {
278
278
  disableActions: false,
279
279
  duration: durationMs / 1000.0
280
280
  ) {
281
- mapView?.animate(to: camera)
281
+ self.mapView?.animate(to: camera)
282
282
  }
283
283
  } else {
284
284
  let update = GMSCameraUpdate.setCamera(camera)
@@ -318,7 +318,7 @@ GMSIndoorDisplayDelegate {
318
318
  disableActions: false,
319
319
  duration: durationMs / 1000.0
320
320
  ) {
321
- mapView?.animate(with: update)
321
+ self.mapView?.animate(with: update)
322
322
  }
323
323
  } else {
324
324
  mapView?.moveCamera(update)
@@ -1,22 +1,24 @@
1
1
  import QuartzCore
2
2
 
3
- @inline(__always)
3
+ @MainActor @inline(__always)
4
4
  func withCATransaction(
5
5
  disableActions: Bool = true,
6
6
  duration: CFTimeInterval? = nil,
7
7
  timingFunction: CAMediaTimingFunction? = nil,
8
8
  completion: (() -> Void)? = nil,
9
- _ body: () -> Void
9
+ _ body: @escaping @MainActor () -> Void
10
10
  ) {
11
- CATransaction.begin()
11
+ onMain {
12
+ CATransaction.begin()
12
13
 
13
- CATransaction.setDisableActions(disableActions)
14
- duration.map { CATransaction.setAnimationDuration($0) }
15
- timingFunction.map { CATransaction.setAnimationTimingFunction($0) }
16
- completion.map { CATransaction.setCompletionBlock($0) }
14
+ CATransaction.setDisableActions(disableActions)
15
+ duration.map { CATransaction.setAnimationDuration($0) }
16
+ timingFunction.map { CATransaction.setAnimationTimingFunction($0) }
17
+ completion.map { CATransaction.setCompletionBlock($0) }
17
18
 
18
- body()
19
- CATransaction.commit()
19
+ body()
20
+ CATransaction.commit()
21
+ }
20
22
  }
21
23
 
22
24
  @MainActor @inline(__always)
@@ -132,19 +132,19 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
132
132
  withCATransaction(disableActions: true) {
133
133
 
134
134
  removed.forEach {
135
- impl.removeMarker(id: $0)
136
- markerBuilder.cancelIconTask($0)
135
+ self.impl.removeMarker(id: $0)
136
+ self.markerBuilder.cancelIconTask($0)
137
137
  }
138
138
 
139
139
  for (id, next) in nextById {
140
140
  if let prev = prevById[id] {
141
141
  if !prev.markerEquals(next) {
142
- impl.updateMarker(id: id) { m in
142
+ self.impl.updateMarker(id: id) { m in
143
143
  self.markerBuilder.update(prev, next, m)
144
144
  }
145
145
  }
146
146
  } else {
147
- markerBuilder.buildIconAsync(next.id, next) { icon in
147
+ self.markerBuilder.buildIconAsync(next.id, next) { icon in
148
148
  let marker = self.markerBuilder.build(next, icon: icon)
149
149
  self.impl.addMarker(id: id, marker: marker)
150
150
  }
@@ -4,8 +4,8 @@ import GoogleMaps
4
4
  extension RNCamera {
5
5
  func toGMSCameraPosition(current: GMSCameraPosition?) -> GMSCameraPosition {
6
6
  let center = CLLocationCoordinate2D(
7
- latitude: center?.latitude ?? current?.target.latitude ?? 0,
8
- longitude: center?.longitude ?? current?.target.longitude ?? 0
7
+ latitude: center?.latitude ?? current?.target.latitude ?? 0.0,
8
+ longitude: center?.longitude ?? current?.target.longitude ?? 0.0
9
9
  )
10
10
 
11
11
  let zoom = Float(zoom ?? Double(current?.zoom ?? 0))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-maps-plus",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "React Native wrapper for Android & iOS Google Maps SDK",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",