Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
naftalibeder authored and Gnative committed Dec 29, 2024
1 parent fa80ae5 commit 67371b6
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ package com.rnmapbox.rnmbx.components.camera

import android.animation.Animator
import android.content.Context
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toPointGeometry
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLng
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLngBounds
import com.rnmapbox.rnmbx.utils.LatLngBounds
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
import com.mapbox.maps.CameraOptions
import com.facebook.react.bridge.ReadableMap
import com.mapbox.geojson.FeatureCollection
import com.mapbox.geojson.Point
import com.mapbox.maps.CameraOptions
import com.mapbox.maps.EdgeInsets
import com.mapbox.maps.ScreenCoordinate
import com.rnmapbox.rnmbx.components.camera.constants.CameraMode
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLng
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toLatLngBounds
import com.rnmapbox.rnmbx.utils.GeoJSONUtils.toPointGeometry
import com.rnmapbox.rnmbx.utils.LatLng
import com.rnmapbox.rnmbx.utils.LatLngBounds

class CameraStop {
private var mBearing: Double? = null
Expand Down Expand Up @@ -124,14 +126,22 @@ class CameraStop {
if (mLatLng != null) {
builder.center(mLatLng!!.point)
} else if (mBounds != null) {
val coordinates = listOf<Point>(
mBounds!!.toBounds().northeast,
mBounds!!.toBounds().southwest
)
val tilt = if (mTilt != null) mTilt!! else currentCamera.pitch
val bearing = if (mBearing != null) mBearing!! else currentCamera.bearing

val boundsCamera = map.cameraForCoordinateBounds(
mBounds!!.toBounds(),
val boundsCamera = map.cameraForCoordinates(
coordinates,
CameraOptions.Builder()
.pitch(tilt)
.bearing(bearing)
.build(),
cameraPaddingEdgeInsets,
bearing,
tilt
null,
ScreenCoordinate(0.0, 0.0)
)
builder.center(boundsCamera.center)
builder.anchor(boundsCamera.anchor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ class CameraUpdateItem(
}
}
val map = mMap.get()
if (map == null) {
if (map == null || mCameraUpdate.center == null) {
isCameraActionCancelled = true
return
}

val animationOptions = MapAnimationOptions.Builder();

// animateCamera / easeCamera only allows positive duration
Expand Down
Loading

0 comments on commit 67371b6

Please sign in to comment.