@rnmapbox/maps 10.0.0-beta.39 → 10.0.0-beta.41

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.
Files changed (53) hide show
  1. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/AbstractMapFeature.kt +10 -0
  2. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraUpdateItem.kt +135 -0
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.kt +68 -0
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +498 -0
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.kt +114 -0
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/UserLocation.java +1 -1
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/UserTrackingMode.java +1 -1
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTSource.kt +14 -9
  9. package/docs/Annotation.md +1 -1
  10. package/docs/Atmosphere.md +1 -1
  11. package/docs/BackgroundLayer.md +1 -1
  12. package/docs/Callout.md +1 -1
  13. package/docs/Camera.md +1 -1
  14. package/docs/CircleLayer.md +1 -1
  15. package/docs/FillExtrusionLayer.md +1 -1
  16. package/docs/FillLayer.md +1 -1
  17. package/docs/HeadingIndicator.md +1 -1
  18. package/docs/HeatmapLayer.md +1 -1
  19. package/docs/ImageSource.md +1 -1
  20. package/docs/Images.md +1 -1
  21. package/docs/Light.md +1 -1
  22. package/docs/LineLayer.md +1 -1
  23. package/docs/MapView.md +1 -1
  24. package/docs/MarkerView.md +1 -1
  25. package/docs/NativeUserLocation.md +1 -1
  26. package/docs/PointAnnotation.md +12 -10
  27. package/docs/RasterDemSource.md +1 -1
  28. package/docs/RasterLayer.md +1 -1
  29. package/docs/RasterSource.md +1 -1
  30. package/docs/ShapeSource.md +1 -1
  31. package/docs/SkyLayer.md +1 -1
  32. package/docs/Style.md +1 -1
  33. package/docs/SymbolLayer.md +1 -1
  34. package/docs/Terrain.md +1 -1
  35. package/docs/UserLocation.md +1 -1
  36. package/docs/VectorSource.md +1 -1
  37. package/docs/docs.json +44 -23
  38. package/index.d.ts +3 -19
  39. package/ios/RCTMGL-v10/RCTMGLCamera.swift +11 -1
  40. package/javascript/components/MarkerView.tsx +12 -1
  41. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +33 -10
  42. package/javascript/components/PointAnnotation.tsx +231 -0
  43. package/javascript/utils/index.d.ts +11 -3
  44. package/package.json +8 -8
  45. package/scripts/autogenHelpers/DocJSONBuilder.js +68 -12
  46. package/scripts/templates/component.md.ejs +1 -1
  47. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/AbstractMapFeature.java +0 -15
  48. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraUpdateItem.java +0 -167
  49. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java +0 -73
  50. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.java +0 -662
  51. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.java +0 -102
  52. package/javascript/components/PointAnnotation.d.ts +0 -13
  53. package/javascript/components/PointAnnotation.js +0 -217
