@maplibre/maplibre-react-native 11.0.0-alpha.21 → 11.0.0-alpha.22

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 (119) hide show
  1. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.kt +2 -3
  2. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +53 -50
  3. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +35 -26
  4. package/android/src/main/java/org/maplibre/reactnative/events/FeatureClickEvent.java +5 -8
  5. package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +2 -2
  6. package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +7 -9
  7. package/ios/components/camera/CameraStop.m +2 -2
  8. package/ios/components/camera/MLRNCameraComponentView.mm +7 -9
  9. package/ios/components/camera/MLRNCameraModule.mm +3 -3
  10. package/ios/components/map-view/MLRNMapTouchEvent.m +14 -8
  11. package/ios/components/map-view/MLRNMapView.m +16 -10
  12. package/ios/components/map-view/MLRNMapViewComponentView.mm +24 -30
  13. package/ios/components/map-view/MLRNMapViewManager.h +8 -8
  14. package/ios/components/map-view/MLRNMapViewManager.m +23 -34
  15. package/ios/components/map-view/MLRNMapViewModule.mm +40 -36
  16. package/lib/commonjs/components/camera/Camera.js +15 -15
  17. package/lib/commonjs/components/camera/Camera.js.map +1 -1
  18. package/lib/commonjs/components/camera/CameraNativeComponent.ts +1 -2
  19. package/lib/commonjs/components/camera/NativeCameraModule.js.map +1 -1
  20. package/lib/commonjs/components/map-view/MapView.js +8 -11
  21. package/lib/commonjs/components/map-view/MapView.js.map +1 -1
  22. package/lib/commonjs/components/map-view/MapViewNativeComponent.ts +7 -6
  23. package/lib/commonjs/components/map-view/NativeMapViewModule.js.map +1 -1
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/types/LngLat.js +2 -0
  26. package/lib/commonjs/types/{Bounds.js.map → LngLat.js.map} +1 -1
  27. package/lib/commonjs/types/LngLatBounds.js +2 -0
  28. package/lib/commonjs/types/LngLatBounds.js.map +1 -0
  29. package/lib/commonjs/types/PixelPoint.js +2 -0
  30. package/lib/commonjs/types/PixelPoint.js.map +1 -0
  31. package/lib/commonjs/types/PixelPointBounds.js +2 -0
  32. package/lib/commonjs/types/PixelPointBounds.js.map +1 -0
  33. package/lib/commonjs/types/PressEvent.js +4 -0
  34. package/lib/module/components/camera/Camera.js +15 -15
  35. package/lib/module/components/camera/Camera.js.map +1 -1
  36. package/lib/module/components/camera/CameraNativeComponent.ts +1 -2
  37. package/lib/module/components/camera/NativeCameraModule.js.map +1 -1
  38. package/lib/module/components/map-view/MapView.js +8 -11
  39. package/lib/module/components/map-view/MapView.js.map +1 -1
  40. package/lib/module/components/map-view/MapViewNativeComponent.ts +7 -6
  41. package/lib/module/components/map-view/NativeMapViewModule.js.map +1 -1
  42. package/lib/module/index.js.map +1 -1
  43. package/lib/module/types/LngLat.js +2 -0
  44. package/lib/module/types/{Bounds.js.map → LngLat.js.map} +1 -1
  45. package/lib/module/types/LngLatBounds.js +2 -0
  46. package/lib/module/types/LngLatBounds.js.map +1 -0
  47. package/lib/module/types/PixelPoint.js +2 -0
  48. package/lib/module/types/PixelPoint.js.map +1 -0
  49. package/lib/module/types/PixelPointBounds.js +2 -0
  50. package/lib/module/types/PixelPointBounds.js.map +1 -0
  51. package/lib/module/types/PressEvent.js +2 -0
  52. package/lib/typescript/commonjs/src/components/camera/Camera.d.ts +15 -21
  53. package/lib/typescript/commonjs/src/components/camera/Camera.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts +1 -2
  55. package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts +1 -2
  57. package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts +66 -42
  59. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts +9 -6
  61. package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts +12 -26
  63. package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/src/index.d.ts +6 -3
  65. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/src/types/LngLat.d.ts +5 -0
  67. package/lib/typescript/commonjs/src/types/LngLat.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/src/types/LngLatBounds.d.ts +12 -0
  69. package/lib/typescript/commonjs/src/types/LngLatBounds.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/src/types/PixelPoint.d.ts +5 -0
  71. package/lib/typescript/commonjs/src/types/PixelPoint.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/src/types/PixelPointBounds.d.ts +10 -0
  73. package/lib/typescript/commonjs/src/types/PixelPointBounds.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/src/types/PressEvent.d.ts +6 -6
  75. package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -1
  76. package/lib/typescript/module/src/components/camera/Camera.d.ts +15 -21
  77. package/lib/typescript/module/src/components/camera/Camera.d.ts.map +1 -1
  78. package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts +1 -2
  79. package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts.map +1 -1
  80. package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts +1 -2
  81. package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts.map +1 -1
  82. package/lib/typescript/module/src/components/map-view/MapView.d.ts +66 -42
  83. package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
  84. package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts +9 -6
  85. package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -1
  86. package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts +12 -26
  87. package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
  88. package/lib/typescript/module/src/index.d.ts +6 -3
  89. package/lib/typescript/module/src/index.d.ts.map +1 -1
  90. package/lib/typescript/module/src/types/LngLat.d.ts +5 -0
  91. package/lib/typescript/module/src/types/LngLat.d.ts.map +1 -0
  92. package/lib/typescript/module/src/types/LngLatBounds.d.ts +12 -0
  93. package/lib/typescript/module/src/types/LngLatBounds.d.ts.map +1 -0
  94. package/lib/typescript/module/src/types/PixelPoint.d.ts +5 -0
  95. package/lib/typescript/module/src/types/PixelPoint.d.ts.map +1 -0
  96. package/lib/typescript/module/src/types/PixelPointBounds.d.ts +10 -0
  97. package/lib/typescript/module/src/types/PixelPointBounds.d.ts.map +1 -0
  98. package/lib/typescript/module/src/types/PressEvent.d.ts +6 -6
  99. package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -1
  100. package/package.json +2 -2
  101. package/src/components/camera/Camera.tsx +24 -26
  102. package/src/components/camera/CameraNativeComponent.ts +1 -2
  103. package/src/components/camera/NativeCameraModule.ts +1 -2
  104. package/src/components/map-view/MapView.tsx +106 -62
  105. package/src/components/map-view/MapViewNativeComponent.ts +7 -6
  106. package/src/components/map-view/NativeMapViewModule.ts +23 -28
  107. package/src/index.ts +8 -4
  108. package/src/types/LngLat.ts +4 -0
  109. package/src/types/LngLatBounds.ts +11 -0
  110. package/src/types/PixelPoint.ts +4 -0
  111. package/src/types/PixelPointBounds.ts +9 -0
  112. package/src/types/PressEvent.ts +7 -8
  113. package/lib/commonjs/types/Bounds.js +0 -2
  114. package/lib/module/types/Bounds.js +0 -2
  115. package/lib/typescript/commonjs/src/types/Bounds.d.ts +0 -2
  116. package/lib/typescript/commonjs/src/types/Bounds.d.ts.map +0 -1
  117. package/lib/typescript/module/src/types/Bounds.d.ts +0 -2
  118. package/lib/typescript/module/src/types/Bounds.d.ts.map +0 -1
  119. package/src/types/Bounds.ts +0 -1
