@rnmapbox/maps 10.1.13 → 10.1.15

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.
@@ -29,6 +29,45 @@ class RNMBXPointAnnotationCoordinator(val mapView: MapView) {
29
29
  onAnnotationClick(pointAnnotation)
30
30
  false
31
31
  })
32
+ manager.addDragListener(object : OnPointAnnotationDragListener {
33
+ override fun onAnnotationDragStarted(_annotation: Annotation<*>) {
34
+ annotationDragged = true;
35
+ var reactAnnotation: RNMBXPointAnnotation? = null
36
+ for (key in annotations.keys) {
37
+ val annotation = annotations[key]
38
+ val curMarkerID = annotation?.mapboxID
39
+ if (_annotation.id == curMarkerID) {
40
+ reactAnnotation = annotation
41
+ }
42
+ }
43
+ reactAnnotation?.let { it.onDragStart() }
44
+ }
45
+
46
+ override fun onAnnotationDrag(_annotation: Annotation<*>) {
47
+ var reactAnnotation: RNMBXPointAnnotation? = null
48
+ for (key in annotations.keys) {
49
+ val annotation = annotations[key]
50
+ val curMarkerID = annotation?.mapboxID
51
+ if (_annotation.id == curMarkerID) {
52
+ reactAnnotation = annotation
53
+ }
54
+ }
55
+ reactAnnotation?.let { it.onDrag() }
56
+ }
57
+
58
+ override fun onAnnotationDragFinished(_annotation: Annotation<*>) {
59
+ annotationDragged = false;
60
+ var reactAnnotation: RNMBXPointAnnotation? = null
61
+ for (key in annotations.keys) {
62
+ val annotation = annotations[key]
63
+ val curMarkerID = annotation?.mapboxID
64
+ if (_annotation.id == curMarkerID) {
65
+ reactAnnotation = annotation
66
+ }
67
+ }
68
+ reactAnnotation?.let { it.onDragEnd() }
69
+ }
70
+ })
32
71
  }
33
72
 
