@maplibre/maplibre-react-native 11.0.0-alpha.26 → 11.0.0-alpha.27

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 (243) hide show
  1. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +16 -1
  2. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +20 -32
  3. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNRasterSource.java +1 -1
  4. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNSource.kt +228 -0
  5. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNTileSource.java +0 -1
  6. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNVectorSourceManager.java +2 -2
  7. package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/ClusterPropertyEntry.kt +5 -0
  8. package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/MLRNShapeSource.kt +232 -0
  9. package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/MLRNShapeSourceManager.kt +183 -0
  10. package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/MLRNShapeSourceModule.kt +65 -0
  11. package/android/src/main/java/org/maplibre/reactnative/events/MapPressEvent.kt +1 -1
  12. package/android/src/main/java/org/maplibre/reactnative/events/MapPressEventWithFeatures.kt +24 -0
  13. package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.kt +203 -0
  14. package/android/src/main/java/org/maplibre/reactnative/utils/ExpressionParser.kt +70 -0
  15. package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +37 -20
  16. package/ios/components/camera/MLRNCameraModule.mm +10 -20
  17. package/ios/components/map-view/MLRNMapViewModule.mm +10 -20
  18. package/ios/components/sources/MLRNSource.h +3 -0
  19. package/ios/components/sources/{MLRNShapeSource.h → shape-source/MLRNShapeSource.h} +3 -5
  20. package/ios/components/sources/{MLRNShapeSource.m → shape-source/MLRNShapeSource.m} +4 -12
  21. package/ios/components/sources/shape-source/MLRNShapeSourceComponentView.h +11 -0
  22. package/ios/components/sources/shape-source/MLRNShapeSourceComponentView.mm +163 -0
  23. package/ios/components/sources/shape-source/MLRNShapeSourceModule.h +5 -0
  24. package/ios/components/sources/shape-source/MLRNShapeSourceModule.mm +136 -0
  25. package/ios/utils/MLRNViewModuleUtils.h +35 -0
  26. package/ios/utils/MLRNViewModuleUtils.m +39 -0
  27. package/lib/commonjs/components/annotations/Annotation.js +1 -1
  28. package/lib/commonjs/components/annotations/Annotation.js.map +1 -1
  29. package/lib/commonjs/components/layers/BackgroundLayer.js.map +1 -1
  30. package/lib/commonjs/components/layers/CircleLayer.js.map +1 -1
  31. package/lib/commonjs/components/layers/FillExtrusionLayer.js.map +1 -1
  32. package/lib/commonjs/components/layers/HeatmapLayer.js.map +1 -1
  33. package/lib/commonjs/components/layers/RasterLayer.js.map +1 -1
  34. package/lib/commonjs/components/layers/SymbolLayer.js.map +1 -1
  35. package/lib/commonjs/components/map-view/MapView.js +16 -22
  36. package/lib/commonjs/components/map-view/MapView.js.map +1 -1
  37. package/lib/commonjs/components/sources/VectorSource.js +2 -2
  38. package/lib/commonjs/components/sources/VectorSource.js.map +1 -1
  39. package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js +9 -0
  40. package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js.map +1 -0
  41. package/lib/commonjs/components/sources/shape-source/ShapeSource.js +51 -0
  42. package/lib/commonjs/components/sources/shape-source/ShapeSource.js.map +1 -0
  43. package/lib/commonjs/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
  44. package/lib/commonjs/hooks/useAbstractLayer.js +2 -2
  45. package/lib/commonjs/hooks/useAbstractLayer.js.map +1 -1
  46. package/lib/commonjs/hooks/useFrozenId.js +16 -0
  47. package/lib/commonjs/hooks/useFrozenId.js.map +1 -0
  48. package/lib/commonjs/index.js +1 -1
  49. package/lib/commonjs/index.js.map +1 -1
  50. package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
  51. package/lib/commonjs/types/PressEventWithFeatures.js +6 -0
  52. package/lib/commonjs/types/PressEventWithFeatures.js.map +1 -0
  53. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +0 -6
  54. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  55. package/lib/commonjs/utils/animated/Animated.js +4 -4
  56. package/lib/commonjs/utils/animated/Animated.js.map +1 -1
  57. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +0 -6
  58. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  59. package/lib/commonjs/utils/animated/AnimatedPoint.js +0 -2
  60. package/lib/commonjs/utils/animated/AnimatedPoint.js.map +1 -1
  61. package/lib/commonjs/utils/animated/AnimatedShape.js +3 -16
  62. package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
  63. package/lib/commonjs/utils/findNodeHandle.js +16 -0
  64. package/lib/commonjs/utils/findNodeHandle.js.map +1 -0
  65. package/lib/commonjs/utils/{filterUtils.js → getFilter.js} +2 -2
  66. package/lib/commonjs/utils/getFilter.js.map +1 -0
  67. package/lib/commonjs/utils/index.js +3 -8
  68. package/lib/commonjs/utils/index.js.map +1 -1
  69. package/lib/module/components/annotations/Annotation.js +1 -1
  70. package/lib/module/components/annotations/Annotation.js.map +1 -1
  71. package/lib/module/components/layers/BackgroundLayer.js.map +1 -1
  72. package/lib/module/components/layers/CircleLayer.js.map +1 -1
  73. package/lib/module/components/layers/FillExtrusionLayer.js.map +1 -1
  74. package/lib/module/components/layers/HeatmapLayer.js.map +1 -1
  75. package/lib/module/components/layers/RasterLayer.js.map +1 -1
  76. package/lib/module/components/layers/SymbolLayer.js.map +1 -1
  77. package/lib/module/components/map-view/MapView.js +3 -9
  78. package/lib/module/components/map-view/MapView.js.map +1 -1
  79. package/lib/module/components/sources/VectorSource.js +1 -1
  80. package/lib/module/components/sources/VectorSource.js.map +1 -1
  81. package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js +5 -0
  82. package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js.map +1 -0
  83. package/lib/module/components/sources/shape-source/ShapeSource.js +46 -0
  84. package/lib/module/components/sources/shape-source/ShapeSource.js.map +1 -0
  85. package/lib/module/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
  86. package/lib/module/hooks/useAbstractLayer.js +1 -1
  87. package/lib/module/hooks/useAbstractLayer.js.map +1 -1
  88. package/lib/module/hooks/useFrozenId.js +12 -0
  89. package/lib/module/hooks/useFrozenId.js.map +1 -0
  90. package/lib/module/index.js +1 -1
  91. package/lib/module/index.js.map +1 -1
  92. package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
  93. package/lib/module/types/PressEventWithFeatures.js +4 -0
  94. package/lib/module/types/PressEventWithFeatures.js.map +1 -0
  95. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +0 -7
  96. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  97. package/lib/module/utils/animated/Animated.js +4 -4
  98. package/lib/module/utils/animated/Animated.js.map +1 -1
  99. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +0 -6
  100. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  101. package/lib/module/utils/animated/AnimatedPoint.js +0 -3
  102. package/lib/module/utils/animated/AnimatedPoint.js.map +1 -1
  103. package/lib/module/utils/animated/AnimatedShape.js +3 -16
  104. package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
  105. package/lib/module/utils/findNodeHandle.js +11 -0
  106. package/lib/module/utils/findNodeHandle.js.map +1 -0
  107. package/lib/module/utils/getFilter.js +9 -0
  108. package/lib/module/utils/getFilter.js.map +1 -0
  109. package/lib/module/utils/index.js +3 -8
  110. package/lib/module/utils/index.js.map +1 -1
  111. package/lib/typescript/commonjs/src/components/annotations/Annotation.d.ts +1 -1
  112. package/lib/typescript/commonjs/src/components/annotations/Annotation.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/src/components/layers/BackgroundLayer.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/src/components/layers/CircleLayer.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/components/layers/HeatmapLayer.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/components/layers/RasterLayer.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/components/layers/SymbolLayer.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/components/sources/VectorSource.d.ts +1 -1
  121. package/lib/typescript/commonjs/src/components/sources/VectorSource.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts +10 -0
  123. package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +1 -0
  124. package/lib/typescript/{module/src/components/sources → commonjs/src/components/sources/shape-source}/ShapeSource.d.ts +60 -41
  125. package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSource.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts +35 -0
  127. package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/src/hooks/useFrozenId.d.ts +2 -0
  129. package/lib/typescript/commonjs/src/hooks/useFrozenId.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/index.d.ts +4 -3
  131. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts +1 -1
  134. package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/types/PressEvent.d.ts +0 -3
  136. package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -1
  137. package/lib/typescript/commonjs/src/types/PressEventWithFeatures.d.ts +5 -0
  138. package/lib/typescript/commonjs/src/types/PressEventWithFeatures.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +4 -1
  141. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +2 -2
  146. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/utils/findNodeHandle.d.ts +3 -0
  148. package/lib/typescript/commonjs/src/utils/findNodeHandle.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/src/utils/{filterUtils.d.ts → getFilter.d.ts} +2 -2
  150. package/lib/typescript/commonjs/src/utils/getFilter.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/utils/index.d.ts +3 -3
  152. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  153. package/lib/typescript/module/src/components/annotations/Annotation.d.ts +1 -1
  154. package/lib/typescript/module/src/components/annotations/Annotation.d.ts.map +1 -1
  155. package/lib/typescript/module/src/components/layers/BackgroundLayer.d.ts.map +1 -1
  156. package/lib/typescript/module/src/components/layers/CircleLayer.d.ts.map +1 -1
  157. package/lib/typescript/module/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
  158. package/lib/typescript/module/src/components/layers/HeatmapLayer.d.ts.map +1 -1
  159. package/lib/typescript/module/src/components/layers/RasterLayer.d.ts.map +1 -1
  160. package/lib/typescript/module/src/components/layers/SymbolLayer.d.ts.map +1 -1
  161. package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
  162. package/lib/typescript/module/src/components/sources/VectorSource.d.ts +1 -1
  163. package/lib/typescript/module/src/components/sources/VectorSource.d.ts.map +1 -1
  164. package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts +10 -0
  165. package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +1 -0
  166. package/lib/typescript/{commonjs/src/components/sources → module/src/components/sources/shape-source}/ShapeSource.d.ts +60 -41
  167. package/lib/typescript/module/src/components/sources/shape-source/ShapeSource.d.ts.map +1 -0
  168. package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts +35 -0
  169. package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +1 -0
  170. package/lib/typescript/module/src/hooks/useFrozenId.d.ts +2 -0
  171. package/lib/typescript/module/src/hooks/useFrozenId.d.ts.map +1 -0
  172. package/lib/typescript/module/src/index.d.ts +4 -3
  173. package/lib/typescript/module/src/index.d.ts.map +1 -1
  174. package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
  175. package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts +1 -1
  176. package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts.map +1 -1
  177. package/lib/typescript/module/src/types/PressEvent.d.ts +0 -3
  178. package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -1
  179. package/lib/typescript/module/src/types/PressEventWithFeatures.d.ts +5 -0
  180. package/lib/typescript/module/src/types/PressEventWithFeatures.d.ts.map +1 -0
  181. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  182. package/lib/typescript/module/src/utils/animated/Animated.d.ts +4 -1
  183. package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
  184. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  185. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  186. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  187. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +2 -2
  188. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  189. package/lib/typescript/module/src/utils/findNodeHandle.d.ts +3 -0
  190. package/lib/typescript/module/src/utils/findNodeHandle.d.ts.map +1 -0
  191. package/lib/typescript/module/src/utils/{filterUtils.d.ts → getFilter.d.ts} +2 -2
  192. package/lib/typescript/module/src/utils/getFilter.d.ts.map +1 -0
  193. package/lib/typescript/module/src/utils/index.d.ts +3 -3
  194. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  195. package/package.json +7 -6
  196. package/src/components/annotations/Annotation.tsx +2 -2
  197. package/src/components/layers/BackgroundLayer.tsx +1 -2
  198. package/src/components/layers/CircleLayer.tsx +1 -2
  199. package/src/components/layers/FillExtrusionLayer.tsx +1 -2
  200. package/src/components/layers/HeatmapLayer.tsx +1 -2
  201. package/src/components/layers/RasterLayer.tsx +1 -2
  202. package/src/components/layers/SymbolLayer.tsx +1 -2
  203. package/src/components/map-view/MapView.tsx +2 -14
  204. package/src/components/sources/VectorSource.tsx +2 -2
  205. package/src/components/sources/shape-source/NativeShapeSourceModule.ts +31 -0
  206. package/src/components/sources/shape-source/ShapeSource.tsx +235 -0
  207. package/src/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
  208. package/src/hooks/useAbstractLayer.ts +1 -1
  209. package/src/hooks/useFrozenId.ts +13 -0
  210. package/src/index.ts +4 -3
  211. package/src/modules/snapshot/SnapshotOptions.ts +3 -2
  212. package/src/types/MapLibreRNStyles.ts +1 -1
  213. package/src/types/PressEvent.ts +0 -4
  214. package/src/types/PressEventWithFeatures.ts +5 -0
  215. package/src/utils/animated/AbstractAnimatedCoordinates.ts +0 -9
  216. package/src/utils/animated/Animated.ts +12 -5
  217. package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +0 -9
  218. package/src/utils/animated/AnimatedPoint.ts +0 -2
  219. package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +3 -3
  220. package/src/utils/animated/AnimatedShape.ts +7 -18
  221. package/src/utils/findNodeHandle.ts +14 -0
  222. package/src/utils/{filterUtils.ts → getFilter.ts} +2 -2
  223. package/src/utils/index.ts +12 -12
  224. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNShapeSource.java +0 -248
  225. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNShapeSourceManager.java +0 -216
  226. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNSource.java +0 -240
  227. package/android/src/main/java/org/maplibre/reactnative/utils/ClusterPropertyEntry.java +0 -13
  228. package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +0 -246
  229. package/android/src/main/java/org/maplibre/reactnative/utils/ExpressionParser.java +0 -74
  230. package/ios/components/sources/MLRNShapeSourceManager.h +0 -6
  231. package/ios/components/sources/MLRNShapeSourceManager.m +0 -128
  232. package/lib/commonjs/components/sources/ShapeSource.js +0 -153
  233. package/lib/commonjs/components/sources/ShapeSource.js.map +0 -1
  234. package/lib/commonjs/utils/filterUtils.js.map +0 -1
  235. package/lib/module/components/sources/ShapeSource.js +0 -149
  236. package/lib/module/components/sources/ShapeSource.js.map +0 -1
  237. package/lib/module/utils/filterUtils.js +0 -9
  238. package/lib/module/utils/filterUtils.js.map +0 -1
  239. package/lib/typescript/commonjs/src/components/sources/ShapeSource.d.ts.map +0 -1
  240. package/lib/typescript/commonjs/src/utils/filterUtils.d.ts.map +0 -1
  241. package/lib/typescript/module/src/components/sources/ShapeSource.d.ts.map +0 -1
  242. package/lib/typescript/module/src/utils/filterUtils.d.ts.map +0 -1
  243. package/src/components/sources/ShapeSource.tsx +0 -366