@@ -13,8 +13,7 @@ type NativeViewPadding = {
13
13
  };
14
14
 
15
15
  type NativeViewState = {
16
- longitude?: CodegenTypes.WithDefault<CodegenTypes.Double, -360>;
17
- latitude?: CodegenTypes.WithDefault<CodegenTypes.Double, -360>;
16
+ center?: CodegenTypes.Double[];
18
17
 
19
18
  bounds?: CodegenTypes.Double[];
20
19
 
@@ -29,11 +29,14 @@ import MapViewNativeComponent, {
29
29
  import NativeMapViewModule from "./NativeMapViewModule";
30
30
  import { LogManager } from "../../modules/log/LogManager";
31
31
  import { type BaseProps } from "../../types/BaseProps";
32
- import type { Bounds } from "../../types/Bounds";
32
+ import type { LngLat } from "../../types/LngLat";
33
+ import type { LngLatBounds } from "../../types/LngLatBounds";
33
34
  import {
34
35
  type FilterExpression,
35
36
  type LightLayerStyle,
36
37
  } from "../../types/MapLibreRNStyles";
38
+ import type { PixelPoint } from "../../types/PixelPoint";
39
+ import type { PixelPointBounds } from "../../types/PixelPointBounds";
37
40
  import type { PressEvent } from "../../types/PressEvent";
38
41
  import type { ViewPadding } from "../../types/ViewPadding";
39
42
  import { isAndroid } from "../../utils";
@@ -76,12 +79,11 @@ export type OrnamentViewPosition =
76
79
  | { bottom: number; left: number };
77
80
 
78
81
  export type ViewState = {
79
- longitude: number;
80
- latitude: number;
82
+ center: LngLat;
81
83
  zoom: number;
82
84
  bearing: number;
83
85
  pitch: number;
84
- bounds: Bounds;
86
+ bounds: LngLatBounds;
85
87
  };
86
88
 
87
89
  export type ViewStateChangeEvent = ViewState & {
@@ -90,7 +92,14 @@ export type ViewStateChangeEvent = ViewState & {
90
92
  };
91
93
 
92
94
  export type QueryRenderedFeaturesOptions = {
95
+ /**
96
+ * Filter expression to filter the queried features
97
+ */
93
98
  filter?: FilterExpression;
99
+
100
+ /**
101
+ * IDs of layers to query features from
102
+ */
94
103
  layers?: string[];
95
104
  };
96
105
 
@@ -103,7 +112,7 @@ export interface MapViewRef {
103
112
  *
104
113
  * @return Current center coordinates of the map
105
114
  */
106
- getCenter(): Promise<Pick<ViewState, "longitude" | "latitude">>;
115
+ getCenter(): Promise<LngLat>;
107
116
 
108
117
  /**
109
118
  * Returns the current zoom level of the map
@@ -113,7 +122,7 @@ export interface MapViewRef {
113
122
  *
114
123
  * @return Current zoom level of the map
115
124
  */
116
- getZoom(): Promise<ViewState["zoom"]>;
125
+ getZoom(): Promise<number>;
117
126
 
118
127
  /**
119
128
  * Returns the current bearing of the map
@@ -123,7 +132,7 @@ export interface MapViewRef {
123
132
  *
124
133
  * @return Current bearing of the map
125
134
  */
126
- getBearing(): Promise<ViewState["bearing"]>;
135
+ getBearing(): Promise<number>;
127
136
 
128
137
  /**
129
138
  * Returns the current pitch of the map
@@ -133,7 +142,7 @@ export interface MapViewRef {
133
142
  *
134
143
  * @return Current pitch of the map
135
144
  */
136
- getPitch(): Promise<ViewState["pitch"]>;
145
+ getPitch(): Promise<number>;
137
146
 
138
147
  /**
139
148
  * Returns the current bounds of the map
@@ -143,7 +152,7 @@ export interface MapViewRef {
143
152
  *
144
153
  * @return Current bounds of the map
145
154
  */
146
- getBounds(): Promise<ViewState["bounds"]>;
155
+ getBounds(): Promise<LngLatBounds>;
147
156
 
148
157
  /**
149
158
  * Returns the current view state of the map
@@ -156,54 +165,81 @@ export interface MapViewRef {
156
165
  getViewState(): Promise<ViewState>;
157
166
 
158
167
  /**
159
- * Converts a geographic coordinate to a pixel point of the view
168
+ * Converts geographic coordinates to pixel point of the view
160
169
  *
161
170
  * @example
162
171
  * await mapViewRef.current?.getPointInView([-37.817070, 144.949901]);
163
172
  *
164
- * @param coordinate Geographic coordinate
173
+ * @param coordinates Geographic coordinate
165
174
  * @return Pixel point
166
175
  */
167
- project(coordinate: {
168
- longitude: number;
169
- latitude: number;
170
- }): Promise<{ locationX: number; locationY: number }>;
176
+ project(coordinates: LngLat): Promise<PixelPoint>;
171
177
 
172
178
  /**
173
- * Converts a pixel point of the view to a geographic coordinate.
179
+ * Converts a pixel point of the view to geographic coordinates.
174
180
  *
175
181
  * @example
176
- * await mapViewRef.current?.getCoordinateFromView([100, 100]);
182
+ * await mapViewRef.current?.getCoordinateFromView([280, 640]);
177
183
  *
178
184
  * @param point Pixel point
179
185
  * @return Geographic coordinate
180
186
  */
181
- unproject(point: {
182
- locationX: number;
183
- locationY: number;
184
- }): Promise<{ longitude: number; latitude: number }>;
187
+ unproject(point: PixelPoint): Promise<LngLat>;
185
188
 
186
189
  /**
187
- * Returns an array of rendered map features.
190
+ * Query rendered features at a point
188
191
  *
189
192
  * @example
190
- * await mapViewRef.current?.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])
193
+ * await mapViewRef.current?.queryRenderedFeatures(
194
+ * [240, 640],
195
+ * {
196
+ * filter: ["==", "type", "Point"],
197
+ * layers: ["restaurants", "shops"],
198
+ * },
199
+ * );
191
200
  *
192
- * @param options.filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
193
- * @param options.layers - A array of layer id's to filter the features by
194
- * @return FeatureCollection containing queried features
201
+ * @return Queried features
195
202
  */
196
203
  queryRenderedFeatures(
197
- coordinate: { longitude: number; latitude: number },
204
+ pixelPoint: PixelPoint,
198
205
  options?: QueryRenderedFeaturesOptions,
199
- ): Promise<GeoJSON.FeatureCollection>;
206
+ ): Promise<GeoJSON.Feature[]>;
207
+
208
+ /**
209
+ * Query rendered features within pixel bounds
210
+ *
211
+ * @example
212
+ * await mapViewRef.current?.queryRenderedFeatures(
213
+ * [100, 100, 400, 400],
214
+ * {
215
+ * filter: ["==", "type", "Point"],
216
+ * layers: ["restaurants", "shops"],
217
+ * },
218
+ * );
219
+ *
220
+ * @return Queried features
221
+ */
200
222
  queryRenderedFeatures(
201
- bounds: Bounds,
223
+ pixelPointBounds: PixelPointBounds,
202
224
  options?: QueryRenderedFeaturesOptions,
203
- ): Promise<GeoJSON.FeatureCollection>;
225
+ ): Promise<GeoJSON.Feature[]>;
226
+
227
+ /**
228
+ * Query rendered features within the current viewport
229
+ *
230
+ * @example
231
+ * await mapViewRef.current?.queryRenderedFeatures(
232
+ * {
233
+ * filter: ["==", "type", "Point"],
234
+ * layers: ["restaurants", "shops"],
235
+ * },
236
+ * );
237
+ *
238
+ * @return Queried features
239
+ */
204
240
  queryRenderedFeatures(
205
241
  options?: QueryRenderedFeaturesOptions,
206
- ): Promise<GeoJSON.FeatureCollection>;
242
+ ): Promise<GeoJSON.Feature[]>;
207
243
 
208
244
  /**
209
245
  * Takes snapshot of map with current tiles and returns a URI to the image
@@ -229,13 +265,14 @@ export interface MapViewRef {
229
265
  ): Promise<void>;
230
266
 
231
267
  /**
232
- * Show the attribution action sheet, can be used to implement a
233
- * custom attribution button
268
+ * Show the attribution dialog
269
+ *
270
+ * Can be used to implement a custom attribution button.
234
271
  */
235
272
  showAttribution(): Promise<void>;
236
273
  }