34
73
  fun getAndClearAnnotationClicked(): Boolean {
@@ -70,46 +109,6 @@ class RNMBXPointAnnotationCoordinator(val mapView: MapView) {
70
109
  newSelected = null
71
110
  }
72
111
 
73
- manager.addDragListener(object : OnPointAnnotationDragListener {
74
- override fun onAnnotationDragStarted(_annotation: Annotation<*>) {
75
- annotationDragged = true;
76
- var reactAnnotation: RNMBXPointAnnotation? = null
77
- for (key in annotations.keys) {
78
- val annotation = annotations[key]
79
- val curMarkerID = annotation?.mapboxID
80
- if (_annotation.id == curMarkerID) {
81
- reactAnnotation = annotation
82
- }
83
- }
84
- reactAnnotation?.let { it.onDragStart() }
85
- }
86
-
87
- override fun onAnnotationDrag(_annotation: Annotation<*>) {
88
- var reactAnnotation: RNMBXPointAnnotation? = null
89
- for (key in annotations.keys) {
90
- val annotation = annotations[key]
91
- val curMarkerID = annotation?.mapboxID
92
- if (_annotation.id == curMarkerID) {
93
- reactAnnotation = annotation
94
- }
95
- }
96
- reactAnnotation?.let { it.onDrag() }
97
- }
98
-
99
- override fun onAnnotationDragFinished(_annotation: Annotation<*>) {
100
- annotationDragged = false;
101
- var reactAnnotation: RNMBXPointAnnotation? = null
102
- for (key in annotations.keys) {
103
- val annotation = annotations[key]
104
- val curMarkerID = annotation?.mapboxID
105
- if (_annotation.id == curMarkerID) {
106
- reactAnnotation = annotation
107
- }
108
- }
109
- reactAnnotation?.let { it.onDragEnd() }
110
- }
111
- })
112
-
113
112
  oldSelected?.let { deselectAnnotation(it) }
114
113
  newSelected?.let { selectAnnotation(it) }
115
114
 
@@ -95,12 +95,10 @@ class CameraStop {
95
95
  fun toCameraUpdate(mapView: RNMBXMapView): CameraUpdateItem {
96
96
  val map = mapView.getMapboxMap()
97
97
  val currentCamera = map.cameraState
98
+
98
99
  val builder = CameraOptions.Builder()
99
100
  builder.center(currentCamera.center)
100
101
  builder.bearing(currentCamera.bearing)
101
-
102
- val currentPadding = currentCamera.padding
103
-
104
102
  builder.padding(currentCamera.padding)
105
103
  builder.zoom(currentCamera.zoom)
106
104
  if (mBearing != null) {
@@ -109,7 +107,11 @@ class CameraStop {
109
107
  if (mTilt != null) {
110
108
  builder.pitch(mTilt)
111
109
  }
110
+ if (mZoom != null) {
111
+ builder.zoom(mZoom)
112
+ }
112
113
 
114
+ val currentPadding = currentCamera.padding
113
115
  val paddingLeft: Int = mPaddingLeft ?: currentPadding.left.toInt()
114
116
  val paddingTop: Int = mPaddingTop ?: currentPadding.top.toInt()
115
117
  val paddingRight: Int = mPaddingRight ?: currentPadding.right.toInt()
@@ -117,10 +119,10 @@ class CameraStop {
117
119
  val cameraPadding = intArrayOf(paddingLeft, paddingTop, paddingRight, paddingBottom)
118
120
  val cameraPaddingClipped = clippedPadding(cameraPadding, mapView)
119
121
  val cameraPaddingEdgeInsets = convert(cameraPaddingClipped)
122
+ builder.padding(cameraPaddingEdgeInsets)
120
123
 
121
124
  if (mLatLng != null) {
122
125
  builder.center(mLatLng!!.point)
123
- builder.padding(cameraPaddingEdgeInsets)
124
126
  } else if (mBounds != null) {
125
127
  val tilt = if (mTilt != null) mTilt!! else currentCamera.pitch
126
128
  val bearing = if (mBearing != null) mBearing!! else currentCamera.bearing
@@ -131,17 +133,14 @@ class CameraStop {
131
133
  bearing,
132
134
  tilt
133
135
  )
134
-
135
136
  builder.center(boundsCamera.center)
136
137
  builder.anchor(boundsCamera.anchor)
137
138
  builder.zoom(boundsCamera.zoom)
139
+ builder.bearing(boundsCamera.bearing)
140
+ builder.pitch(boundsCamera.pitch)
138
141
  builder.padding(boundsCamera.padding)
139
142
  }
140
143
 
141
- if (mZoom != null) {
142
- builder.zoom(mZoom)
143
- }
144
-
145
144
  return CameraUpdateItem(map, builder.build(), mDuration, mCallback, mMode)
146
145
  }
147
146
 
@@ -195,6 +194,7 @@ class CameraStop {
195
194
  when (readableMap.getInt("mode")) {
196
195
  CameraMode.FLIGHT -> stop.setMode(CameraMode.FLIGHT)
197
196
  CameraMode.LINEAR -> stop.setMode(CameraMode.LINEAR)
197
+ CameraMode.MOVE -> stop.setMode(CameraMode.MOVE)
198
198
  CameraMode.NONE -> stop.setMode(CameraMode.NONE)
199
199
  else -> stop.setMode(CameraMode.EASE)
200
200
  }
@@ -83,7 +83,7 @@ class CameraUpdateItem(
83
83
  val animationOptions = MapAnimationOptions.Builder();
84
84
 
85
85
  // animateCamera / easeCamera only allows positive duration
86
- if (duration == 0 || mCameraMode == CameraMode.NONE) {
86
+ if (duration == 0 || mCameraMode == CameraMode.MOVE || mCameraMode == CameraMode.NONE) {
87
87
  map.flyToV11(mCameraUpdate, animationOptions.apply {
88
88
  duration(0)
89
89
  },
@@ -109,7 +109,6 @@ class CameraUpdateItem(
109
109
  callback
110
110
  )
111
111
  }
112
- null
113
112
  }
114
113
 
115
114
  override fun cancel(mayInterruptIfRunning: Boolean): Boolean {
@@ -179,15 +179,12 @@ class RNMBXCamera(private val mContext: Context, private val mManager: RNMBXCame
179
179
  private fun updateMaxBounds() {
180
180
  withMapView { mapView ->
181
181
  val map = mapView.getMapboxMap()
182
- val maxBounds = mMaxBounds
183
182
  val builder = CameraBoundsOptions.Builder()
184
-
185
- if (maxBounds != null) {
186
- builder.bounds(maxBounds.toBounds())
187
- }
188
- mMinZoomLevel?.let { builder.minZoom(it) }
189
- mMaxZoomLevel?.let { builder.maxZoom(it) }
183
+ builder.bounds(mMaxBounds?.toBounds())
184
+ builder.minZoom(mMinZoomLevel ?: 0.0) // Passing null does not reset this value.
185
+ builder.maxZoom(mMaxZoomLevel ?: 25.0) // Passing null does not reset this value.
190
186
  map.setBounds(builder.build())
187
+ mCameraStop?.let { updateCamera(it) }
191
188
  }
192
189
  }
193
190
 
@@ -59,12 +59,12 @@ class RNMBXCameraManager(private val mContext: ReactApplicationContext, val view
59
59
 
60
60
  @ReactProp(name = "minZoomLevel")
61
61
  override fun setMinZoomLevel(camera: RNMBXCamera, value: Dynamic) {
62
- camera.setMinZoomLevel(value.asDouble())
62
+ camera.setMinZoomLevel(value.asDoubleOrNull())
63
63
  }
64
64
 
65
65
  @ReactProp(name = "maxZoomLevel")
66
66
  override fun setMaxZoomLevel(camera: RNMBXCamera, value: Dynamic) {
67
- camera.setMaxZoomLevel(value.asDouble())
67
+ camera.setMaxZoomLevel(value.asDoubleOrNull())
68
68
  }
69
69
 
70
70
  @ReactProp(name = "followUserLocation")
@@ -7,12 +7,13 @@ import java.lang.annotation.RetentionPolicy;
7
7
 
8
8
  public class CameraMode {
9
9
 
10
- @IntDef({ FLIGHT, EASE, LINEAR, NONE })
10
+ @IntDef({ FLIGHT, EASE, LINEAR, MOVE, NONE })
11
11
  @Retention(RetentionPolicy.SOURCE)
12
12
  public @interface Mode {}
13
13
 
14
14
  public static final int FLIGHT = 1;
15
15
  public static final int EASE = 2;
16
16
  public static final int LINEAR = 3;
17
- public static final int NONE = 4;
17
+ public static final int MOVE = 4;
18
+ public static final int NONE = 5;
18
19
  }