@@ -0,0 +1,231 @@
1
+ import React, { SyntheticEvent, type Component } from 'react';
2
+ import {
3
+ requireNativeComponent,
4
+ StyleSheet,
5
+ Platform,
6
+ type HostComponent,
7
+ type ViewProps,
8
+ } from 'react-native';
9
+ import { type Feature } from 'geojson';
10
+
11
+ import { toJSONString, isFunction } from '../utils';
12
+ import { makePoint } from '../utils/geoUtils';
13
+
14
+ import NativeBridgeComponent, { type RNMBEvent } from './NativeBridgeComponent';
15
+
16
+ export const NATIVE_MODULE_NAME = 'RCTMGLPointAnnotation';
17
+
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ position: 'absolute',
23
+ },
24
+ });
25
+
26
+ type FeaturePayload = {
27
+ feature: Feature;
28
+ };
29
+
30
+ type PointAnnotationProps = {
31
+ /**
32
+ * A string that uniquely identifies the annotation
33
+ */
34
+ id: string;
35
+
36
+ /**
37
+ * The string containing the annotation’s title. Note this is required to be set if you want to see a callout appear on iOS.
38
+ */
39
+ title?: string;
40
+
41
+ /**
42
+ * The string containing the annotation’s snippet(subtitle). Not displayed in the default callout.
43
+ */
44
+ snippet?: string;
45
+
46
+ /**
47
+ * Manually selects/deselects annotation
48
+ */
49
+ selected?: boolean;
50
+
51
+ /**
52
+ * Enable or disable dragging. Defaults to false.
53
+ */
54
+ draggable?: boolean;
55
+
56
+ /**
57
+ * The center point (specified as a map coordinate) of the annotation.
58
+ */
59
+ coordinate: [number, number];
60
+
61
+ /**
62
+ * Specifies the anchor being set on a particular point of the annotation.
63
+ * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],
64
+ * where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.
65
+ * Note this is only for custom annotations not the default pin view.
66
+ * Defaults to the center of the view.
67
+ */
68
+ anchor?: {
69
+ /**
70
+ * See anchor
71
+ */
72
+ x: number;
73
+ /**
74
+ * See anchor
75
+ */
76
+ y: number;
77
+ };
78
+
79
+ /**
80
+ * This callback is fired once this annotation is selected. Returns a Feature as the first param.
81
+ */
82
+ onSelected?: (payload: FeaturePayload) => void;
83
+
84
+ /**
85
+ * This callback is fired once this annotation is deselected.
86
+ */
87
+ onDeselected?: (payload: FeaturePayload) => void;
88
+
89
+ /**
90
+ * This callback is fired once this annotation has started being dragged.
91
+ */
92
+ onDragStart?: (payload: FeaturePayload) => void;
93
+
94
+ /**
95
+ * This callback is fired once this annotation has stopped being dragged.
96
+ */
97
+ onDragEnd?: (payload: FeaturePayload) => void;
98
+
99
+ /**
100
+ * This callback is fired while this annotation is being dragged.
101
+ */
102
+ onDrag?: (payload: FeaturePayload) => void;
103
+
104
+ /**
105
+ * Expects one child, and an optional callout can be added as well
106
+ */
107
+ children: React.ReactElement;
108
+
109
+ style?: ViewProps['style'];
110
+ };
111
+
112
+ /**
113
+ * PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
114
+ *
115
+ * Consider using ShapeSource and SymbolLayer instead, if you have many points and you have static images,
116
+ * they'll offer much better performance.
117
+ *
118
+ * If you need interactive views please use MarkerView,
119
+ * as with PointAnnotation on Android child views are rendered onto a bitmap for better performance.
120
+ */
121
+ class PointAnnotation extends NativeBridgeComponent(
122
+ React.PureComponent<PointAnnotationProps>,
123
+ ) {
124
+ static defaultProps = {
125
+ anchor: { x: 0.5, y: 0.5 },
126
+ draggable: false,
127
+ };
128
+
129
+ _nativeRef: NativePointAnnotationRef | null = null;
130
+
131
+ constructor(props: PointAnnotationProps) {
132
+ super(props, NATIVE_MODULE_NAME);
133
+ this._onSelected = this._onSelected.bind(this);
134
+ this._onDeselected = this._onDeselected.bind(this);
135
+ this._onDragStart = this._onDragStart.bind(this);
136
+ this._onDrag = this._onDrag.bind(this);
137
+ this._onDragEnd = this._onDragEnd.bind(this);
138
+ }
139
+
140
+ _onSelected(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
141
+ if (isFunction(this.props.onSelected)) {
142
+ this.props.onSelected(e.nativeEvent.payload);
143
+ }
144
+ }
145
+
146
+ _onDeselected(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
147
+ if (isFunction(this.props.onDeselected)) {
148
+ this.props.onDeselected(e.nativeEvent.payload);
149
+ }
150
+ }
151
+
152
+ _onDragStart(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
153
+ if (isFunction(this.props.onDragStart)) {
154
+ this.props.onDragStart(e.nativeEvent.payload);
155
+ }
156
+ }
157
+
158
+ _onDrag(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
159
+ if (isFunction(this.props.onDrag)) {
160
+ this.props.onDrag(e.nativeEvent.payload);
161
+ }
162
+ }
163
+
164
+ _onDragEnd(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
165
+ if (isFunction(this.props.onDragEnd)) {
166
+ this.props.onDragEnd(e.nativeEvent.payload);
167
+ }
168
+ }
169
+
170
+ _getCoordinate(): string | undefined {
171
+ if (!this.props.coordinate) {
172
+ return undefined;
173
+ }
174
+ return toJSONString(makePoint(this.props.coordinate));
175
+ }
176
+
177
+ /**
178
+ * On v10 and pre v10 android point annotation is rendered offscreen with a canvas into an image.
179
+ * To rerender the image from the current state of the view call refresh.
180
+ * Call this for example from Image#onLoad.
181
+ */
182
+ refresh() {
183
+ if (Platform.OS === 'android') {
184
+ this._runNativeCommand('refresh', this._nativeRef, []);
185
+ } else {
186
+ this._runNativeCommand('refresh', this._nativeRef, []);
187
+ }
188
+ }
189
+
190
+ _setNativeRef(nativeRef: NativePointAnnotationRef | null) {
191
+ this._nativeRef = nativeRef;
192
+ super._runPendingNativeCommands(nativeRef);
193
+ }
194
+
195
+ render() {
196
+ const props = {
197
+ ...this.props,
198
+ ref: (nativeRef: NativePointAnnotationRef | null) =>
199
+ this._setNativeRef(nativeRef),
200
+ id: this.props.id,
201
+ title: this.props.title,
202
+ snippet: this.props.snippet,
203
+ anchor: this.props.anchor,
204
+ selected: this.props.selected,
205
+ draggable: this.props.draggable,
206
+ style: [this.props.style, styles.container],
207
+ onMapboxPointAnnotationSelected: this._onSelected,
208
+ onMapboxPointAnnotationDeselected: this._onDeselected,
209
+ onMapboxPointAnnotationDragStart: this._onDragStart,
210
+ onMapboxPointAnnotationDrag: this._onDrag,
211
+ onMapboxPointAnnotationDragEnd: this._onDragEnd,
212
+ coordinate: this._getCoordinate(),
213
+ };
214
+ return (
215
+ <RCTMGLPointAnnotation {...props}>
216
+ {this.props.children}
217
+ </RCTMGLPointAnnotation>
218
+ );
219
+ }
220
+ }
221
+ type NativePointAnnotationProps = Omit<PointAnnotationProps, 'coordinate'> & {
222
+ coordinate: string | undefined;
223
+ };
224
+
225
+ type NativePointAnnotationRef = Component<NativePointAnnotationProps>;
226
+ type NativePointAnnotation = HostComponent<NativePointAnnotationProps>;
227
+
228
+ const RCTMGLPointAnnotation: NativePointAnnotation =
229
+ requireNativeComponent(NATIVE_MODULE_NAME);
230
+
231
+ export default PointAnnotation;
@@ -1,6 +1,14 @@
1
1
  export function isAndroid(): boolean;
