@rnmapbox/maps 10.0.0-beta.73 → 10.0.0-beta.75

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 (191) hide show
  1. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +61 -46
  2. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/LocationComponentManager.kt +4 -2
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +7 -2
  4. package/index.d.ts +46 -328
  5. package/javascript/components/AbstractLayer.tsx +2 -1
  6. package/javascript/components/AbstractSource.tsx +3 -1
  7. package/javascript/components/Atmosphere.tsx +2 -1
  8. package/javascript/components/Camera.tsx +6 -4
  9. package/javascript/components/ImageSource.tsx +81 -0
  10. package/javascript/components/Images.tsx +1 -1
  11. package/javascript/components/Light.tsx +60 -0
  12. package/javascript/components/{MapView.js → MapView.tsx} +456 -383
  13. package/javascript/components/NativeBridgeComponent.tsx +1 -1
  14. package/javascript/components/PointAnnotation.tsx +2 -1
  15. package/javascript/components/RasterDemSource.tsx +105 -0
  16. package/javascript/components/RasterSource.tsx +124 -0
  17. package/javascript/components/ShapeSource.tsx +1 -11
  18. package/javascript/components/Terrain.tsx +2 -1
  19. package/javascript/components/VectorSource.tsx +209 -0
  20. package/javascript/modules/location/locationManager.ts +1 -1
  21. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +21 -6
  22. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +19 -4
  23. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +77 -21
  24. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +27 -3
  25. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +1 -1
  26. package/javascript/types/BaseProps.ts +3 -0
  27. package/javascript/types/OnPressEvent.ts +11 -0
  28. package/javascript/utils/{Logger.js → Logger.ts} +32 -14
  29. package/javascript/utils/MapboxStyles.d.ts +1 -1
  30. package/javascript/utils/deprecation.ts +3 -3
  31. package/javascript/utils/geoUtils.ts +91 -0
  32. package/javascript/utils/{index.js → index.ts} +41 -19
  33. package/javascript/utils/nativeRef.ts +28 -0
  34. package/lib/commonjs/components/AbstractLayer.js.map +1 -1
  35. package/lib/commonjs/components/AbstractSource.js.map +1 -1
  36. package/lib/commonjs/components/Atmosphere.js.map +1 -1
  37. package/lib/commonjs/components/Camera.js +4 -4
  38. package/lib/commonjs/components/Camera.js.map +1 -1
  39. package/lib/commonjs/components/ImageSource.js +8 -25
  40. package/lib/commonjs/components/ImageSource.js.map +1 -1
  41. package/lib/commonjs/components/Images.js +1 -1
  42. package/lib/commonjs/components/Images.js.map +1 -1
  43. package/lib/commonjs/components/Light.js +32 -33
  44. package/lib/commonjs/components/Light.js.map +1 -1
  45. package/lib/commonjs/components/MapView.js +30 -289
  46. package/lib/commonjs/components/MapView.js.map +1 -1
  47. package/lib/commonjs/components/NativeBridgeComponent.js.map +1 -1
  48. package/lib/commonjs/components/PointAnnotation.js.map +1 -1
  49. package/lib/commonjs/components/RasterDemSource.js +3 -37
  50. package/lib/commonjs/components/RasterDemSource.js.map +1 -1
  51. package/lib/commonjs/components/RasterSource.js +2 -46
  52. package/lib/commonjs/components/RasterSource.js.map +1 -1
  53. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  54. package/lib/commonjs/components/Terrain.js.map +1 -1
  55. package/lib/commonjs/components/VectorSource.js +15 -74
  56. package/lib/commonjs/components/VectorSource.js.map +1 -1
  57. package/lib/commonjs/modules/location/locationManager.js +2 -1
  58. package/lib/commonjs/modules/location/locationManager.js.map +1 -1
  59. package/lib/commonjs/modules/offline/OfflineCreatePackOptions.js +2 -4
  60. package/lib/commonjs/modules/offline/OfflineCreatePackOptions.js.map +1 -1
  61. package/lib/commonjs/modules/offline/OfflinePack.js.map +1 -1
  62. package/lib/commonjs/modules/offline/offlineManager.js +1 -2
  63. package/lib/commonjs/modules/offline/offlineManager.js.map +1 -1
  64. package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
  65. package/lib/commonjs/modules/snapshot/snapshotManager.js.map +1 -1
  66. package/lib/commonjs/types/BaseProps.js +2 -0
  67. package/lib/commonjs/{utils/index.d.js.map → types/BaseProps.js.map} +1 -1
  68. package/lib/commonjs/types/OnPressEvent.js +2 -0
  69. package/lib/commonjs/{utils/geoUtils.d.js.map → types/OnPressEvent.js.map} +1 -1
  70. package/lib/commonjs/utils/Logger.js +7 -7
  71. package/lib/commonjs/utils/Logger.js.map +1 -1
  72. package/lib/commonjs/utils/deprecation.js +2 -2
  73. package/lib/commonjs/utils/geoUtils.js +15 -23
  74. package/lib/commonjs/utils/geoUtils.js.map +1 -1
  75. package/lib/commonjs/utils/index.js +3 -6
  76. package/lib/commonjs/utils/index.js.map +1 -1
  77. package/lib/commonjs/utils/nativeRef.js +27 -0
  78. package/lib/commonjs/utils/nativeRef.js.map +1 -0
  79. package/lib/module/components/AbstractLayer.js.map +1 -1
  80. package/lib/module/components/AbstractSource.js.map +1 -1
  81. package/lib/module/components/Atmosphere.js.map +1 -1
  82. package/lib/module/components/Camera.js +4 -4
  83. package/lib/module/components/Camera.js.map +1 -1
  84. package/lib/module/components/ImageSource.js +8 -25
  85. package/lib/module/components/ImageSource.js.map +1 -1
  86. package/lib/module/components/Images.js +1 -1
  87. package/lib/module/components/Images.js.map +1 -1
  88. package/lib/module/components/Light.js +29 -32
  89. package/lib/module/components/Light.js.map +1 -1
  90. package/lib/module/components/MapView.js +31 -290
  91. package/lib/module/components/MapView.js.map +1 -1
  92. package/lib/module/components/NativeBridgeComponent.js.map +1 -1
  93. package/lib/module/components/PointAnnotation.js.map +1 -1
  94. package/lib/module/components/RasterDemSource.js +4 -38
  95. package/lib/module/components/RasterDemSource.js.map +1 -1
  96. package/lib/module/components/RasterSource.js +3 -47
  97. package/lib/module/components/RasterSource.js.map +1 -1
  98. package/lib/module/components/ShapeSource.js.map +1 -1
  99. package/lib/module/components/Terrain.js.map +1 -1
  100. package/lib/module/components/VectorSource.js +15 -74
  101. package/lib/module/components/VectorSource.js.map +1 -1
  102. package/lib/module/modules/location/locationManager.js +1 -1
  103. package/lib/module/modules/location/locationManager.js.map +1 -1
  104. package/lib/module/modules/offline/OfflineCreatePackOptions.js +2 -4
  105. package/lib/module/modules/offline/OfflineCreatePackOptions.js.map +1 -1
  106. package/lib/module/modules/offline/OfflinePack.js.map +1 -1
  107. package/lib/module/modules/offline/offlineManager.js +0 -1
  108. package/lib/module/modules/offline/offlineManager.js.map +1 -1
  109. package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
  110. package/lib/module/modules/snapshot/snapshotManager.js.map +1 -1
  111. package/lib/module/types/BaseProps.js +2 -0
  112. package/lib/module/{utils/index.d.js.map → types/BaseProps.js.map} +1 -1
  113. package/lib/module/types/OnPressEvent.js +2 -0
  114. package/lib/module/{utils/geoUtils.d.js.map → types/OnPressEvent.js.map} +1 -1
  115. package/lib/module/utils/Logger.js +7 -7
  116. package/lib/module/utils/Logger.js.map +1 -1
  117. package/lib/module/utils/deprecation.js +2 -2
  118. package/lib/module/utils/geoUtils.js +7 -18
  119. package/lib/module/utils/geoUtils.js.map +1 -1
  120. package/lib/module/utils/index.js +3 -5
  121. package/lib/module/utils/index.js.map +1 -1
  122. package/lib/module/utils/nativeRef.js +21 -0
  123. package/lib/module/utils/nativeRef.js.map +1 -0
  124. package/lib/typescript/components/AbstractLayer.d.ts +2 -1
  125. package/lib/typescript/components/AbstractLayer.d.ts.map +1 -1
  126. package/lib/typescript/components/AbstractSource.d.ts +2 -1
  127. package/lib/typescript/components/AbstractSource.d.ts.map +1 -1
  128. package/lib/typescript/components/Atmosphere.d.ts +2 -1
  129. package/lib/typescript/components/Atmosphere.d.ts.map +1 -1
  130. package/lib/typescript/components/Camera.d.ts.map +1 -1
  131. package/lib/typescript/components/ImageSource.d.ts +32 -0
  132. package/lib/typescript/components/ImageSource.d.ts.map +1 -0
  133. package/lib/typescript/components/Images.d.ts +1 -1
  134. package/lib/typescript/components/Images.d.ts.map +1 -1
  135. package/lib/typescript/components/Light.d.ts +17 -0
  136. package/lib/typescript/components/Light.d.ts.map +1 -0
  137. package/lib/typescript/components/MapView.d.ts +472 -0
  138. package/lib/typescript/components/MapView.d.ts.map +1 -0
  139. package/lib/typescript/components/NativeBridgeComponent.d.ts +1 -1
  140. package/lib/typescript/components/NativeBridgeComponent.d.ts.map +1 -1
  141. package/lib/typescript/components/PointAnnotation.d.ts +3 -2
  142. package/lib/typescript/components/PointAnnotation.d.ts.map +1 -1
  143. package/lib/typescript/components/RasterDemSource.d.ts +46 -0
  144. package/lib/typescript/components/RasterDemSource.d.ts.map +1 -0
  145. package/lib/typescript/components/RasterSource.d.ts +59 -0
  146. package/lib/typescript/components/RasterSource.d.ts.map +1 -0
  147. package/lib/typescript/components/ShapeSource.d.ts +4 -14
  148. package/lib/typescript/components/ShapeSource.d.ts.map +1 -1
  149. package/lib/typescript/components/Terrain.d.ts +2 -1
  150. package/lib/typescript/components/Terrain.d.ts.map +1 -1
  151. package/lib/typescript/components/VectorSource.d.ts +144 -0
  152. package/lib/typescript/components/VectorSource.d.ts.map +1 -0
  153. package/lib/typescript/modules/location/locationManager.d.ts +1 -1
  154. package/lib/typescript/modules/location/locationManager.d.ts.map +1 -1
  155. package/lib/typescript/modules/offline/OfflineCreatePackOptions.d.ts +22 -0
  156. package/lib/typescript/modules/offline/OfflineCreatePackOptions.d.ts.map +1 -0
  157. package/lib/typescript/modules/offline/OfflinePack.d.ts +24 -0
  158. package/lib/typescript/modules/offline/OfflinePack.d.ts.map +1 -0
  159. package/lib/typescript/modules/offline/offlineManager.d.ts +219 -0
  160. package/lib/typescript/modules/offline/offlineManager.d.ts.map +1 -0
  161. package/lib/typescript/modules/snapshot/SnapshotOptions.d.ts +41 -0
  162. package/lib/typescript/modules/snapshot/SnapshotOptions.d.ts.map +1 -0
  163. package/lib/typescript/modules/snapshot/snapshotManager.d.ts +51 -0
  164. package/lib/typescript/modules/snapshot/snapshotManager.d.ts.map +1 -0
  165. package/lib/typescript/types/BaseProps.d.ts +4 -0
  166. package/lib/typescript/types/BaseProps.d.ts.map +1 -0
  167. package/lib/typescript/types/OnPressEvent.d.ts +12 -0
  168. package/lib/typescript/types/OnPressEvent.d.ts.map +1 -0
  169. package/lib/typescript/utils/Logger.d.ts +53 -0
  170. package/lib/typescript/utils/Logger.d.ts.map +1 -0
  171. package/lib/typescript/utils/deprecation.d.ts +4 -3
  172. package/lib/typescript/utils/deprecation.d.ts.map +1 -1
  173. package/lib/typescript/utils/geoUtils.d.ts +23 -0
  174. package/lib/typescript/utils/geoUtils.d.ts.map +1 -0
  175. package/lib/typescript/utils/index.d.ts +48 -0
  176. package/lib/typescript/utils/index.d.ts.map +1 -0
  177. package/lib/typescript/utils/nativeRef.d.ts +21 -0
  178. package/lib/typescript/utils/nativeRef.d.ts.map +1 -0
  179. package/package.json +3 -1
  180. package/javascript/components/ImageSource.js +0 -82
  181. package/javascript/components/Light.js +0 -47
  182. package/javascript/components/RasterDemSource.js +0 -106
  183. package/javascript/components/RasterSource.js +0 -124
  184. package/javascript/components/VectorSource.js +0 -203
  185. package/javascript/utils/geoUtils.d.ts +0 -10
  186. package/javascript/utils/geoUtils.js +0 -73
  187. package/javascript/utils/index.d.ts +0 -27
  188. package/lib/commonjs/utils/geoUtils.d.js +0 -2
  189. package/lib/commonjs/utils/index.d.js +0 -2
  190. package/lib/module/utils/geoUtils.d.js +0 -2
  191. package/lib/module/utils/index.d.js +0 -2
