Skip to content

Commit 11eabc9

Browse files
naftalibederGnative
authored andcommitted
1 parent 51b1d22 commit 11eabc9

File tree

3 files changed

+124
-92
lines changed

3 files changed

+124
-92
lines changed

android/src/main/java/com/rnmapbox/rnmbx/components/camera/CameraStop.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ package com.rnmapbox.rnmbx.components.camera
22

33
import android.animation.Animator
44
import android.content.Context
5-
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toPointGeometry
6-
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLng
7-
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLngBounds
8-
import com.rnmapbox.rnmbx.utils.LatLngBounds
9-
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
10-
import com.mapbox.maps.CameraOptions
115
import com.facebook.react.bridge.ReadableMap
126
import com.mapbox.geojson.FeatureCollection
7+
import com.mapbox.geojson.Point
8+
import com.mapbox.maps.CameraOptions
139
import com.mapbox.maps.EdgeInsets
10+
import com.mapbox.maps.ScreenCoordinate
1411
import com.rnmapbox.rnmbx.components.camera.constants.CameraMode
12+
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
13+
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLng
14+
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLngBounds
15+
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toPointGeometry
1516
import com.rnmapbox.rnmbx.utils.LatLng
17+
import com.rnmapbox.rnmbx.utils.LatLngBounds
1618

1719
class CameraStop {
1820
private var mBearing: Double? = null
@@ -124,14 +126,22 @@ class CameraStop {
124126
if (mLatLng != null) {
125127
builder.center(mLatLng!!.point)
126128
} else if (mBounds != null) {
129+
val coordinates = listOf<Point>(
130+
mBounds!!.toBounds().northeast,
131+
mBounds!!.toBounds().southwest
132+
)
127133
val tilt = if (mTilt != null) mTilt!! else currentCamera.pitch
128134
val bearing = if (mBearing != null) mBearing!! else currentCamera.bearing
129135

130-
val boundsCamera = map.cameraForCoordinateBounds(
131-
mBounds!!.toBounds(),
136+
val boundsCamera = map.cameraForCoordinates(
137+
coordinates,
138+
CameraOptions.Builder()
139+
.pitch(tilt)
140+
.bearing(bearing)
141+
.build(),
132142
cameraPaddingEdgeInsets,
133-
bearing,
134-
tilt
143+
null,
144+
ScreenCoordinate(0.0, 0.0)
135145
)
136146
builder.center(boundsCamera.center)
137147
builder.anchor(boundsCamera.anchor)

android/src/main/java/com/rnmapbox/rnmbx/components/camera/CameraUpdateItem.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ class CameraUpdateItem(
7676
}
7777
}
7878
val map = mMap.get()
79-
if (map == null) {
79+
if (map == null || mCameraUpdate.center == null) {
8080
isCameraActionCancelled = true
8181
return
8282
}
83+
8384
val animationOptions = MapAnimationOptions.Builder();
8485

8586
// animateCamera / easeCamera only allows positive duration

0 commit comments

Comments
 (0)