2
- export function isBoolean(_: unknown): boolean;
3
- export function isNumber(_: unknown): boolean;
4
- export function isString(_: unknown): boolean;
2
+ export function isBoolean(_: unknown): argument is boolean;
3
+ export function isNumber(_: unknown): argument is number;
4
+ export function isString(_: unknown): argument is string;
5
+ // eslint-disable-next-line @typescript-eslint/ban-types
6
+ export function isFunction(argument: unknown): argument is Function;
5
7
 
6
8
  export function toJSONString(_: unknown): string;
9
+ export function runNativeCommand<RefType>(
10
+ module: string,
11
+ name: string,
12
+ nativeRef: RefType,
13
+ args: string[],
14
+ ): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.0-beta.39",
4
+ "version": "10.0.0-beta.41",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -62,17 +62,17 @@
62
62
  "deprecated-react-native-prop-types": "^2.3.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@babel/core": "7.17.5",
66
- "@babel/eslint-parser": "^7.17.0",
67
- "@babel/plugin-proposal-class-properties": "7.16.7",
68
- "@babel/runtime": "7.17.2",
65
+ "@babel/core": "7.19.1",
66
+ "@babel/eslint-parser": "^7.19.1",
67
+ "@babel/plugin-proposal-class-properties": "7.18.6",
68
+ "@babel/runtime": "7.19.0",
69
69
  "@react-native-community/eslint-config": "^3.0.1",