@@ -1,149 +0,0 @@
1
- "use strict";
2
-
3
- import { forwardRef, memo, useImperativeHandle, useRef } from "react";
4
- import { NativeModules, requireNativeComponent } from "react-native";
5
- import { useNativeBridge } from "../../hooks/useNativeBridge.js";
6
- import { cloneReactChildrenWithProps, isAndroid, toJSONString } from "../../utils/index.js";
7
- import { getFilter } from "../../utils/filterUtils.js";
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- const MLRNModule = NativeModules.MLRNModule;
10
- export const NATIVE_MODULE_NAME = "MLRNShapeSource";
11
- /**
12
- * ShapeSource is a map content source that supplies vector shapes to be shown on the map.
13
- * The shape may be a url or a GeoJSON object
14
- */
15
- export const ShapeSource = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(({
16
- id: shapeId = MLRNModule.StyleSource.DefaultSourceID,
17
- ...props
18
- }, ref) => {
19
- useImperativeHandle(ref, () => ({
20
- ..._nativeRef.current,
21
- /**
22
- * Returns all features from the source that match the query parameters regardless of whether or not the feature is
23
- * currently rendered on the map.
24
- *
25
- * @example
26
- * shapeSource.features()
27
- *
28
- * @param {Array=} filter - an optional filter statement to filter the returned Features.
29
- * @return {GeoJSON.FeatureCollection}
30
- */
31
- features,
32
- /**
33
- * Returns the zoom needed to expand the cluster.
34
- *
35
- * @example
36
- * const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
37
- *
38
- * @param {GeoJSON.Feature} feature - The feature cluster to expand.
39
- * @return {number}
40
- */
41
- getClusterExpansionZoom,
42
- /**
43
- * Returns the FeatureCollection from the cluster.
44
- *
45
- * @example
46
- * const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
47
- *
48
- * @param {GeoJSON.Feature} feature - The feature cluster to expand.
49
- * @param {number} limit - The number of points to return.
50
- * @param {number} offset - The amount of points to skip (for pagination).
51
- * @return {GeoJSON.FeatureCollection}
52
- */
53
- getClusterLeaves,
54
- /**
55
- * Returns the FeatureCollection from the cluster (on the next zoom level).
56
- *
57
- * @example
58
- * const collection = await shapeSource.getClusterChildren(clusterId);
59
- *
60
- * @param {GeoJSON.Feature} feature - The feature cluster to expand.
61
- * @return {GeoJSON.FeatureCollection}
62
- */
63
- getClusterChildren,
64
- setNativeProps,
65
- _nativeRef: _nativeRef.current
66
- }));
67
- const _nativeRef = useRef(null);
68
- const {
69
- _runNativeCommand,
70
- _runPendingNativeCommands,
71
- _onAndroidCallback
72
- } = useNativeBridge(NATIVE_MODULE_NAME);
73
- const _setNativeRef = nativeRef => {
74
- _nativeRef.current = nativeRef;
75
- _runPendingNativeCommands(nativeRef);
76
- };
77
- async function features(filter) {
78
- const res = await _runNativeCommand("features", _nativeRef.current, [getFilter(filter)]);
79
- if (isAndroid()) {
80
- return JSON.parse(res.data);
81
- }
82
- return res.data;
83
- }
84
- async function getClusterExpansionZoom(feature) {
85
- const res = await _runNativeCommand("getClusterExpansionZoom", _nativeRef.current, [JSON.stringify(feature)]);
86
- return res.data;
87
- }
88
- async function getClusterLeaves(feature, limit, offset) {
89
- const res = await _runNativeCommand("getClusterLeaves", _nativeRef.current, [JSON.stringify(feature), limit, offset]);
90
- if (isAndroid()) {
91
- return JSON.parse(res.data);
92
- }
93
- return res.data;
94
- }
95
- async function getClusterChildren(feature) {
96
- const res = await _runNativeCommand("getClusterChildren", _nativeRef.current, [JSON.stringify(feature)]);
97
- if (isAndroid()) {
98
- return JSON.parse(res.data);
99
- }
100
- return res.data;
101
- }
102
- function setNativeProps(nativeProps) {
103
- if (!_nativeRef.current) {
104
- return;
105
- }
106
- const shallowProps = Object.assign({}, nativeProps);
107
-
108
- // Adds support for Animated
109
- if (shallowProps.shape && typeof shallowProps.shape !== "string") {
110
- shallowProps.shape = JSON.stringify(shallowProps.shape);
111
- }
112
- _nativeRef.current.setNativeProps(shallowProps);
113
- }
114
- function _getShape() {
115
- if (!props.shape) {
116
- return undefined;
117
- }
118
- return toJSONString(props.shape);
119
- }
120
- const shapeProps = {
121
- id: shapeId,
122
- testID: props.testID,
123
- url: props.url,
124
- shape: _getShape(),
125
- hitbox: props.hitbox,
126
- hasPressListener: !!props.onPress,
127
- onMapboxShapeSourcePress: props.onPress,
128
- cluster: props.cluster ? 1 : 0,
129
- clusterRadius: props.clusterRadius,
130
- clusterMinPoints: props.clusterMinPoints,
131
- clusterMaxZoomLevel: props.clusterMaxZoomLevel,
132
- clusterProperties: props.clusterProperties,
133
- maxZoomLevel: props.maxZoomLevel,
134
- buffer: props.buffer,
135
- tolerance: props.tolerance,
136
- lineMetrics: props.lineMetrics,
137
- onPress: undefined,
138
- ref: _setNativeRef,
139
- onAndroidCallback: isAndroid() ? _onAndroidCallback : undefined
140
- };
141
- return /*#__PURE__*/_jsx(MLRNShapeSource, {
142
- ...shapeProps,
143
- children: cloneReactChildrenWithProps(props.children, {
144
- sourceID: shapeId
145
- })
146
- });
147
- }));
148
- const MLRNShapeSource = requireNativeComponent(NATIVE_MODULE_NAME);
149
- //# sourceMappingURL=ShapeSource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["forwardRef","memo","useImperativeHandle","useRef","NativeModules","requireNativeComponent","useNativeBridge","cloneReactChildrenWithProps","isAndroid","toJSONString","getFilter","jsx","_jsx","MLRNModule","NATIVE_MODULE_NAME","ShapeSource","id","shapeId","StyleSource","DefaultSourceID","props","ref","_nativeRef","current","features","getClusterExpansionZoom","getClusterLeaves","getClusterChildren","setNativeProps","_runNativeCommand","_runPendingNativeCommands","_onAndroidCallback","_setNativeRef","nativeRef","filter","res","JSON","parse","data","feature","stringify","limit","offset","nativeProps","shallowProps","Object","assign","shape","_getShape","undefined","shapeProps","testID","url","hitbox","hasPressListener","onPress","onMapboxShapeSourcePress","cluster","clusterRadius","clusterMinPoints","clusterMaxZoomLevel","clusterProperties","maxZoomLevel","buffer","tolerance","lineMetrics","onAndroidCallback","MLRNShapeSource","children","sourceID"],"sourceRoot":"../../../../src","sources":["components/sources/ShapeSource.tsx"],"mappings":";;AAAA,SAEEA,UAAU,EACVC,IAAI,EAEJC,mBAAmB,EACnBC,MAAM,QACD,OAAO;AACd,SAEEC,aAAa,EAEbC,sBAAsB,QACjB,cAAc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AS;IAClB5B,GAAG,EAAEW,aAAa;IAClBkC,iBAAiB,EAAE1D,SAAS,CAAC,CAAC,GAAGuB,kBAAkB,GAAGkB;EACxD,CAAC;EAED,oBACErC,IAAA,CAACuD,eAAe;IAAA,GAAKjB,UAAU;IAAAkB,QAAA,EAC5B7D,2BAA2B,CAACa,KAAK,CAACgD,QAAQ,EAAE;MAC3CC,QAAQ,EAAEpD;IACZ,CAAC;EAAC,CACa,CAAC;AAEtB,CACF,CACF,CAAC;AAED,MAAMkD,eAAe,GAAG9D,sBAAsB,CAAcS,kBAAkB,CAAC","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- export function getFilter(filter) {
4
- if (!Array.isArray(filter) || filter.length === 0) {
5
- return [];
6
- }
7
- return filter;
8
- }
9
- //# sourceMappingURL=filterUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getFilter","filter","Array","isArray","length"],"sourceRoot":"../../../src","sources":["utils/filterUtils.ts"],"mappings":";;AAEA,OAAO,SAASA,SAASA,CAACC,MAAoC,EAAY;EACxE,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAIA,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;IACjD,OAAO,EAAE;EACX;EAEA,OAAOH,MAAM;AACf","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShapeSource.d.ts","sourceRoot":"","sources":["../../../../../../src/components/sources/ShapeSource.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGT,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,sBAAsB,EAA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AAC;KAChB,CAAC;IAEF,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAExE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnE,gBAAgB,CACd,OAAO,EAAE,OAAO,CAAC,OAAO,EACxB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC,kBAAkB,CAChB,OAAO,EAAE,OAAO,CAAC,OAAO,GACvB,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAG7C,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC3C;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,wGA8LvB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"filterUtils.d.ts","sourceRoot":"","sources":["../../../../../src/utils/filterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,wBAAgB,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,EAAE,CAMxE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShapeSource.d.ts","sourceRoot":"","sources":["../../../../../../src/components/sources/ShapeSource.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGT,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;A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ExE;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAExE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnE,gBAAgB,CACd,OAAO,EAAE,OAAO,CAAC,OAAO,EACxB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC,kBAAkB,CAChB,OAAO,EAAE,OAAO,CAAC,OAAO,GACvB,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAG7C,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC3C;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,wGA8LvB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"filterUtils.d.ts","sourceRoot":"","sources":["../../../../../src/utils/filterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,wBAAgB,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,EAAE,CAMxE"}
@@ -1,366 +0,0 @@
1
- import {
2
- Component,
3
- forwardRef,
4
- memo,
5
- type ReactNode,
6
- useImperativeHandle,
7
- useRef,
8
- } from "react";
9
- import {
10
- type NativeMethods,
11
- NativeModules,
12
- type NativeSyntheticEvent,
13
- requireNativeComponent,
14
- } from "react-native";
15
-
16
- import { useNativeBridge } from "../../hooks/useNativeBridge";
17
- import { type BaseProps } from "../../types/BaseProps";
18
- import {
19
- type ExpressionField,
20
- type FilterExpression,
21
- } from "../../types/MapLibreRNStyles";
22
- import { type PressEventWithFeatures } from "../../types/PressEvent";
23
- import {
24
- cloneReactChildrenWithProps,
25
- isAndroid,
26
- toJSONString,
27
- } from "../../utils";
28
- import { getFilter } from "../../utils/filterUtils";
29
-
30
- const MLRNModule = NativeModules.MLRNModule;
31
- export const NATIVE_MODULE_NAME = "MLRNShapeSource";
32
-
33
- interface NativeProps {
34
- shape?: object | string;
35
- }
36
-
37
- type MLRNShapeSourceRefType = Component<NativeProps> & Readonly<NativeMethods>;
38
-
39
- export interface ShapeSourceProps extends BaseProps {
40
- /**
41
- * A string that uniquely identifies the source.
42
- */
43
- id: string;
44
-
45
- /**
46
- * An HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle.
47
- */
48
- url?: string;
49
-
50
- /**
51
- * The contents of the source. A shape can represent a GeoJSON geometry, a feature, or a feature colllection.
52
- */
53
- shape?:
54
- | GeoJSON.GeometryCollection
55
- | GeoJSON.Feature
56
- | GeoJSON.FeatureCollection
57
- | GeoJSON.Geometry;
58
-
59
- /**
60
- * Enables clustering on the source for point shapes.
61
- */
62
- cluster?: boolean;
63
-
64
- /**
65
- * Specifies the radius of each cluster if clustering is enabled.
66
- * A value of 512 produces a radius equal to the width of a tile.
67
- * The default value is 50.
68
- */
69
- clusterRadius?: number;
70
-
71
- /**
72
- * Specifies minimum number of points to form a cluster if clustering is enabled.
73
- * The default value is 2.
74
- */
75
- clusterMinPoints?: number;
76
-
77
- /**
78
- * Specifies the maximum zoom level at which to cluster points if clustering is enabled.
79
- * Defaults to one zoom level less than the value of maxZoomLevel so that, at the maximum zoom level,
80
- * the shapes are not clustered.
81
- */
82
- clusterMaxZoomLevel?: number;
83
-
84
- /**
85
- * Specifies custom properties on the generated clusters if clustering
86
- * is enabled, aggregating values from clustered points.
87
- *
88
- * Has the form `{ "property_name": [operator, map_expression]}`, where
89
- * `operator` is a custom reduce expression that references a special `["accumulated"]` value -
90
- * it accumulates the property value from clusters/points the cluster contains
91
- * `map_expression` produces the value of a single point
92
- *
93
- * @example `{ "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }`
94
- *
95
- */
96
- clusterProperties?: { [propertyName: string]: ExpressionField };
97
-
98
- /**
99
- * Specifies the maximum zoom level at which to create vector tiles.
100
- * A greater value produces greater detail at high zoom levels.
101
- * The default value is 18.
102
- */
103
- maxZoomLevel?: number;
104
-
105
- /**
106
- * Specifies the size of the tile buffer on each side.
107
- * A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself.
108
- * Larger values produce fewer rendering artifacts near tile edges and slower performance.
109
- * The default value is 128.
110
- */
111
- buffer?: number;
112
-
113
- /**
114
- * Specifies the Douglas-Peucker simplification tolerance.
115
- * A greater value produces simpler geometries and improves performance.
116
- * The default value is 0.375.
117
- */
118
- tolerance?: number;
119
-
120
- /**
121
- * Whether to calculate line distance metrics.
122
- * This is required for line layers that specify lineGradient values.
123
- * The default value is false.
124
- */
125
- lineMetrics?: boolean;
126
-
127
- /**
128
- * Source press listener, gets called when a user presses one of the children layers only if that layer has a higher z-index than another source layers.
129
- */
130
- onPress?: (event: NativeSyntheticEvent<PressEventWithFeatures>) => void;
131
-
132
- /**
133
- * Overrides the default touch hitbox (44x44 pixels) for the source layers
134
- */
135
- hitbox?: {
136
- /**
137
- * `width` of hitbox
138
- */
139
- width: number;
140
- /**
141
- * `height` of hitbox
142
- */
143
- height: number;
144
- };
145
-
146
- children?: ReactNode;
147
- }
148
-
149
- export interface ShapeSourceRef {
150
- features(filter?: FilterExpression): Promise<GeoJSON.FeatureCollection>;
151
-
152
- getClusterExpansionZoom(feature: GeoJSON.Feature): Promise<number>;
153
-
154
- getClusterLeaves(
155
- feature: GeoJSON.Feature,
156
- limit: number,
157
- offset: number,
158
- ): Promise<GeoJSON.FeatureCollection>;
159
-
160
- getClusterChildren(
161
- feature: GeoJSON.Feature,
162
- ): Promise<GeoJSON.FeatureCollection>;
163
-
164
- setNativeProps: (props: NativeProps) => void;
165
-
166
- // this was required by existing test __tests__/utils/animated/AnimatedCoordinatesArray.test.js
167
- _nativeRef: MLRNShapeSourceRefType | null;
168
- }
169
-
170
- /**
171
- * ShapeSource is a map content source that supplies vector shapes to be shown on the map.
172
- * The shape may be a url or a GeoJSON object
173
- */
174
- export const ShapeSource = memo(
175
- forwardRef<ShapeSourceRef, ShapeSourceProps>(
176
- (
177
- {
178
- id: shapeId = MLRNModule.StyleSource.DefaultSourceID,
179
- ...props
180
- }: ShapeSourceProps,
181
- ref,
182
- ) => {
183
- useImperativeHandle(ref, () => ({
184
- ..._nativeRef.current,
185
-
186
- /**
187
- * Returns all features from the source that match the query parameters regardless of whether or not the feature is
188
- * currently rendered on the map.
189
- *
190
- * @example
191
- * shapeSource.features()
192
- *
193
- * @param {Array=} filter - an optional filter statement to filter the returned Features.
194
- * @return {GeoJSON.FeatureCollection}
195
- */
196
- features,
197
-
198
- /**
199
- * Returns the zoom needed to expand the cluster.
200
- *
201
- * @example
202
- * const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
203
- *
204
- * @param {GeoJSON.Feature} feature - The feature cluster to expand.
205
- * @return {number}
206
- */
207
- getClusterExpansionZoom,
208
-
209
- /**
210
- * Returns the FeatureCollection from the cluster.
211
- *
212
- * @example
213
- * const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
214
- *
215
- * @param {GeoJSON.Feature} feature - The feature cluster to expand.
216
- * @param {number} limit - The number of points to return.
217
- * @param {number} offset - The amount of points to skip (for pagination).
218
- * @return {GeoJSON.FeatureCollection}
219
- */
220
- getClusterLeaves,
221
-
222
- /**
223
- * Returns the FeatureCollection from the cluster (on the next zoom level).
224
- *
225
- * @example
226
- * const collection = await shapeSource.getClusterChildren(clusterId);
227
- *
228
- * @param {GeoJSON.Feature} feature - The feature cluster to expand.
229
- * @return {GeoJSON.FeatureCollection}
230
- */
231
- getClusterChildren,
232
-
233
- setNativeProps,
234
-
235
- _nativeRef: _nativeRef.current,
236
- }));
237
-
238
- const _nativeRef = useRef<MLRNShapeSourceRefType>(null);
239
-
240
- const {
241
- _runNativeCommand,
242
- _runPendingNativeCommands,
243
- _onAndroidCallback,
244
- } = useNativeBridge(NATIVE_MODULE_NAME);
245
-
246
- const _setNativeRef = (nativeRef: MLRNShapeSourceRefType): void => {
247
- _nativeRef.current = nativeRef;
248
- _runPendingNativeCommands(nativeRef);
249
- };
250
-
251
- async function features(
252
- filter?: FilterExpression,
253
- ): Promise<GeoJSON.FeatureCollection> {
254
- const res: { data: string | GeoJSON.FeatureCollection } =
255
- await _runNativeCommand("features", _nativeRef.current, [
256
- getFilter(filter),
257
- ]);
258
-
259
- if (isAndroid()) {
260
- return JSON.parse(res.data as string);
261
- }
262
-
263
- return res.data as GeoJSON.FeatureCollection;
264
- }
265
-
266
- async function getClusterExpansionZoom(
267
- feature: GeoJSON.Feature,
268
- ): Promise<number> {
269
- const res: { data: number } = await _runNativeCommand(
270
- "getClusterExpansionZoom",
271
- _nativeRef.current,
272
- [JSON.stringify(feature)],
273
- );
274
- return res.data;
275
- }
276
-
277
- async function getClusterLeaves(
278
- feature: GeoJSON.Feature,
279
- limit: number,
280
- offset: number,
281
- ): Promise<GeoJSON.FeatureCollection> {
282
- const res: { data: string | GeoJSON.FeatureCollection } =
283
- await _runNativeCommand("getClusterLeaves", _nativeRef.current, [
284
- JSON.stringify(feature),
285
- limit,
286
- offset,
287
- ]);
288
-
289
- if (isAndroid()) {
290
- return JSON.parse(res.data as string);
291
- }
292
-
293
- return res.data as GeoJSON.FeatureCollection;
294
- }
295
-
296
- async function getClusterChildren(
297
- feature: GeoJSON.Feature,
298
- ): Promise<GeoJSON.FeatureCollection> {
299
- const res: { data: string | GeoJSON.FeatureCollection } =
300
- await _runNativeCommand("getClusterChildren", _nativeRef.current, [
301
- JSON.stringify(feature),
302
- ]);
303
-
304
- if (isAndroid()) {
305
- return JSON.parse(res.data as string);
306
- }
307
-
308
- return res.data as GeoJSON.FeatureCollection;
309
- }
310
-
311
- function setNativeProps(nativeProps: NativeProps): void {
312
- if (!_nativeRef.current) {
313
- return;
314
- }
315
-
316
- const shallowProps = Object.assign({}, nativeProps);
317
-
318
- // Adds support for Animated
319
- if (shallowProps.shape && typeof shallowProps.shape !== "string") {
320
- shallowProps.shape = JSON.stringify(shallowProps.shape);
321
- }
322
-
323
- _nativeRef.current.setNativeProps(shallowProps);
324
- }
325
-
326
- function _getShape(): string | undefined {
327
- if (!props.shape) {
328
- return undefined;
329
- }
330
- return toJSONString(props.shape);
331
- }
332
-
333
- const shapeProps = {
334
- id: shapeId,
335
- testID: props.testID,
336
- url: props.url,
337
- shape: _getShape(),
338
- hitbox: props.hitbox,
339
- hasPressListener: !!props.onPress,
340
- onMapboxShapeSourcePress: props.onPress,
341
- cluster: props.cluster ? 1 : 0,
342
- clusterRadius: props.clusterRadius,
343
- clusterMinPoints: props.clusterMinPoints,
344
- clusterMaxZoomLevel: props.clusterMaxZoomLevel,
345
- clusterProperties: props.clusterProperties,
346
- maxZoomLevel: props.maxZoomLevel,
347
- buffer: props.buffer,
348
- tolerance: props.tolerance,
349
- lineMetrics: props.lineMetrics,
350
- onPress: undefined,
351
- ref: _setNativeRef,
352
- onAndroidCallback: isAndroid() ? _onAndroidCallback : undefined,
353
- };
354
-
355
- return (
356
- <MLRNShapeSource {...shapeProps}>
357
- {cloneReactChildrenWithProps(props.children, {
358
- sourceID: shapeId,
359
- })}
360
- </MLRNShapeSource>
361
- );
362
- },
363
- ),
364
- );
365
-
366
- const MLRNShapeSource = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);