react-native-google-maps-plus 1.10.0 → 1.10.1-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.
@@ -53,7 +53,6 @@ import com.rngooglemapsplus.extensions.toRnCamera
53
53
  import com.rngooglemapsplus.extensions.toRnLatLng
54
54
  import com.rngooglemapsplus.extensions.toRnLocation
55
55
  import com.rngooglemapsplus.extensions.toRnRegion
56
- import com.rngooglemapsplus.extensions.withPaddingPixels
57
56
  import idTag
58
57
  import tagData
59
58
  import java.io.ByteArrayInputStream
@@ -451,27 +450,25 @@ class GoogleMapsViewImpl(
451
450
  ) = onUi {
452
451
  if (coordinates.isEmpty()) return@onUi
453
452
 
454
- val w = mapView?.width ?: 0
455
- val h = mapView?.height ?: 0
453
+ val bounds =
454
+ LatLngBounds
455
+ .builder()
456
+ .apply {
457
+ coordinates.forEach { include(it.toLatLng()) }
458
+ }.build()
456
459
 
457
- val builder = LatLngBounds.builder()
458
- coordinates.forEach { coord -> builder.include(coord.toLatLng()) }
460
+ val previousMapPadding = mapPadding
461
+ mapPadding = padding
459
462
 
460
- val baseBounds = builder.build()
461
- val paddedBounds = baseBounds.withPaddingPixels(w, h, padding)
462
-
463
- val adjustedWidth =
464
- (w - padding.left.dpToPx() - padding.right.dpToPx()).toInt().coerceAtLeast(0)
465
- val adjustedHeight =
466
- (h - padding.top.dpToPx() - padding.bottom.dpToPx()).toInt().coerceAtLeast(0)
467
-
468
- val update = CameraUpdateFactory.newLatLngBounds(paddedBounds, adjustedWidth, adjustedHeight, 0)
463
+ val update = CameraUpdateFactory.newLatLngBounds(bounds, 0)
469
464
 
470
465
  if (animated) {
471
466
  googleMap?.animateCamera(update, durationMs, null)
472
467
  } else {
473
468
  googleMap?.moveCamera(update)
474
469
  }
470
+
471
+ mapPadding = previousMapPadding
475
472
  }
476
473
 
477
474
  fun setCameraBounds(bounds: LatLngBounds?) =
@@ -837,9 +834,15 @@ class GoogleMapsViewImpl(
837
834
  setOnMyLocationClickListener(null)
838
835
  setOnMyLocationButtonClickListener(null)
839
836
  setInfoWindowAdapter(null)
837
+ isTrafficEnabled = false
838
+ isIndoorEnabled = false
839
+ myLocationEnabled = false
840
+ setLocationSource(null)
841
+ setLatLngBoundsForCameraTarget(null)
840
842
  }
841
843
  googleMap = null
842
844
  mapView?.removeAllViews()
845
+ mapView = null
843
846
  super.removeAllViews()
844
847
  reactContext.unregisterComponentCallbacks(componentCallbacks)
845
848
  }
@@ -19,6 +19,7 @@ import com.google.android.gms.location.LocationServices
19
19
  import com.google.android.gms.location.LocationSettingsRequest
20
20
  import com.google.android.gms.location.Priority
21
21
  import com.google.android.gms.maps.LocationSource
22
+ import com.rngooglemapsplus.extensions.onUi
22
23
  import com.rngooglemapsplus.extensions.toLocationErrorCode
23
24
 
24
25
  private const val REQ_LOCATION_SETTINGS = 2001
@@ -64,8 +65,8 @@ class LocationHandler(
64
65
  }
65
66
 
66
67
  fun showLocationDialog() {
67
- UiThreadUtil.runOnUiThread {
68
- val activity = context.currentActivity ?: run { return@runOnUiThread }
68
+ onUi {
69
+ val activity = context.currentActivity ?: run { return@onUi }
69
70
 
70
71
  val lr =
71
72
  if (Build.VERSION.SDK_INT >= 31) {
@@ -1,41 +1,10 @@
1
1
  package com.rngooglemapsplus.extensions
2
2
 
3
- import com.facebook.react.uimanager.PixelUtil.dpToPx
4
- import com.google.android.gms.maps.model.LatLng
5
3
  import com.google.android.gms.maps.model.LatLngBounds
6
4
  import com.rngooglemapsplus.RNLatLngBounds
7
- import com.rngooglemapsplus.RNMapPadding
8
5
 
9
6
  fun LatLngBounds.toRnLatLngBounds(): RNLatLngBounds =
10
7
  RNLatLngBounds(
11
8
  northeast = northeast.toRnLatLng(),
12
9
  southwest = southwest.toRnLatLng(),
13
10
  )
14
-
15
- fun LatLngBounds.withPaddingPixels(
16
- mapWidthPx: Int,
17
- mapHeightPx: Int,
18
- padding: RNMapPadding,
19
- ): LatLngBounds {
20
- val latSpan = northeast.latitude - southwest.latitude
21
- val lngSpan = northeast.longitude - southwest.longitude
22
- if (latSpan == 0.0 && lngSpan == 0.0) return this
23
-
24
- val latPerPixel = if (mapHeightPx != 0) latSpan / mapHeightPx else 0.0
25
- val lngPerPixel = if (mapWidthPx != 0) lngSpan / mapWidthPx else 0.0
26
-
27
- val builder = LatLngBounds.builder()
28
- builder.include(
29
- LatLng(
30
- northeast.latitude + (padding.top.dpToPx() * latPerPixel),
31
- northeast.longitude + (padding.right.dpToPx() * lngPerPixel),
32
- ),
33
- )
34
- builder.include(
35
- LatLng(
36
- southwest.latitude - (padding.bottom.dpToPx() * latPerPixel),
37
- southwest.longitude - (padding.left.dpToPx() * lngPerPixel),
38
- ),
39
- )
40
- return builder.build()
41
- }