70
70
  "@sinonjs/fake-timers": "^8.0.1",
71
71
  "@testing-library/react-native": "^11.0.0",
72
72
  "@types/mapbox-gl": "^2.7.5",
73
73
  "@types/react-native": ">=0.59.9",
74
- "@typescript-eslint/eslint-plugin": "^5.36.2",
75
- "@typescript-eslint/parser": "^5.36.2",
74
+ "@typescript-eslint/eslint-plugin": "^5.37.0",
75
+ "@typescript-eslint/parser": "^5.37.0",
76
76
  "babel-jest": "^27.5.1",
77
77
  "documentation": "13.2.5",
78
78
  "ejs": "^3.1.3",
@@ -90,7 +90,7 @@
90
90
  "mapbox-gl": "^2.9.0",
91
91
  "metro-react-native-babel-preset": "0.71.1",
92
92
  "node-dir": "0.1.17",
93
- "prettier": "2.6.2",
93
+ "prettier": "2.7.1",
94
94
  "react": "17.0.2",
95
95
  "react-docgen": "rnmapbox/react-docgen#rnmapbox-dist",
96
96
  "react-native": "0.67.0",
@@ -22,6 +22,7 @@ const IGNORE_FILES = [
22
22
  'AbstractLayer',
23
23
  'AbstractSource',
24
24
  'NativeBridgeComponent',
25
+ 'NativeBridgeComponent.tsx',
25
26
  ];
26
27
  const IGNORE_PATTERN = /\.web\./;
27
28
 
@@ -143,29 +144,77 @@ class DocJSONBuilder {
143
144
  }
144
145
  }
145
146
 