237
274
 
238
- interface MapViewProps extends BaseProps {
275
+ export interface MapViewProps extends BaseProps {
239
276
  children?: ReactNode;
240
277
 
241
278
  /**
@@ -444,7 +481,7 @@ interface MapViewProps extends BaseProps {
444
481
  */
445
482
  export const MapView = memo(
446
483
  forwardRef<MapViewRef, MapViewProps>(
447
- ({ androidView = "surface", style, testID, ...props }, ref) => {
484
+ ({ androidView = "surface", style, ...props }, ref) => {
448
485
  const [isReady, setIsReady] = useState(false);
449
486
 
450
487
  const nativeRef = useRef<
@@ -466,19 +503,17 @@ export const MapView = memo(
466
503
  NativeMapViewModule.getPitch(findNodeHandle(nativeRef.current)),
467
504
 
468
505
  getBounds: () =>
469
- NativeMapViewModule.getBounds(
470
- findNodeHandle(nativeRef.current),
471
- ) as Promise<Bounds>,
506
+ NativeMapViewModule.getBounds(findNodeHandle(nativeRef.current)),
472
507
 
473
508
  getViewState: () =>
474
509
  NativeMapViewModule.getViewState(
475
510
  findNodeHandle(nativeRef.current),
476
511
  ) as Promise<ViewState>,
477
512
 
478
- project: (coordinate) =>
513
+ project: (lngLat) =>
479
514
  NativeMapViewModule.project(
480
515
  findNodeHandle(nativeRef.current),
481
- coordinate,
516
+ lngLat,
482
517
  ),
483
518
 
484
519
  unproject: (point) =>
@@ -488,40 +523,49 @@ export const MapView = memo(
488
523
  ),
489
524
 
490
525
  queryRenderedFeatures: async (
491
- geometryOrOptions?:
492
- | { longitude: number; latitude: number }
493
- | Bounds
526
+ pixelPointOrPixelPointBoundsOrOptions?:
527
+ | PixelPoint
528
+ | PixelPointBounds
494
529
  | QueryRenderedFeaturesOptions,
495
530
  options?: QueryRenderedFeaturesOptions,
496
531
  ) => {
497
532
  if (
498
- geometryOrOptions &&
499
- "longitude" in geometryOrOptions &&
500
- "latitude" in geometryOrOptions
533
+ pixelPointOrPixelPointBoundsOrOptions &&
534
+ Array.isArray(pixelPointOrPixelPointBoundsOrOptions) &&
535
+ ((value: PixelPoint | PixelPointBounds): value is PixelPoint =>
536
+ typeof value[0] === "number" && typeof value[1] === "number")(
537
+ pixelPointOrPixelPointBoundsOrOptions,
538
+ )
501
539
  ) {
502
- return (await NativeMapViewModule.queryRenderedFeaturesWithCoordinate(
540
+ return await NativeMapViewModule.queryRenderedFeaturesWithPoint(
503
541
  findNodeHandle(nativeRef.current),
504
- geometryOrOptions,
542
+ pixelPointOrPixelPointBoundsOrOptions,
505
543
  options?.layers ?? [],
506
544
  getFilter(options?.filter),
507
- )) as GeoJSON.FeatureCollection;
508
- } else if (Array.isArray(geometryOrOptions)) {
509
- return (await NativeMapViewModule.queryRenderedFeaturesWithBounds(
545
+ );
546
+ } else if (
547
+ pixelPointOrPixelPointBoundsOrOptions &&
548
+ Array.isArray(pixelPointOrPixelPointBoundsOrOptions) &&
549
+ ((
550
+ value: PixelPoint | PixelPointBounds,
551
+ ): value is PixelPointBounds =>
552
+ Array.isArray(value[0]) && Array.isArray(value[1]))(
553
+ pixelPointOrPixelPointBoundsOrOptions,
554
+ )
555
+ ) {
556
+ return await NativeMapViewModule.queryRenderedFeaturesWithBounds(
510
557
  findNodeHandle(nativeRef.current),
511
- geometryOrOptions,
558
+ pixelPointOrPixelPointBoundsOrOptions,
512
559
  options?.layers ?? [],
513
560
  getFilter(options?.filter),
514
- )) as GeoJSON.FeatureCollection;
561
+ );
515
562
  } else {
516
- return (await NativeMapViewModule.queryRenderedFeaturesWithBounds(
563
+ return await NativeMapViewModule.queryRenderedFeaturesWithBounds(
517
564
  findNodeHandle(nativeRef.current),
518
- // TODO: Solve this natively
519
- await NativeMapViewModule.getBounds(
520
- findNodeHandle(nativeRef.current),
521
- ),
522
- options?.layers ?? [],
523
- getFilter(options?.filter),
524
- )) as GeoJSON.FeatureCollection;
565
+ null,
566
+ pixelPointOrPixelPointBoundsOrOptions?.layers ?? [],
567
+ getFilter(pixelPointOrPixelPointBoundsOrOptions?.filter),
568
+ );
525
569
  }
526
570
  },
527
571
 
@@ -592,7 +636,7 @@ export const MapView = memo(
592
636
  <View
593
637
  onLayout={() => setIsReady(true)}
594
638
  style={style ?? styles.flex1}
595
- testID={mapView ? undefined : testID}
639
+ testID={nativeProps.testID ? `${nativeProps.testID}View` : undefined}
596
640
  >
597
641
  {mapView}
598
642
  </View>
@@ -24,15 +24,16 @@ type NativeOrnamentViewPosition = {
24
24
  };
25
25
 
26
26
  type NativePressEvent = {
27
- longitude: CodegenTypes.Double;
28
- latitude: CodegenTypes.Double;
29
- locationX: CodegenTypes.Double;
30
- locationY: CodegenTypes.Double;
27
+ lngLat: UnsafeMixed<
28
+ [longitude: CodegenTypes.Double, latitude: CodegenTypes.Double]
29
+ >;
30
+ point: UnsafeMixed<[x: CodegenTypes.Double, y: CodegenTypes.Double]>;
31
31
  };
32
32
 
33
33
  type NativeViewStateEvent = {
34
- longitude: CodegenTypes.Double;
35
- latitude: CodegenTypes.Double;
34
+ center: UnsafeMixed<
35
+ [longitude: CodegenTypes.Double, latitude: CodegenTypes.Double]
36
+ >;
36
37
  zoom: CodegenTypes.Double;
37
38
  bearing: CodegenTypes.Double;
38
39
  pitch: CodegenTypes.Double;
@@ -5,8 +5,7 @@ import {
5
5
  } from "react-native";
6
6
 
7
7
  type NativeViewState = {
8
- longitude: CodegenTypes.Double;
9
- latitude: CodegenTypes.Double;
8
+ center: CodegenTypes.Double[];
10
9
  zoom: CodegenTypes.Double;
11
10
  bearing: CodegenTypes.Double;
12
11
  pitch: CodegenTypes.Double;
@@ -14,10 +13,9 @@ type NativeViewState = {
14
13
  };
15
14
 
16
15
  export interface Spec extends TurboModule {
17
- getCenter: (reactTag: CodegenTypes.Int32) => Promise<{
18
- longitude: CodegenTypes.Double;
19
- latitude: CodegenTypes.Double;
20
- }>;
16
+ getCenter: (
17
+ reactTag: CodegenTypes.Int32,
18
+ ) => Promise<[longitude: CodegenTypes.Double, latitude: CodegenTypes.Double]>;
21
19
 
22
20
  getZoom: (reactTag: CodegenTypes.Int32) => Promise<CodegenTypes.Double>;
23
21
 
@@ -25,45 +23,42 @@ export interface Spec extends TurboModule {
25
23
 
26
24
  getPitch: (reactTag: CodegenTypes.Int32) => Promise<CodegenTypes.Double>;
27
25
 
28
- getBounds: (reactTag: CodegenTypes.Int32) => Promise<CodegenTypes.Double[]>;
26
+ getBounds: (
27
+ reactTag: CodegenTypes.Int32,
28
+ ) => Promise<
29
+ [
30
+ west: CodegenTypes.Double,
31
+ south: CodegenTypes.Double,
32
+ east: CodegenTypes.Double,
33
+ north: CodegenTypes.Double,
34
+ ]
35
+ >;
29
36
 
30
37
  getViewState: (reactTag: CodegenTypes.Int32) => Promise<NativeViewState>;
31
38
 
32
39
  project: (
33
40
  reactTag: CodegenTypes.Int32,
34
- coordinate: {
35
- longitude: CodegenTypes.Double;
36
- latitude: CodegenTypes.Double;
37
- },
38
- ) => Promise<{
39
- locationX: CodegenTypes.Double;
40
- locationY: CodegenTypes.Double;
41
- }>;
41
+ lngLat: CodegenTypes.Double[],
42
+ ) => Promise<[x: CodegenTypes.Double, y: CodegenTypes.Double]>;
42
43
 
43
44
  unproject: (
44
45
  reactTag: CodegenTypes.Int32,
45
- point: { locationX: CodegenTypes.Double; locationY: CodegenTypes.Double },
46
- ) => Promise<{
47
- longitude: CodegenTypes.Double;
48
- latitude: CodegenTypes.Double;
49
- }>;
46
+ pixelPoint: CodegenTypes.Double[],
47
+ ) => Promise<[longitude: CodegenTypes.Double, latitude: CodegenTypes.Double]>;
50
48
 
51
- queryRenderedFeaturesWithCoordinate: (
49
+ queryRenderedFeaturesWithPoint: (
52
50
  reactTag: CodegenTypes.Int32,
53
- coordinate: {
54
- longitude: CodegenTypes.Double;
55
- latitude: CodegenTypes.Double;
56
- },
51
+ pixelPoint: CodegenTypes.Double[],
57
52
  layers: string[],
58
53
  filter: string[],
59
- ) => Promise<object>;
54
+ ) => Promise<GeoJSON.Feature[]>;
60
55
 
61
56
  queryRenderedFeaturesWithBounds: (
62
57
  reactTag: CodegenTypes.Int32,
63
- bounds: CodegenTypes.Double[],
58
+ pixelPointBounds: CodegenTypes.Double[][] | null,
64
59
  layers: string[],
65
60
  filter: string[],
66
- ) => Promise<object>;
61
+ ) => Promise<GeoJSON.Feature[]>;
67
62
 
68
63
  setSourceVisibility: (
69
64
  reactTag: CodegenTypes.Int32,
package/src/index.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from "./MLRNModule";
2
2
 
3
3
  export {
4
+ Camera,
5
+ type CameraProps,
6
+ type CameraRef,
4
7
  type CameraOptions,
5
8
  type CameraEasing,
6
9
  type CameraAnimationOptions,
@@ -10,15 +13,13 @@ export {
10
13
  type CameraBoundsStop,
11
14
  type CameraStop,
12
15
  type InitialViewState,
13
- type CameraRef,
14
16
  type TrackUserLocation,
15
17
  type TrackUserLocationChangeEvent,
16
- type CameraProps,
17
- Camera,
18
18
  } from "./components/camera/Camera";
19
19
 
20
20
  export {
21
21
  MapView,
22
+ type MapViewProps,
22
23
  type MapViewRef,
23
24
  type ViewState,
24
25
  type ViewStateChangeEvent,
@@ -62,7 +63,8 @@ export { OfflineCreatePackOptions } from "./modules/offline/OfflineCreatePackOpt
62
63
  export { SnapshotManager } from "./modules/snapshot/SnapshotManager";
63
64
  export type { SnapshotInputOptions } from "./modules/snapshot/SnapshotOptions";
64
65
 
65
- export type { Bounds } from "./types/Bounds";
66
+ export type { LngLat } from "./types/LngLat";
67
+ export type { LngLatBounds } from "./types/LngLatBounds";
66
68
  export type {
67
69
  FillLayerStyle,
68
70
  LineLayerStyle,
@@ -76,6 +78,8 @@ export type {
76
78
  LightLayerStyle,
77
79
  Expression,
78
80
  } from "./types/MapLibreRNStyles";
81
+ export type { PixelPoint } from "./types/PixelPoint";
82
+ export type { PixelPointBounds } from "./types/PixelPointBounds";
79
83
  export type { PressEvent, PressEventWithFeatures } from "./types/PressEvent";
80
84
  export type { ViewPadding } from "./types/ViewPadding";
81
85
 
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Geographic coordinates
3
+ */
4
+ export type LngLat = [longitude: number, latitude: number];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Represents bounds in geographic coordinates
3
+ *
4
+ * Uses order of south-west and north-east corners in flat style per GeoJSON RFC.
5
+ */
6
+ export type LngLatBounds = [
7
+ west: number,
8
+ south: number,
9
+ east: number,
10
+ north: number,
11
+ ];
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Pixel coordinates
3
+ */
4
+ export type PixelPoint = [x: number, y: number];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Bounds in pixel coordinates
3
+ *
4
+ * Uses common order of top-left and bottom-right corners.
5
+ */
6
+ export type PixelPointBounds = [
7
+ topLeft: [left: number, top: number],
8
+ bottomRight: [right: number, bottom: number],
9
+ ];
@@ -1,17 +1,16 @@
1
- export interface PressEvent {
2
- longitude: number;
3
-
4
- latitude: number;
1
+ import type { LngLat } from "./LngLat";
2
+ import type { PixelPoint } from "./PixelPoint";
5
3
 
4
+ export interface PressEvent {
6
5
  /**
7
- * Touch origin X coordinate inside touchable area (relative to the element).
6
+ * Geographic coordinates of the touch event
8
7
  */
9
- locationX: number;
8
+ lngLat: LngLat;
10
9
 
11
10
  /**
12
- * Touch origin Y coordinate inside touchable area (relative to the element).
11
+ * Pixel point of the touch event within the elements' viewport
13
12
  */
14
- locationY: number;
13
+ point: PixelPoint;
15
14
  }
16
15
 
17
16
  export interface PressEventWithFeatures extends PressEvent {
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=Bounds.js.map
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=Bounds.js.map
@@ -1,2 +0,0 @@
1
- export type Bounds = [west: number, south: number, east: number, north: number];
2
- //# sourceMappingURL=Bounds.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Bounds.d.ts","sourceRoot":"","sources":["../../../../../src/types/Bounds.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export type Bounds = [west: number, south: number, east: number, north: number];
2
- //# sourceMappingURL=Bounds.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Bounds.d.ts","sourceRoot":"","sources":["../../../../../src/types/Bounds.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export type Bounds = [west: number, south: number, east: number, north: number];