package/index.d.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  declare module 'react-native-mapbox-gl__maps';
2
2
 
3
3
  import { Component, FC, ReactNode } from 'react';
4
- import {
5
- ViewProps,
6
- ViewStyle,
7
- StyleProp,
8
- TextStyle,
9
- ImageSourcePropType,
10
- } from 'react-native';
4
+ import { ViewProps, ViewStyle, StyleProp, TextStyle } from 'react-native';
11
5
  import ReactNative from 'react-native';
12
6
  import {
13
7
  Geometry,
@@ -26,7 +20,6 @@ import type {
26
20
  SymbolLayerStyleProps,
27
21
  CircleLayerStyleProps,
28
22
  FillExtrusionLayerStyleProps,
29
- SkyLayerStyleProps,
30
23
  RasterLayerStyleProps,
31
24
  HeatmapLayerStyleProps,
32
25
  FillLayerStyleProps,
@@ -49,6 +42,7 @@ import {
49
42
  } from './javascript/components/Camera';
50
43
  import _Images from './javascript/components/Images';
51
44
  import _Image from './javascript/components/Image';
45
+ import _MapView, { _MapState } from './javascript/components/MapView';
52
46
  import { MarkerView as _MarkerView } from './javascript/components/MarkerView';
53
47
  import { PointAnnotation as _PointAnnotation } from './javascript/components/PointAnnotation';
54
48
  import { Atmosphere as _Atmosphere } from './javascript/components/Atmosphere';
@@ -59,17 +53,24 @@ import {
59
53
  import _LineLayer, {
60
54
  Props as _LineLayerProps,
61
55
  } from './javascript/components/LineLayer';
56
+ import _SkyLater from './javascript/components/SkyLayer';
62
57
  import { Props as _BackgroundLayerProps } from './javascript/components/BackgroundLayer';
63
58
  import { Props as _CircleLayerProps } from './javascript/components/CircleLayer';
64
59
  import { Props as _FillLayerProps } from './javascript/components/FillLayer';
65
60
  import { Props as _FillExtrusionLayerProps } from './javascript/components/FillExtrusionLayer';
66
61
  import { Props as _RasterLayerProps } from './javascript/components/RasterLayer';
67
62
  import { Props as _HeatmapLayerProps } from './javascript/components/HeatmapLayer';
68
- import { Props as _SkyLayerProps } from './javascript/components/SkyLayer';
63
+ import _SkyLayer, {
64
+ Props as _SkyLayerProps,
65
+ } from './javascript/components/SkyLayer';
69
66
  import {
70
67
  ShapeSource as _ShapeSource,
71
68
  Props as _ShapeSourceProps,
72
69
  } from './javascript/components/ShapeSource';
70
+ import _RasterSource from './javascript/components/RasterSource';
71
+ import _RasterDemSource from './javascript/components/RasterDemSource';
72
+ import _VectorSource from './javascript/components/VectorSource';
73
+ import _Light from './javascript/components/Light';
73
74
  import type {
74
75
  MapboxGLEvent as _MapboxGLEvent,
75
76
  AnimatedPoint as _AnimatedPoint,
@@ -80,67 +81,15 @@ import type {
80
81
  Location as _Location,
81
82
  LocationManager,
82
83
  } from './javascript/modules/location/locationManager';
84
+ import type { OnPressEvent as _OnPressEvent } from './javascript/types/OnPressEvent';
85
+ import {
86
+ type LogLevel,
87
+ type LogObject,
88
+ type LogCallback,
89
+ Logger as _Logger,
90
+ } from './javascript/utils/Logger';
83
91
 
84
- // prettier-ignore
85
- type ExpressionName =
86
- // Types
87
- | 'array' | 'boolean' | 'collator' | 'format' | 'image' | 'literal' | 'number' | 'number-format' | 'object' | 'string'
88
- | 'to-boolean' | 'to-color' | 'to-number' | 'to-string' | 'typeof'
89
- // Feature data
90
- | 'accumulated' | 'feature-state' | 'geometry-type' | 'id' | 'line-progress' | 'properties'
91
- // Lookup
92
- | 'at' | 'get' | 'has' | 'in' | 'index-of' | 'length' | 'slice'
93
- // Decision
94
- | '!' | '!=' | '<' | '<=' | '==' | '>' | '>=' | 'all' | 'any' | 'case' | 'match' | 'coalesce' | 'within'
95
- // Ramps, scales, curves
96
- | 'interpolate' | 'interpolate-hcl' | 'interpolate-lab' | 'step'
97
- // Variable binding
98
- | 'let' | 'var'
99
- // String
100
- | 'concat' | 'downcase' | 'is-supported-script' | 'resolved-locale' | 'upcase'
101
- // Color
102
- | 'rgb' | 'rgba' | 'to-rgba'
103
- // Math
104
- | '-' | '*' | '/' | '%' | '^' | '+' | 'abs' | 'acos' | 'asin' | 'atan' | 'ceil' | 'cos' | 'distance' | 'e'
105
- | 'floor' | 'ln' | 'ln2' | 'log10' | 'log2' | 'max' | 'min' | 'pi' | 'round' | 'sin' | 'sqrt' | 'tan'
106
- // Zoom, Heatmap
107
- | 'zoom' | 'heatmap-density';
108
-
109
- type ExpressionField =
110
- | string
111
- | number
112
- | boolean
113
- | Expression
114
- | ExpressionField[]
115
- | { [key: string]: ExpressionField };
116
-
117
- export type Expression = [ExpressionName, ...ExpressionField[]];
118
-
119
- type Anchor =
120
- | 'center'
121
- | 'left'
122
- | 'right'
123
- | 'top'
124
- | 'bottom'
125
- | 'top-left'
126
- | 'top-right'
127
- | 'bottom-left'
128
- | 'bottom-right';
129
- type Visibility = 'visible' | 'none';
130
- type Alignment = 'map' | 'viewport';
131
- type AutoAlignment = Alignment | 'auto';
132
-
133
- export type OnPressEvent = {
134
- features: Array<GeoJSON.Feature>;
135
- coordinates: {
136
- latitude: number;
137
- longitude: number;
138
- };
139
- point: {
140
- x: number;
141
- y: number;
142
- };
143
- };
92
+ export type OnPressEvent = _OnPressEvent;
144
93
 
145
94
  declare namespace MapboxGL {
146
95
  function removeCustomHeader(headerName: string): void;
@@ -156,6 +105,8 @@ declare namespace MapboxGL {
156
105
  const getAnnotationsLayerID = _getAnnotationsLayerID;
157
106
  type getAnnotationsLayerID = _getAnnotationsLayerID;
158
107
 
108
+ const Logger = _Logger;
109
+ type Logger = _Logger;
159
110
  const Camera = _Camera;
160
111
  type Camera = _Camera;
161
112
  type CameraStop = _CameraStop;
@@ -172,8 +123,14 @@ declare namespace MapboxGL {
172
123
  const PointAnnotation = _PointAnnotation;
173
124
  const SymbolLayer = _SymbolLayer;
174
125
  const LineLayer = _LineLayer;
126
+ type LineLayer = _LineLayer;
175
127
  const ShapeSource = _ShapeSource;
176
128
  type ShapeSource = _ShapeSource;
129
+ const SkyLayer = _SkyLayer;
130
+ type SkyLayer = _SkyLayer;
131
+
132
+ const MapView = _MapView;
133
+ type MapView = _MapView;
177
134
 
178
135
  type MapboxGLEvent = _MapboxGLEvent;
179
136
  type UserTrackingMode = _UserTrackingMode;
@@ -295,56 +252,29 @@ declare namespace MapboxGL {
295
252
  // layers
296
253
  class FillLayer extends Component<_FillLayerProps> {}
297
254
  class FillExtrusionLayer extends Component<_FillExtrusionLayerProps> {}
298
- class LineLayer extends Component<_LineLayerProps> {}
299
255
  class CircleLayer extends Component<_CircleLayerProps> {}
300
256
  class SymbolLayer extends Component<_SymbolLayerProps> {}
301
257
  class RasterLayer extends Component<_RasterLayerProps> {}
302
258
  class BackgroundLayer extends Component<_BackgroundLayerProps> {}
303
259
  }
304
260
 
305
- /**
306
- * Components
307
- */
308
- export class MapView extends Component<MapViewProps> {
309
- getPointInView(coordinate: GeoJSON.Position): Promise<GeoJSON.Position>;
310
- getCoordinateFromView(point: GeoJSON.Position): Promise<GeoJSON.Position>;
311
- getVisibleBounds(): Promise<GeoJSON.Position[]>;
312
- queryRenderedFeaturesAtPoint(
313
- coordinate: GeoJSON.Position,
314
- filter?: Expression,
315
- layerIds?: Array<string>,
316
- ): Promise<GeoJSON.FeatureCollection | undefined>;
317
- queryRenderedFeaturesInRect(
318
- coordinate: GeoJSON.Position,
319
- filter?: Expression,
320
- layerIds?: Array<string>,
321
- ): Promise<GeoJSON.FeatureCollection | undefined>;
322
- takeSnap(writeToDisk?: boolean): Promise<string>;
323
- getZoom(): Promise<number>;
324
- getCenter(): Promise<GeoJSON.Position>;
325
- showAttribution(): void;
326
- setSourceVisibility(
327
- visible: boolean,
328
- sourceId: string,
329
- sourceLayerId?: string,
330
- ): void;
331
- }
332
-
333
261
  type Padding = number | [number, number] | [number, number, number, number];
334
262
 
335
263
  class UserLocation extends Component<UserLocationProps> {}
336
264
 
337
- class Light extends Component<LightProps> {}
265
+ const Light = _Light;
338
266
 
339
267
  class Callout extends Component<CalloutProps> {}
340
- type Style = FC<StyleProps>;
341
268
 
342
269
  /**
343
270
  * Sources
344
271
  */
345
- class VectorSource extends Component<VectorSourceProps> {}
346
- class RasterSource extends Component<RasterSourceProps> {}
347
- class RasterDemSource extends Component<RasterSourceProps> {}
272
+ type VectorSource = _VectorSource;
273
+ const VectorSource = _VectorSource;
274
+ type RasterSource = _RasterSource;
275
+ const RasterSource = _RasterSource;
276
+ type RasterDemSource = RasterDemSource;
277
+ const RasterDemSource = _RasterDemSource;
348
278
 
349
279
  /**
350
280
  * Layers
@@ -353,11 +283,11 @@ declare namespace MapboxGL {
353
283
  class CircleLayer extends Component<_CircleLayerProps> {}
354
284
  class FillExtrusionLayer extends Component<_FillExtrusionLayerProps> {}
355
285
  class FillLayer extends Component<_FillLayerProps> {}
356
- class LineLayer extends Component<_LineLayerProps> {}
357
286
  class RasterLayer extends Component<_RasterLayerProps> {}
358
287
  class HeatmapLayer extends Component<_HeatmapLayerProps> {}
359
288
  class ImageSource extends Component<ImageSourceProps> {}
360
- class SkyLayer extends Component<_SkyLayerProps> {}
289
+ type SkyLayer = _SkyLayer;
290
+ const SkyLayer = _SkyLayer;
361
291
 
362
292
  type Images = _Images;
363
293
  const Images = _Images;
@@ -458,99 +388,6 @@ declare namespace MapboxGL {
458
388
  }
459
389
  }
460
390
 
461
- export type OrnamentPosition =
462
- | { top: number; left: number }
463
- | { top: number; right: number }
464
- | { bottom: number; left: number }
465
- | { bottom: number; right: number };
466
-
467
- export interface RegionPayload {
468
- zoomLevel: number;
469
- heading: number;
470
- animated: boolean;
471
- isUserInteraction: boolean;
472
- visibleBounds: GeoJSON.Position[];
473
- pitch: number;
474
- }
475
-
476
- /**
477
- * v10 only - experimental
478
- */
479
- export interface MapState {
480
- properties: {
481
- center: GeoJSON.Position;
482
- bounds: {
483
- ne: GeoJSON.Position;
484
- sw: GeoJSON.Position;
485
- };
486
- zoom: number;
487
- heading: number;
488
- pitch: number;
489
- };
490
- gestures: {
491
- isGestureActive: boolean;
492
- isAnimatingFromGesture: boolean;
493
- };
494
- }
495
-
496
- export interface MapViewProps extends ViewProps {
497
- animated?: boolean;
498
- userTrackingMode?: MapboxGL.UserTrackingModes;
499
- contentInset?: Array<number>;
500
- projection?: 'mercator' | 'globe';
501
- style?: StyleProp<ViewStyle>;
502
- styleURL?: string;
503
- styleJSON?: string;
504
- preferredFramesPerSecond?: number;
505
- localizeLabels?: boolean;
506
- zoomEnabled?: boolean;
507
- scrollEnabled?: boolean;
508
- pitchEnabled?: boolean;
509
- rotateEnabled?: boolean;
510
- attributionEnabled?: boolean;
511
- attributionPosition?: OrnamentPosition;
512
- logoEnabled?: boolean;
513
- logoPosition?: OrnamentPosition;
514
- compassEnabled?: boolean;
515
- compassFadeWhenNorth?: boolean;
516
- compassPosition?: OrnamentPosition;
517
- compassViewPosition?: number;
518
- compassViewMargins?: Point;
519
- compassImage?: string;
520
- scaleBarEnabled?: boolean;
521
- scaleBarPosition?: OrnamentPosition;
522
- surfaceView?: boolean;
523
- regionWillChangeDebounceTime?: number;
524
- regionDidChangeDebounceTime?: number;
525
- tintColor?: string;
526
-
527
- onPress?: (feature: GeoJSON.Feature) => void;
528
- onLongPress?: (feature: GeoJSON.Feature) => void;
529
- onRegionWillChange?: (
530
- feature: GeoJSON.Feature<GeoJSON.Point, RegionPayload>,
531
- ) => void;
532
- onRegionIsChanging?: (
533
- feature: GeoJSON.Feature<GeoJSON.Point, RegionPayload>,
534
- ) => void;
535
- onRegionDidChange?: (
536
- feature: GeoJSON.Feature<GeoJSON.Point, RegionPayload>,
537
- ) => void;
538
- onCameraChanged?: (state: MapState) => void;
539
- onMapIdle?: (state: MapState) => void;
540
- onUserLocationUpdate?: (feature: Location) => void;
541
- onWillStartLoadingMap?: () => void;
542
- onDidFinishLoadingMap?: () => void;
543
- onDidFailLoadingMap?: () => void;
544
- onWillStartRenderingFrame?: () => void;
545
- onDidFinishRenderingFrame?: () => void;
546
- onDidFinishRenderingFrameFully?: () => void;
547
- onWillStartRenderingMap?: () => void;
548
- onDidFinishRenderingMap?: () => void;
549
- onDidFinishRenderingMapFully?: () => void;
550
- onDidFinishLoadingStyle?: () => void;
551
- onUserTrackingModeChange?: () => void;
552
- }
553
-
554
391
  export interface UserLocationProps {
555
392
  androidRenderMode?: 'normal' | 'compass' | 'gps';
556
393
  animated?: boolean;
@@ -564,20 +401,6 @@ export interface UserLocationProps {
564
401
  visible?: boolean;
565
402
  }
566
403
 
567
- export type WithExpression<T> = {
568
- [P in keyof T]: T[P] | Expression;
569
- };
570
-
571
- export interface LightStyle {
572
- anchor?: Alignment | Expression;
573
- position?: GeoJSON.Position | Expression;
574
- positionTransition?: Transition | Expression;
575
- color?: string | Expression;
576
- colorTransition?: Transition | Expression;
577
- intensity?: number | Expression;
578
- intensityTransition?: Transition | Expression;
579
- }
580
-
581
404
  export interface Transition {
582
405
  duration: number;
583
406
  delay: number;
@@ -597,17 +420,6 @@ export type LineLayerStyle = LineLayerStyleProps;
597
420
 
598
421
  export type RasterLayerStyle = RasterLayerStyleProps;
599
422
 
600
- export type TextVariableAnchorValues =
601
- | 'center'
602
- | 'left'
603
- | 'right'
604
- | 'top'
605
- | 'bottom'
606
- | 'top-left'
607
- | 'top-right'
608
- | 'bottom-left'
609
- | 'bottom-right';
610
-
611
423
  export type SymbolLayerStyle = SymbolLayerStyleProps;
612
424
  export type LineLayerStyle = LineLayerStyleProps;
613
425
 
@@ -618,93 +430,13 @@ export interface Point {
618
430
  y: number;
619
431
  }
620
432
 
621
- export interface LightProps extends Omit<ViewProps, 'style'> {
622
- style?: LightStyle;
623
- }
624
-
625
- export interface StyleProps {
626
- json: any;
627
- }
628
-
629
433
  export interface CalloutProps extends Omit<ViewProps, 'style'> {
630
434
  title?: string;
631
- style?: StyleProp<WithExpression<ViewStyle>>;
632
- containerStyle?: StyleProp<WithExpression<ViewStyle>>;
633
- contentStyle?: StyleProp<WithExpression<ViewStyle>>;
634
- tipStyle?: StyleProp<WithExpression<ViewStyle>>;
635
- textStyle?: StyleProp<WithExpression<TextStyle>>;
636
- }
637
-
638
- export interface TileSourceProps extends ViewProps {
639
- id: string;
640
- url?: string;
641
- tileUrlTemplates?: Array<string>;
642
- minZoomLevel?: number;
643
- maxZoomLevel?: number;
644
- }
645
-
646
- export interface VectorSourceProps extends TileSourceProps {
647
- onPress?: (event: OnPressEvent) => void;
648
- hitbox?: {
649
- width: number;
650
- height: number;
651
- };
652
- }
653
-
654
- export interface RasterSourceProps extends TileSourceProps {
655
- tileSize?: number;
656
- }
657
-
658
- export interface LayerBaseProps<T = object> extends Omit<ViewProps, 'style'> {
659
- id: string;
660
- sourceID?: string;
661
- sourceLayerID?: string;
662
- aboveLayerID?: string;
663
- belowLayerID?: string;
664
- layerIndex?: number;
665
- filter?: Expression;
666
- minZoomLevel?: number;
667
- maxZoomLevel?: number;
668
- }
669
-
670
- export interface BackgroundLayerProps extends LayerBaseProps {
671
- style?: StyleProp<BackgroundLayerStyle>;
672
- }
673
-
674
- export interface CircleLayerProps extends LayerBaseProps {
675
- style?: StyleProp<CircleLayerStyle>;
676
- }
677
-
678
- export interface FillExtrusionLayerProps extends Omit<LayerBaseProps, 'id'> {
679
- id: string;
680
- style?: StyleProp<FillExtrusionLayerStyle>;
681
- }
682
-
683
- export interface FillLayerProps extends LayerBaseProps {
684
- style?: StyleProp<FillLayerStyle>;
685
- }
686
-
687
- export interface LineLayerProps extends LayerBaseProps {
688
- style?: StyleProp<LineLayerStyle>;
689
- }
690
-
691
- export interface RasterLayerProps extends LayerBaseProps {
692
- style?: StyleProp<RasterLayerStyle>;
693
- }
694
-
695
- export interface HeatmapLayerProps extends LayerBaseProps {
696
- style?: StyleProp<HeatmapLayerStyle>;
697
- }
698
-
699
- export interface ImageSourceProps extends ViewProps {
700
- id: string;
701
- url?: number | string;
702
- coordinates: [
703
- GeoJSON.Position,
704
- GeoJSON.Position,
705
- GeoJSON.Position,
706
- GeoJSON.Position,
707
- ];
435
+ style?: StyleProp<ViewStyle>;
436
+ containerStyle?: StyleProp<ViewStyle>;
437
+ contentStyle?: StyleProp<ViewStyle>;
438
+ tipStyle?: StyleProp<ViewStyle>;
439
+ textStyle?: StyleProp<TextStyle>;
708
440
  }
709
441
 
710
442
  export interface OfflineCreatePackOptions {
@@ -727,26 +459,7 @@ export interface SnapshotOptions {
727
459
  writeToDisk?: boolean;
728
460
  }
729
461
 
730
- export interface SkyLayerProps extends LayerBaseProps {
731
- id: string;
732
- style?: StyleProp<SkyLayerStyle>;
733
- }
734
-
735
- // Logger class
736
- type LogLevel = 'error' | 'warning' | 'info' | 'debug' | 'verbose';
737
-
738
- interface LogObject {
739
- level: LogLevel;
740
- message: string;
741
- tag: string;
742
- }
743
-
744
- type LogCallback = (object: LogObject) => void;
745
-
746
- export class Logger {
747
- public static setLogCallback: (cb: LogCallback) => boolean;
748
- public static setLogLevel: (level: LogLevel) => void;
749
- }
462
+ export import Logger = MapboxGL.Logger;
750
463
 
751
464
  export import MapView = MapboxGL.MapView;
752
465
 
@@ -790,6 +503,11 @@ export import AnimatedMapPoint = MapboxGL.AnimatedPoint;
790
503
  export import AnimatedShape = MapboxGL.AnimatedShape;
791
504
  export import Images = MapboxGL.Images;
792
505
  export import Image = MapboxGL.Image;
506
+ export import Light = MapboxGL.Light;
507
+ export import VectorSource = MapboxGL.VectorSource;
508
+ export import MapView = MapboxGL.MapView;
509
+ export import SkyLayer = MapboxGL.SkyLayer;
510
+ export import MapState = _MapState;
793
511
 
794
512
  export const { offlineManager } = MapboxGL;
795
513
 
@@ -5,8 +5,9 @@ import { NativeMethods, processColor } from 'react-native';
5
5
  import { getFilter } from '../utils/filterUtils';
6
6
  import { AllLayerStyleProps, FilterExpression } from '../utils/MapboxStyles';
7
7
  import { transformStyle } from '../utils/StyleValue';
8
+ import type { BaseProps } from '../types/BaseProps';
8
9
 
9
- type PropsBase = {
10
+ type PropsBase = BaseProps & {
10
11
  id: string;
11
12
  sourceID?: string;
12
13
  minZoomLevel?: number;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { NativeMethods } from 'react-native';
3
3
 
4
+ import type { BaseProps } from '../types/BaseProps';
5
+
4
6
  class AbstractSource<
5
7
  PropsType,
6
8
  NativePropsType extends object,
7
- > extends React.PureComponent<PropsType> {
9
+ > extends React.PureComponent<PropsType & BaseProps> {
8
10
  _nativeRef?: React.Component<NativePropsType> & Readonly<NativeMethods>;
9
11
 
10
12
  setNativeProps(props: NativePropsType) {
@@ -3,10 +3,11 @@ import { requireNativeComponent } from 'react-native';
3
3
 
4
4
  import type { AtmosphereLayerStyleProps } from '../utils/MapboxStyles';
5
5
  import { StyleValue, transformStyle } from '../utils/StyleValue';
6
+ import type { BaseProps } from '../types/BaseProps';
6
7
 
7
8
  export const NATIVE_MODULE_NAME = 'RCTMGLAtmosphere';
8
9
 
9
- type Props = {
10
+ type Props = BaseProps & {
10
11
  style: AtmosphereLayerStyleProps;
11
12
  };
12
13
 
@@ -11,6 +11,7 @@ import { NativeModules, requireNativeComponent } from 'react-native';
11
11
 
12
12
  import { MapboxGLEvent } from '../types';
13
13
  import { makeLatLngBounds, makePoint } from '../utils/geoUtils';
14
+ import { type NativeRefType } from '../utils/nativeRef';
14
15
 
15
16
  const NativeModule = NativeModules.MGLModule;
16
17
 
@@ -240,8 +241,9 @@ export const Camera = memo(
240
241
  onUserTrackingModeChange,
241
242
  } = props;
242
243
 
243
- // @ts-expect-error This avoids a type/value mismatch.
244
- const nativeCamera = useRef<RCTMGLCamera>(null);
244
+ const nativeCamera = useRef<typeof RCTMGLCamera>(
245
+ null,
246
+ ) as NativeRefType<NativeCameraProps>;
245
247
 
246
248
  const buildNativeStop = useCallback(
247
249
  (
@@ -352,14 +354,14 @@ export const Camera = memo(
352
354
  if (_nativeStop) {
353
355
  _nativeStops = [..._nativeStops, _nativeStop];
354
356
  }
355
- nativeCamera.current.setNativeProps({
357
+ nativeCamera.current?.setNativeProps({
356
358
  stop: { stops: _nativeStops },
357
359
  });
358
360
  }
359
361
  } else if (config.type === 'CameraStop') {
360
362
  const _nativeStop = buildNativeStop(config);
361
363
  if (_nativeStop) {
362
- nativeCamera.current.setNativeProps({ stop: _nativeStop });
364
+ nativeCamera.current?.setNativeProps({ stop: _nativeStop });
363
365
  }
364
366
  }
365
367
  };
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ import { requireNativeComponent } from 'react-native';
3
+
4
+ import {
5
+ cloneReactChildrenWithProps,
6
+ isNumber,
7
+ resolveImagePath,
8
+ } from '../utils';
9
+ import { BaseProps } from '../types/BaseProps';
10
+
11
+ import AbstractSource from './AbstractSource';
12
+
13
+ export const NATIVE_MODULE_NAME = 'RCTMGLImageSource';
14
+
15
+ type Position = [number, number];
16
+
17
+ type Props = BaseProps & {
18
+ /**
19
+ * A string that uniquely identifies the source.
20
+ */
21
+ id: string;
22
+
23
+ /**
24
+ * An HTTP(S) URL, absolute file URL, or local file URL to the source image.
25
+ * Gifs are currently not supported.
26
+ */
27
+ url?: number | string;
28
+
29
+ /**
30
+ * The top left, top right, bottom right, and bottom left coordinates for the image.
31
+ */
32
+ coordinates: [Position, Position, Position, Position];
33
+
34
+ children?: React.ReactElement | React.ReactElement[];
35
+ };
36
+
37
+ type NativeProps = Props;
38
+
39
+ /**
40
+ * ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
41
+ * The georeferenced image scales and rotates as the user zooms and rotates the map
42
+ */
43
+ class ImageSource extends AbstractSource<Props, NativeProps> {
44
+ _getURL(): string | undefined {
45
+ const { url } = this.props;
46
+
47
+ if (isNumber(url)) {
48
+ return resolveImagePath(url);
49
+ } else {
50
+ return url;
51
+ }
52
+ }
53
+
54
+ render() {
55
+ if (
56
+ !this.props.url ||
57
+ !this.props.coordinates ||
58
+ !this.props.coordinates.length
59
+ ) {
60
+ return null;
61
+ }
62
+
63
+ const props = {
64
+ ...this.props,
65
+ url: this._getURL(),
66
+ };
67
+
68
+ return (
69
+ <RCTMGLImageSource ref={this.setNativeRef} {...props}>
70
+ {cloneReactChildrenWithProps(this.props.children, {
71
+ sourceID: this.props.id,
72
+ })}
73
+ </RCTMGLImageSource>
74
+ );
75
+ }
76
+ }
77
+
78
+ const RCTMGLImageSource =
79
+ requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
80
+
81
+ export default ImageSource;
@@ -69,7 +69,7 @@ interface Props {
69
69
  /**
70
70
  * Images defines the images used in Symbol etc. layers.
71
71
  */
72
- class Images extends React.Component<Props> {
72
+ class Images extends React.PureComponent<Props> {
73
73
  static NATIVE_ASSETS_KEY = 'assets';
74
74
 
75
75
  _getImages() {