147
+ /**
148
+ * @typedef {{arguments: {type:TSType,name:string}[], return: TSType]}} TSFuncSignature
149
+ * @typedef {{key:string, value:TSType}[]} TSKVProperties
150
+ * @typedef {{properties: TSKVProperties}} TSObjectSignature
151
+ * @typedef {{name: 'void'}} TSVoidType
152
+ * @typedef {{name: string}} TSTypeType
153
+ * @typedef {{name: 'signature', type:'function', raw:string, signature: TSFuncSignature}} TSFunctionType
154
+ * @typedef {{name: 'signature', type:'object', raw:string, signature: TSObjectSignature}} TSObjectType
155
+ * @typedef {TSVoidType | TSFunctionType | TSTypeType | TSObjectType} TSType
156
+ */
157
+
158
+ /**
159
+ * @params {TSType} tsType
160
+ * @returns {tsType is TSFunctionType}
161
+ */
162
+ function tsTypeIsFunction(tsType) {
163
+ return tsType.type === 'function';
164
+ }
165
+
166
+ /**
167
+ * @params {TSType} tsType
168
+ * @returns {tsType is TSObjectType}
169
+ */
170
+ function tsTypeIsObject(tsType) {
171
+ return tsType.type === 'object';
172
+ }
173
+
174
+ /**
175
+ * @param {TSType} tsType
176
+ */
177
+ function tsTypeDump(tsType) {
178
+ if (tsTypeIsFunction(tsType)) {
179
+ let { signature } = tsType;
180
+ return `(${signature.arguments
181
+ .map(({ name, type }) => `${name}:${tsTypeDump(type)}`)
182
+ .join(', ')}) => ${tsTypeDump(signature.return)}`;
183
+ } else if (tsTypeIsObject(tsType)) {
184
+ let { signature } = tsType;
185
+ return `{${signature.properties
186
+ .map(({ key, value }) => `${key}: ${tsTypeDump(value)}`)
187
+ .join(', ')}}`;
188
+ } else {
189
+ return tsType.name;
190
+ }
191
+ }
192
+
146
193
  function tsTypeDescType(tsType) {
147
194
  if (!tsType?.name) {
148
195
  return null;
149
196
  }
150
197
 
151
- if (tsType.name === 'signature') {
198
+ if (tsType.name === 'signature' && tsType.type === 'object') {
152
199
  const { properties } = tsType.signature;
153
- const value = properties.map((kv) => {
154
- return mapProp(
155
- mapNestedProp({ ...kv.value, description: kv.description }),
156
- kv.key,
157
- false,
158
- );
159
- });
160
- return { name: 'shape', value };
161
- /*
162
- if (tsType.raw.length < 200) {
200
+ if (properties) {
201
+ const value = properties.map((kv) => {
202
+ return mapProp(
203
+ mapNestedProp({ ...kv.value, description: kv.description }),
204
+ kv.key,
205
+ false,
206
+ );
207
+ });
208
+ return { name: 'shape', value };
209
+ } else if (tsType.raw.length < 200) {
163
210
  return `${tsType.raw
164
211
  .replace(/(\n|\s)/g, '')
165
212
  .replace(/(\|)/g, '\\|')}`;
166
213
  } else {
167
214
  return 'FIX ME FORMAT BIG OBJECT';
168
- } */
215
+ }
216
+ } else if (tsType.name === 'signature' && tsType.type === 'function') {
217
+ return { name: 'func', funcSignature: tsTypeDump(tsType) };
169
218
  } else if (tsType.name === 'union') {
170
219
  if (tsType.raw) {
171
220
  // Props
@@ -194,6 +243,13 @@ class DocJSONBuilder {
194
243
  : propMeta.defaultValue.value.replace(/\n/g, ''),
195
244
  description: propMeta.description || 'FIX ME NO DESCRIPTION',
196
245
  };
246
+ if (
247
+ result.type &&
248
+ result.type.name === 'func' &&
249
+ result.type.funcSignature
250
+ ) {
251
+ result.description = `${result.description}\n*signature:*\`${result.type.funcSignature}\``;
252
+ }
197
253
  } else {
198
254
  if (propName) {
199
255
  result.name = propName;
@@ -8,7 +8,7 @@
8
8
  <%_ if (component.props && component.props.length) { _%>
9
9
  ## props
10
10
  | Prop | Type | Default | Required | Description |
11
- | ---- | :--: | :-----: | :------: | :----------: |
11
+ | ---- | :-- | :----- | :------ | :---------- |
12
12
  <%- propMarkdownTableRows(component) %>
13
13
  <%_ } _%>
14
14
 
@@ -1,15 +0,0 @@
1
- package com.mapbox.rctmgl.components;
2
-
3
- import android.content.Context;
4
-
5
- import com.facebook.react.views.view.ReactViewGroup;
6
- import com.mapbox.rctmgl.components.mapview.RCTMGLMapView ;
7
-
8
- public abstract class AbstractMapFeature extends ReactViewGroup {
9
- public AbstractMapFeature(Context context) {
10
- super(context);
11
- }
12
-
13
- public abstract void addToMap(RCTMGLMapView mapView);
14
- public abstract void removeFromMap(RCTMGLMapView mapView);
15
- }
@@ -1,167 +0,0 @@
1
- package com.mapbox.rctmgl.components.camera;
2
-
3
- import android.animation.Animator;
4
- import android.view.animation.AccelerateDecelerateInterpolator;
5
- import android.view.animation.LinearInterpolator;
6
-
7
- import androidx.annotation.NonNull;
8
-
9
- import com.mapbox.maps.CameraOptions;
10
- import com.mapbox.maps.MapboxMap;
11
- import com.mapbox.maps.plugin.animation.CameraAnimationsPlugin;
12
- import com.mapbox.maps.plugin.animation.MapAnimationOptions;
13
- import com.mapbox.rctmgl.components.camera.constants.CameraMode;
14
-
15
- import java.lang.ref.WeakReference;
16
- import java.util.concurrent.Callable;
17
- import java.util.concurrent.ExecutionException;
18
- import java.util.concurrent.ExecutorService;
19
- import java.util.concurrent.Future;
20
- import java.util.concurrent.FutureTask;
21
- import java.util.concurrent.RunnableFuture;
22
- import java.util.concurrent.TimeUnit;
23
- import java.util.concurrent.TimeoutException;
24
-
25
- import kotlin.jvm.functions.Function1;
26
-
27
- public class CameraUpdateItem implements RunnableFuture<Void> {
28
- private int mDuration;
29
- private Animator.AnimatorListener mCallback;
30
- private CameraOptions mCameraUpdate;
31
- private int mCameraMode;
32
-
33
- private boolean isCameraActionFinished;
34
- private boolean isCameraActionCancelled;
35
-
36
- private WeakReference<MapboxMap> mMap;
37
-
38
- enum CallbackMode {
39
- START,
40
- END,
41
- CANCEL,
42
- REPEAT
43
- }
44
-
45
-
46
- public CameraUpdateItem(MapboxMap map, CameraOptions update, int duration, Animator.AnimatorListener callback, @CameraMode.Mode int cameraMode) {
47
- mCameraUpdate = update;
48
- mDuration = duration;
49
- mCallback = callback;
50
- mCameraMode = cameraMode;
51
- mMap = new WeakReference<>(map);
52
- }
53
-
54
- public int getDuration() {
55
- return mDuration;
56
- }
57
-
58
- @Override
59
- public void run() {
60
- final Animator.AnimatorListener callback = new Animator.AnimatorListener() {
61
-
62
- @Override
63
- public void onAnimationStart(Animator animator) {
64
- isCameraActionCancelled = false;
65
- isCameraActionFinished = false;
66
-
67
- if (mCallback != null) {
68
- mCallback.onAnimationStart(animator);
69
- }
70
- }
71
-
72
- @Override
73
- public void onAnimationEnd(Animator animator) {
74
- isCameraActionCancelled = false;
75
- isCameraActionFinished = true;
76
-
77
- if (mCallback != null) {
78
- mCallback.onAnimationEnd(animator);
79
- }
80
- }
81
-
82
- @Override
83
- public void onAnimationCancel(Animator animator) {
84
- isCameraActionCancelled = true;
85
- isCameraActionFinished = false;
86
-
87
- if (mCallback != null) {
88
- mCallback.onAnimationCancel(animator);
89
- }
90
- }
91
-
92
- @Override
93
- public void onAnimationRepeat(Animator animator) {
94
- isCameraActionCancelled = false;
95
- isCameraActionFinished = false;
96
-
97
- if (mCallback != null) {
98
- mCallback.onAnimationRepeat(animator);
99
- }
100
- }
101
- };
102
-
103
- MapboxMap map = mMap.get();
104
- if (map == null) {
105
- isCameraActionCancelled = true;
106
- return;
107
- }
108
-
109
- MapAnimationOptions.Builder optionsBuilder = new MapAnimationOptions.Builder();
110
- optionsBuilder.animatorListener(callback);
111
-
112
- map.cameraAnimationsPlugin(new Function1<CameraAnimationsPlugin, Object>() {
113
-
114
- @Override
115
- public Object invoke(CameraAnimationsPlugin cameraAnimationsPlugin) {
116
-
117
- // animateCamera / easeCamera only allows positive duration
118
- if (mDuration == 0 || mCameraMode == CameraMode.NONE) {
119
- cameraAnimationsPlugin.flyTo(
120
- mCameraUpdate,
121
- optionsBuilder.duration(0).build()
122
- );
123
- }
124
-
125
- // On iOS a duration of -1 means default or dynamic duration (based on flight-path length)
126
- // On Android we can fallback to Mapbox's default duration as there is no such API
127
- if (mDuration > 0) {
128
- optionsBuilder.duration(mDuration);
129
- }
130
-
131
- if (mCameraMode == CameraMode.FLIGHT) {
132
- cameraAnimationsPlugin.flyTo(mCameraUpdate, optionsBuilder.build());
133
- } else if (mCameraMode == CameraMode.LINEAR) {
134
- cameraAnimationsPlugin.easeTo(mCameraUpdate, optionsBuilder.interpolator(new LinearInterpolator()).build());
135
- } else if (mCameraMode == CameraMode.EASE) {
136
- cameraAnimationsPlugin.easeTo(mCameraUpdate, optionsBuilder.interpolator(new AccelerateDecelerateInterpolator()).build());
137
- }
138
- return null;
139
- }
140
- });
141
- }
142
-
143
- @Override
144
- public boolean cancel(boolean mayInterruptIfRunning) {
145
- return false;
146
- }
147
-
148
- @Override
149
- public boolean isCancelled() {
150
- return isCameraActionCancelled;
151
- }
152
-
153
- @Override
154
- public boolean isDone() {
155
- return isCameraActionFinished;
156
- }
157
-
158
- @Override
159
- public Void get() throws InterruptedException, ExecutionException {
160
- return null;
161
- }
162
-
163
- @Override
164
- public Void get(long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
165
- return null;
166
- }
167
- }
@@ -1,73 +0,0 @@
1
- package com.mapbox.rctmgl.components.camera;
2
-
3
- import com.mapbox.maps.MapboxMap;
4
- import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
5
-
6
- import java.util.ArrayList;
7
- import java.util.Iterator;
8
- import java.util.LinkedList;
9
- import java.util.List;
10
- import java.util.Queue;
11
- import java.util.concurrent.ExecutorService;
12
- import java.util.concurrent.Executors;
13
- import java.util.concurrent.FutureTask;
14
-
15
-
16
- /**
17
- * Created by nickitaliano on 9/5/17.
18
- */
19
-
20
- public class CameraUpdateQueue {
21
- private Queue<CameraStop> mQueue;
22
-
23
- private OnCompleteAllListener mCompleteListener;
24
-
25
- public interface OnCompleteAllListener {
26
- void onCompleteAll();
27
- }
28
-
29
- public CameraUpdateQueue() {
30
- mQueue = new LinkedList<>();
31
- }
32
-
33
- public void offer(CameraStop item) {
34
- mQueue.offer(item);
35
- }
36
-
37
- public int size() {
38
- return mQueue.size();
39
- }
40
-
41
- public boolean isEmpty() {
42
- return mQueue.isEmpty();
43
- }
44
-
45
- public void flush() {
46
- while (mQueue.size() > 0) {
47
- mQueue.remove();
48
- }
49
- mQueue = new LinkedList<>();
50
- }
51
-
52
- public void setOnCompleteAllListener(OnCompleteAllListener listener) {
53
- mCompleteListener = listener;
54
- }
55
-
56
- public void execute(RCTMGLMapView map) {
57
- if (mQueue.isEmpty()) {
58
- if (mCompleteListener != null) {
59
- mCompleteListener.onCompleteAll();
60
- }
61
- return;
62
- }
63
-
64
- final CameraStop stop = mQueue.poll();
65
- if (stop == null) {
66
- return;
67
- }
68
-
69
- CameraUpdateItem item = stop.toCameraUpdate(map);
70
- item.run();
71
- execute(map);
72
- }
73
- }