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

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 (248) 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/Images.js +1 -1
  28. package/lib/commonjs/components/Images.js.map +1 -1
  29. package/lib/commonjs/components/annotations/Annotation.js +1 -1
  30. package/lib/commonjs/components/annotations/Annotation.js.map +1 -1
  31. package/lib/commonjs/components/layers/BackgroundLayer.js.map +1 -1
  32. package/lib/commonjs/components/layers/CircleLayer.js.map +1 -1
  33. package/lib/commonjs/components/layers/FillExtrusionLayer.js.map +1 -1
  34. package/lib/commonjs/components/layers/HeatmapLayer.js.map +1 -1
  35. package/lib/commonjs/components/layers/RasterLayer.js.map +1 -1
  36. package/lib/commonjs/components/layers/SymbolLayer.js.map +1 -1
  37. package/lib/commonjs/components/map-view/MapView.js +16 -22
  38. package/lib/commonjs/components/map-view/MapView.js.map +1 -1
  39. package/lib/commonjs/components/sources/VectorSource.js +2 -2
  40. package/lib/commonjs/components/sources/VectorSource.js.map +1 -1
  41. package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js +9 -0
  42. package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js.map +1 -0
  43. package/lib/commonjs/components/sources/shape-source/ShapeSource.js +51 -0
  44. package/lib/commonjs/components/sources/shape-source/ShapeSource.js.map +1 -0
  45. package/lib/commonjs/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
  46. package/lib/commonjs/hooks/useAbstractLayer.js +2 -2
  47. package/lib/commonjs/hooks/useAbstractLayer.js.map +1 -1
  48. package/lib/commonjs/hooks/useFrozenId.js +16 -0
  49. package/lib/commonjs/hooks/useFrozenId.js.map +1 -0
  50. package/lib/commonjs/index.js +1 -1
  51. package/lib/commonjs/index.js.map +1 -1
  52. package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
  53. package/lib/commonjs/types/PressEventWithFeatures.js +6 -0
  54. package/lib/commonjs/types/PressEventWithFeatures.js.map +1 -0
  55. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +0 -6
  56. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  57. package/lib/commonjs/utils/animated/Animated.js +4 -4
  58. package/lib/commonjs/utils/animated/Animated.js.map +1 -1
  59. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +0 -6
  60. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  61. package/lib/commonjs/utils/animated/AnimatedPoint.js +0 -2
  62. package/lib/commonjs/utils/animated/AnimatedPoint.js.map +1 -1
  63. package/lib/commonjs/utils/animated/AnimatedShape.js +3 -16
  64. package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
  65. package/lib/commonjs/utils/findNodeHandle.js +16 -0
  66. package/lib/commonjs/utils/findNodeHandle.js.map +1 -0
  67. package/lib/commonjs/utils/{filterUtils.js → getFilter.js} +2 -2
  68. package/lib/commonjs/utils/getFilter.js.map +1 -0
  69. package/lib/commonjs/utils/index.js +3 -8
  70. package/lib/commonjs/utils/index.js.map +1 -1
  71. package/lib/module/components/Images.js +1 -1
  72. package/lib/module/components/Images.js.map +1 -1
  73. package/lib/module/components/annotations/Annotation.js +1 -1
  74. package/lib/module/components/annotations/Annotation.js.map +1 -1
  75. package/lib/module/components/layers/BackgroundLayer.js.map +1 -1
  76. package/lib/module/components/layers/CircleLayer.js.map +1 -1
  77. package/lib/module/components/layers/FillExtrusionLayer.js.map +1 -1
  78. package/lib/module/components/layers/HeatmapLayer.js.map +1 -1
  79. package/lib/module/components/layers/RasterLayer.js.map +1 -1
  80. package/lib/module/components/layers/SymbolLayer.js.map +1 -1
  81. package/lib/module/components/map-view/MapView.js +3 -9
  82. package/lib/module/components/map-view/MapView.js.map +1 -1
  83. package/lib/module/components/sources/VectorSource.js +1 -1
  84. package/lib/module/components/sources/VectorSource.js.map +1 -1
  85. package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js +5 -0
  86. package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js.map +1 -0
  87. package/lib/module/components/sources/shape-source/ShapeSource.js +46 -0
  88. package/lib/module/components/sources/shape-source/ShapeSource.js.map +1 -0
  89. package/lib/module/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
  90. package/lib/module/hooks/useAbstractLayer.js +1 -1
  91. package/lib/module/hooks/useAbstractLayer.js.map +1 -1
  92. package/lib/module/hooks/useFrozenId.js +12 -0
  93. package/lib/module/hooks/useFrozenId.js.map +1 -0
  94. package/lib/module/index.js +1 -1
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
  97. package/lib/module/types/PressEventWithFeatures.js +4 -0
  98. package/lib/module/types/PressEventWithFeatures.js.map +1 -0
  99. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +0 -7
  100. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  101. package/lib/module/utils/animated/Animated.js +4 -4
  102. package/lib/module/utils/animated/Animated.js.map +1 -1
  103. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +0 -6
  104. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  105. package/lib/module/utils/animated/AnimatedPoint.js +0 -3
  106. package/lib/module/utils/animated/AnimatedPoint.js.map +1 -1
  107. package/lib/module/utils/animated/AnimatedShape.js +3 -16
  108. package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
  109. package/lib/module/utils/findNodeHandle.js +11 -0
  110. package/lib/module/utils/findNodeHandle.js.map +1 -0
  111. package/lib/module/utils/getFilter.js +9 -0
  112. package/lib/module/utils/getFilter.js.map +1 -0
  113. package/lib/module/utils/index.js +3 -8
  114. package/lib/module/utils/index.js.map +1 -1
  115. package/lib/typescript/commonjs/src/components/annotations/Annotation.d.ts +1 -1
  116. package/lib/typescript/commonjs/src/components/annotations/Annotation.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/components/layers/BackgroundLayer.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/components/layers/CircleLayer.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/components/layers/HeatmapLayer.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/src/components/layers/RasterLayer.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/components/layers/SymbolLayer.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/src/components/sources/VectorSource.d.ts +1 -1
  125. package/lib/typescript/commonjs/src/components/sources/VectorSource.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts +10 -0
  127. package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +1 -0
  128. package/lib/typescript/{module/src/components/sources → commonjs/src/components/sources/shape-source}/ShapeSource.d.ts +60 -41
  129. package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSource.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts +35 -0
  131. package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/src/hooks/useFrozenId.d.ts +2 -0
  133. package/lib/typescript/commonjs/src/hooks/useFrozenId.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/src/index.d.ts +4 -3
  135. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
  137. package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts +1 -1
  138. package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts.map +1 -1
  139. package/lib/typescript/commonjs/src/types/PressEvent.d.ts +0 -3
  140. package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/src/types/PressEventWithFeatures.d.ts +5 -0
  142. package/lib/typescript/commonjs/src/types/PressEventWithFeatures.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +4 -1
  145. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +2 -2
  150. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/utils/findNodeHandle.d.ts +3 -0
  152. package/lib/typescript/commonjs/src/utils/findNodeHandle.d.ts.map +1 -0
  153. package/lib/typescript/commonjs/src/utils/{filterUtils.d.ts → getFilter.d.ts} +2 -2
  154. package/lib/typescript/commonjs/src/utils/getFilter.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/src/utils/index.d.ts +3 -3
  156. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  157. package/lib/typescript/module/src/components/annotations/Annotation.d.ts +1 -1
  158. package/lib/typescript/module/src/components/annotations/Annotation.d.ts.map +1 -1
  159. package/lib/typescript/module/src/components/layers/BackgroundLayer.d.ts.map +1 -1
  160. package/lib/typescript/module/src/components/layers/CircleLayer.d.ts.map +1 -1
  161. package/lib/typescript/module/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
  162. package/lib/typescript/module/src/components/layers/HeatmapLayer.d.ts.map +1 -1
  163. package/lib/typescript/module/src/components/layers/RasterLayer.d.ts.map +1 -1
  164. package/lib/typescript/module/src/components/layers/SymbolLayer.d.ts.map +1 -1
  165. package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
  166. package/lib/typescript/module/src/components/sources/VectorSource.d.ts +1 -1
  167. package/lib/typescript/module/src/components/sources/VectorSource.d.ts.map +1 -1
  168. package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts +10 -0
  169. package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +1 -0
  170. package/lib/typescript/{commonjs/src/components/sources → module/src/components/sources/shape-source}/ShapeSource.d.ts +60 -41
  171. package/lib/typescript/module/src/components/sources/shape-source/ShapeSource.d.ts.map +1 -0
  172. package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts +35 -0
  173. package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +1 -0
  174. package/lib/typescript/module/src/hooks/useFrozenId.d.ts +2 -0
  175. package/lib/typescript/module/src/hooks/useFrozenId.d.ts.map +1 -0
  176. package/lib/typescript/module/src/index.d.ts +4 -3
  177. package/lib/typescript/module/src/index.d.ts.map +1 -1
  178. package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
  179. package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts +1 -1
  180. package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts.map +1 -1
  181. package/lib/typescript/module/src/types/PressEvent.d.ts +0 -3
  182. package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -1
  183. package/lib/typescript/module/src/types/PressEventWithFeatures.d.ts +5 -0
  184. package/lib/typescript/module/src/types/PressEventWithFeatures.d.ts.map +1 -0
  185. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  186. package/lib/typescript/module/src/utils/animated/Animated.d.ts +4 -1
  187. package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
  188. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  189. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  190. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  191. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +2 -2
  192. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  193. package/lib/typescript/module/src/utils/findNodeHandle.d.ts +3 -0
  194. package/lib/typescript/module/src/utils/findNodeHandle.d.ts.map +1 -0
  195. package/lib/typescript/module/src/utils/{filterUtils.d.ts → getFilter.d.ts} +2 -2
  196. package/lib/typescript/module/src/utils/getFilter.d.ts.map +1 -0
  197. package/lib/typescript/module/src/utils/index.d.ts +3 -3
  198. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  199. package/package.json +8 -7
  200. package/src/components/Images.tsx +2 -2
  201. package/src/components/annotations/Annotation.tsx +2 -2
  202. package/src/components/layers/BackgroundLayer.tsx +1 -2
  203. package/src/components/layers/CircleLayer.tsx +1 -2
  204. package/src/components/layers/FillExtrusionLayer.tsx +1 -2
  205. package/src/components/layers/HeatmapLayer.tsx +1 -2
  206. package/src/components/layers/RasterLayer.tsx +1 -2
  207. package/src/components/layers/SymbolLayer.tsx +1 -2
  208. package/src/components/map-view/MapView.tsx +2 -14
  209. package/src/components/sources/VectorSource.tsx +2 -2
  210. package/src/components/sources/shape-source/NativeShapeSourceModule.ts +31 -0
  211. package/src/components/sources/shape-source/ShapeSource.tsx +235 -0
  212. package/src/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
  213. package/src/hooks/useAbstractLayer.ts +1 -1
  214. package/src/hooks/useFrozenId.ts +13 -0
  215. package/src/index.ts +4 -3
  216. package/src/modules/snapshot/SnapshotOptions.ts +3 -2
  217. package/src/types/MapLibreRNStyles.ts +1 -1
  218. package/src/types/PressEvent.ts +0 -4
  219. package/src/types/PressEventWithFeatures.ts +5 -0
  220. package/src/utils/animated/AbstractAnimatedCoordinates.ts +0 -9
  221. package/src/utils/animated/Animated.ts +12 -5
  222. package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +0 -9
  223. package/src/utils/animated/AnimatedPoint.ts +0 -2
  224. package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +3 -3
  225. package/src/utils/animated/AnimatedShape.ts +7 -18
  226. package/src/utils/findNodeHandle.ts +14 -0
  227. package/src/utils/{filterUtils.ts → getFilter.ts} +2 -2
  228. package/src/utils/index.ts +12 -12
  229. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNShapeSource.java +0 -248
  230. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNShapeSourceManager.java +0 -216
  231. package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNSource.java +0 -240
  232. package/android/src/main/java/org/maplibre/reactnative/utils/ClusterPropertyEntry.java +0 -13
  233. package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +0 -246
  234. package/android/src/main/java/org/maplibre/reactnative/utils/ExpressionParser.java +0 -74
  235. package/ios/components/sources/MLRNShapeSourceManager.h +0 -6
  236. package/ios/components/sources/MLRNShapeSourceManager.m +0 -128
  237. package/lib/commonjs/components/sources/ShapeSource.js +0 -153
  238. package/lib/commonjs/components/sources/ShapeSource.js.map +0 -1
  239. package/lib/commonjs/utils/filterUtils.js.map +0 -1
  240. package/lib/module/components/sources/ShapeSource.js +0 -149
  241. package/lib/module/components/sources/ShapeSource.js.map +0 -1
  242. package/lib/module/utils/filterUtils.js +0 -9
  243. package/lib/module/utils/filterUtils.js.map +0 -1
  244. package/lib/typescript/commonjs/src/components/sources/ShapeSource.d.ts.map +0 -1
  245. package/lib/typescript/commonjs/src/utils/filterUtils.d.ts.map +0 -1
  246. package/lib/typescript/module/src/components/sources/ShapeSource.d.ts.map +0 -1
  247. package/lib/typescript/module/src/utils/filterUtils.d.ts.map +0 -1
  248. package/src/components/sources/ShapeSource.tsx +0 -366
@@ -26,7 +26,8 @@ import org.maplibre.reactnative.components.layers.MLRNRasterLayerManager
26
26
  import org.maplibre.reactnative.components.layers.MLRNSymbolLayerManager
27
27
  import org.maplibre.reactnative.components.sources.MLRNImageSourceManager
28
28
  import org.maplibre.reactnative.components.sources.MLRNRasterSourceManager
29
- import org.maplibre.reactnative.components.sources.MLRNShapeSourceManager
29
+ import org.maplibre.reactnative.components.sources.shapesource.MLRNShapeSourceManager
30
+ import org.maplibre.reactnative.components.sources.shapesource.MLRNShapeSourceModule
30
31
  import org.maplibre.reactnative.components.sources.MLRNVectorSourceManager
31
32
  import org.maplibre.reactnative.modules.MLRNLocationModule
32
33
  import org.maplibre.reactnative.modules.MLRNLogModule
@@ -52,6 +53,11 @@ class MLRNPackage : BaseReactPackage() {
52
53
  getReactTagResolver(reactContext)
53
54
  )
54
55
 
56
+ MLRNShapeSourceModule.NAME -> return MLRNShapeSourceModule(
57
+ reactContext,
58
+ getReactTagResolver(reactContext)
59
+ )
60
+
55
61
 
56
62
  MLRNOfflineModule.REACT_CLASS -> return MLRNOfflineModule(reactContext)
57
63
  MLRNSnapshotModule.NAME -> return MLRNSnapshotModule(reactContext)
@@ -93,6 +99,15 @@ class MLRNPackage : BaseReactPackage() {
93
99
  isTurboModule = true
94
100
  )
95
101
 
102
+ moduleInfos[MLRNShapeSourceModule.NAME] = ReactModuleInfo(
103
+ MLRNShapeSourceModule.NAME,
104
+ MLRNShapeSourceModule.NAME,
105
+ canOverrideExistingModule = false,
106
+ needsEagerInit = false,
107
+ isCxxModule = false,
108
+ isTurboModule = true
109
+ )
110
+
96
111
  moduleInfos[MLRNOfflineModule.REACT_CLASS] = ReactModuleInfo(
97
112
  MLRNOfflineModule.REACT_CLASS,
98
113
  MLRNOfflineModule.REACT_CLASS,
@@ -64,7 +64,6 @@ import org.maplibre.reactnative.events.MapChangeEvent
64
64
  import org.maplibre.reactnative.events.MapPressEvent
65
65
  import org.maplibre.reactnative.modules.MLRNModule
66
66
  import org.maplibre.reactnative.utils.BitmapUtils
67
- import org.maplibre.reactnative.utils.ConvertUtils
68
67
  import org.maplibre.reactnative.utils.GeoJSONUtils
69
68
  import kotlin.math.roundToInt
70
69
 
@@ -537,24 +536,21 @@ open class MLRNMapView(
537
536
  val screenPoint = mapLibreMap!!.projection.toScreenLocation(latLng)
538
537
  val touchableSources = this.allTouchableSources
539
538
 
540
- val hits: MutableMap<String?, MutableList<Feature?>?> = HashMap()
539
+ val hits: MutableMap<String, MutableList<Feature>?> = HashMap()
541
540
  val hitTouchableSources: MutableList<MLRNSource<*>> = ArrayList()
542
541
  for (touchableSource in touchableSources) {
543
- val hitbox = touchableSource.getTouchHitbox() ?: continue
542
+ val hitbox = touchableSource.hitbox ?: continue
544
543
 
545
- val halfWidth = hitbox["width"]!!.toFloat() / 2.0f
546
- val halfHeight = hitbox["height"]!!.toFloat() / 2.0f
547
-
548
- val hitboxF = RectF()
549
- hitboxF.set(
550
- screenPoint.x - halfWidth,
551
- screenPoint.y - halfHeight,
552
- screenPoint.x + halfWidth,
553
- screenPoint.y + halfHeight
544
+ val pointWithHitbox = RectF(
545
+ screenPoint.x - hitbox.left,
546
+ screenPoint.y - hitbox.top,
547
+ screenPoint.x + hitbox.right,
548
+ screenPoint.y + hitbox.bottom
554
549
  )
555
550
 
551
+
556
552
  val features =
557
- mapLibreMap!!.queryRenderedFeatures(hitboxF, *touchableSource.getLayerIDs())
553
+ mapLibreMap!!.queryRenderedFeatures(pointWithHitbox, *touchableSource.getLayerIDs())
558
554
  if (features.isNotEmpty()) {
559
555
  hits[touchableSource.getID()] = features
560
556
  hitTouchableSources.add(touchableSource)
@@ -563,12 +559,15 @@ open class MLRNMapView(
563
559
 
564
560
  if (hits.isNotEmpty()) {
565
561
  val source = getTouchableSourceWithHighestZIndex(hitTouchableSources)
566
- if (source != null && source.hasPressListener()) {
567
- source.onPress(
568
- OnPressEvent(
569
- hits[source.getID()]!!, latLng, screenPoint
562
+ if (source != null && source.hasOnPress()) {
563
+ hits[source.getID()]?.let {
564
+ source.onPress(
565
+ OnPressEvent(
566
+ it, latLng, screenPoint
567
+ )
570
568
  )
571
- )
569
+ }
570
+
572
571
  return true
573
572
  }
574
573
  }
@@ -907,13 +906,7 @@ open class MLRNMapView(
907
906
  filter,
908
907
  *(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
909
908
 
910
-
911
- val result = Arguments.createArray()
912
- for (feature in features) {
913
- val jsonObject = com.google.gson.JsonParser.parseString(feature.toJson()).asJsonObject
914
- result.pushMap(ConvertUtils.toWritableMap(jsonObject))
915
- }
916
- return result
909
+ return GeoJSONUtils.fromFeatureList(features)
917
910
  }
918
911
 
919
912
 
@@ -938,12 +931,7 @@ open class MLRNMapView(
938
931
  filter,
939
932
  *(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
940
933
 
941
- val result = Arguments.createArray()
942
- for (feature in features) {
943
- val jsonObject = com.google.gson.JsonParser.parseString(feature.toJson()).asJsonObject
944
- result.pushMap(ConvertUtils.toWritableMap(jsonObject))
945
- }
946
- return result
934
+ return GeoJSONUtils.fromFeatureList(features)
947
935
  }
948
936
 
949
937
  fun project(mapCoordinate: LatLng): WritableArray {
@@ -1258,7 +1246,7 @@ open class MLRNMapView(
1258
1246
 
1259
1247
  for (key in this.sources.keys) {
1260
1248
  val source = this.sources[key]
1261
- if (source != null && source.hasPressListener()) {
1249
+ if (source != null && source.hasOnPress()) {
1262
1250
  sources.add(source)
1263
1251
  }
1264
1252
  }
@@ -29,7 +29,7 @@ public class MLRNRasterSource extends MLRNTileSource<RasterSource> {
29
29
  }
30
30
 
31
31
  @Override
32
- public boolean hasPressListener() {
32
+ public boolean hasOnPress() {
33
33
  return false;
34
34
  }
35
35
 
@@ -0,0 +1,228 @@
1
+ package org.maplibre.reactnative.components.sources
2
+
3
+ import android.content.Context
4
+ import android.graphics.PointF
5
+ import android.graphics.RectF
6
+ import android.view.View
7
+ import com.facebook.react.bridge.ReadableMap
8
+ import org.maplibre.android.geometry.LatLng
9
+ import org.maplibre.android.log.Logger
10
+ import org.maplibre.android.maps.MapLibreMap
11
+ import org.maplibre.android.maps.Style
12
+ import org.maplibre.android.style.sources.Source
13
+ import org.maplibre.geojson.Feature
14
+ import org.maplibre.reactnative.components.AbstractMapFeature
15
+ import org.maplibre.reactnative.components.layers.MLRNLayer
16
+ import org.maplibre.reactnative.components.mapview.MLRNMapView
17
+
18
+ abstract class MLRNSource<T : Source?>(context: Context?) : AbstractMapFeature(context) {
19
+ protected var mMapView: MLRNMapView? = null
20
+
21
+ @JvmField
22
+ protected var mMap: MapLibreMap? = null
23
+
24
+ @JvmField
25
+ protected var mID: String? = null
26
+
27
+ @JvmField
28
+ protected var mSource: T? = null
29
+ protected var mHasOnPress: Boolean = false
30
+
31
+ protected var mLayers: MutableList<MLRNLayer<*>> = ArrayList()
32
+ private var mQueuedLayers: MutableList<MLRNLayer<*>?>? = ArrayList()
33
+
34
+ fun getID(): String {
35
+ return mID!!
36
+ }
37
+
38
+ fun setID(id: String) {
39
+ mID = id
40
+ }
41
+
42
+ fun getLayerIDs(): Array<String?> {
43
+ val layerIDs: MutableList<String?> = ArrayList()
44
+
45
+ for (i in mLayers.indices) {
46
+ val layer = mLayers[i]
47
+ layerIDs.add(layer.getID())
48
+ }
49
+
50
+ return layerIDs.toTypedArray<String?>()
51
+ }
52
+
53
+ open fun hasOnPress(): Boolean {
54
+ return mHasOnPress
55
+ }
56
+
57
+ fun setHasOnPress(hasPressListener: Boolean) {
58
+ mHasOnPress = hasPressListener
59
+ }
60
+
61
+ fun setSource(source: T?) {
62
+ mSource = source
63
+ }
64
+
65
+ var hitbox: RectF? = null
66
+ get() {
67
+ if (!hasOnPress()) {
68
+ return null
69
+ }
70
+
71
+ if (field == null) {
72
+ return DEFAULT_HITBOX
73
+ }
74
+
75
+ return field
76
+ }
77
+
78
+ fun setReactHitbox(map: ReadableMap?) {
79
+ hitbox = if (map != null) {
80
+ RectF(
81
+ map.getDouble("left").toFloat(),
82
+ map.getDouble("top").toFloat(),
83
+ map.getDouble("right").toFloat(),
84
+ map.getDouble("bottom").toFloat()
85
+ )
86
+ } else {
87
+ null
88
+ }
89
+ }
90
+
91
+ val layerCount: Int
92
+ get() {
93
+ var totalCount = 0
94
+
95
+ if (mQueuedLayers != null) {
96
+ totalCount = mQueuedLayers!!.size
97
+ }
98
+
99
+ totalCount += mLayers.size
100
+ return totalCount
101
+ }
102
+
103
+ override fun addToMap(mapView: MLRNMapView) {
104
+ mMapView = mapView
105
+ mMap = mapView.mapLibreMap
106
+ mMap!!.getStyle { style ->
107
+ val existingSource = style.getSourceAs<T?>(mID!!)
108
+ if (existingSource != null) {
109
+ mSource = existingSource
110
+ } else {
111
+ mSource = makeSource()
112
+ style.addSource(mSource!!)
113
+ }
114
+
115
+ if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) { // first load
116
+ for (i in mQueuedLayers!!.indices) {
117
+ addLayerToMap(mQueuedLayers!![i], i)
118
+ }
119
+ mQueuedLayers = null
120
+ } else if (mLayers.isNotEmpty()) { // handles the case of switching style url, but keeping layers on map
121
+ for (i in mLayers.indices) {
122
+ addLayerToMap(mLayers[i], i)
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ override fun removeFromMap(mapView: MLRNMapView?) {
129
+ if (mLayers.isNotEmpty()) {
130
+ for (i in mLayers.indices) {
131
+ val layer = mLayers[i]
132
+ layer.removeFromMap(mMapView)
133
+ }
134
+ }
135
+ if (mQueuedLayers != null) {
136
+ mQueuedLayers!!.clear()
137
+ }
138
+ if (mMap != null && mSource != null && mMap!!.style != null) {
139
+ try {
140
+ mMap!!.style!!.removeSource(mSource!!)
141
+ } catch (ex: Throwable) {
142
+ Logger.w(
143
+ LOG_TAG,
144
+ String.format("MLRNSource.removeFromMap: %s - %s", mSource, ex.message),
145
+ ex
146
+ )
147
+ }
148
+ }
149
+ }
150
+
151
+ fun addLayer(childView: View?, childPosition: Int) {
152
+ if (childView !is MLRNLayer<*>) {
153
+ return
154
+ }
155
+
156
+ if (mMap == null) {
157
+ mQueuedLayers!!.add(childPosition, childView)
158
+ } else {
159
+ addLayerToMap(childView, childPosition)
160
+ }
161
+ }
162
+
163
+ fun removeLayer(childPosition: Int) {
164
+ val layer: MLRNLayer<*>? = if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
165
+ mQueuedLayers!![childPosition]
166
+ } else {
167
+ mLayers[childPosition]
168
+ }
169
+ removeLayerFromMap(layer, childPosition)
170
+ }
171
+
172
+ fun getLayerAt(childPosition: Int): MLRNLayer<*>? {
173
+ if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
174
+ return mQueuedLayers!![childPosition]
175
+ }
176
+ return mLayers[childPosition]
177
+ }
178
+
179
+ protected fun addLayerToMap(layer: MLRNLayer<*>?, childPosition: Int) {
180
+ if (mMapView == null || layer == null) {
181
+ return
182
+ }
183
+
184
+ layer.addToMap(mMapView)
185
+ if (!mLayers.contains(layer)) {
186
+ mLayers.add(childPosition, layer)
187
+ }
188
+ }
189
+
190
+ protected fun removeLayerFromMap(layer: MLRNLayer<*>?, childPosition: Int) {
191
+ if (mMapView != null && layer != null) {
192
+ layer.removeFromMap(mMapView)
193
+ }
194
+ if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
195
+ mQueuedLayers!!.removeAt(childPosition)
196
+ } else {
197
+ mLayers.removeAt(childPosition)
198
+ }
199
+ }
200
+
201
+ val style: Style?
202
+ get() {
203
+ if (mMap == null) return null
204
+ return mMap!!.style
205
+ }
206
+
207
+ abstract fun makeSource(): T?
208
+
209
+ class OnPressEvent(
210
+ @JvmField var features: MutableList<Feature>,
211
+ @JvmField var latLng: LatLng,
212
+ @JvmField var screenPoint: PointF
213
+ )
214
+
215
+ abstract fun onPress(event: OnPressEvent)
216
+
217
+ companion object {
218
+ const val DEFAULT_ID: String = "composite"
219
+ const val LOG_TAG: String = "MLRNSource"
220
+
221
+ val DEFAULT_HITBOX: RectF = RectF(22.0f, 22.0f, 22.0f, 22.0f)
222
+
223
+ @JvmStatic
224
+ fun isDefaultSource(sourceID: String?): Boolean {
225
+ return DEFAULT_ID == sourceID
226
+ }
227
+ }
228
+ }
@@ -7,7 +7,6 @@ import org.maplibre.android.style.sources.TileSet;
7
7
 
8
8
  import java.util.Collection;
9
9
 
10
- @SuppressWarnings("unused")
11
10
  public abstract class MLRNTileSource<T extends Source> extends MLRNSource<T> {
12
11
  static final String TILE_SPEC_VERSION = "2.1.0";
13
12
 
@@ -37,12 +37,12 @@ public class MLRNVectorSourceManager extends MLRNTileSourceManager<MLRNVectorSou
37
37
 
38
38
  @ReactProp(name = "hasPressListener")
39
39
  public void setHasPressListener(MLRNVectorSource source, boolean hasPressListener) {
40
- source.setHasPressListener(hasPressListener);
40
+ source.setHasOnPress(hasPressListener);
41
41
  }
42
42
 
43
43
  @ReactProp(name="hitbox")
44
44
  public void setHitbox(MLRNVectorSource source, ReadableMap map) {
45
- source.setHitbox(map);
45
+ source.setReactHitbox(map);
46
46
  }
47
47
 
48
48
  @Override
@@ -0,0 +1,5 @@
1
+ package org.maplibre.reactnative.components.sources.shapesource
2
+
3
+ import org.maplibre.android.style.expressions.Expression
4
+
5
+ class ClusterPropertyEntry(var operator: Expression, var mapping: Expression)
@@ -0,0 +1,232 @@
1
+ package org.maplibre.reactnative.components.sources.shapesource
2
+
3
+ import android.content.Context
4
+ import com.facebook.react.bridge.ReactContext
5
+ import com.facebook.react.bridge.WritableArray
6
+ import com.facebook.react.bridge.WritableMap
7
+ import com.facebook.react.uimanager.UIManagerHelper
8
+ import com.facebook.react.uimanager.events.EventDispatcher
9
+ import com.google.gson.JsonObject
10
+ import org.maplibre.android.style.expressions.Expression
11
+ import org.maplibre.android.style.sources.GeoJsonOptions
12
+ import org.maplibre.android.style.sources.GeoJsonSource
13
+ import org.maplibre.geojson.Feature
14
+ import org.maplibre.geojson.FeatureCollection
15
+ import org.maplibre.geojson.Point
16
+ import org.maplibre.reactnative.components.mapview.MLRNMapView
17
+ import org.maplibre.reactnative.components.sources.MLRNSource
18
+ import org.maplibre.reactnative.events.MapPressEventWithFeatures
19
+ import org.maplibre.reactnative.utils.GeoJSONUtils
20
+ import java.net.URI
21
+
22
+ class MLRNShapeSource(context: Context) : MLRNSource<GeoJsonSource?>(context) {
23
+ private var uri: URI? = null
24
+ private var geoJson: String? = null
25
+
26
+ private var maxZoom: Int? = null
27
+ private var buffer: Int? = null
28
+ private var tolerance: Double? = null
29
+ private var lineMetrics: Boolean? = null
30
+
31
+ private var cluster: Boolean? = null
32
+ private var clusterRadius: Int? = null
33
+ private var clusterMinPoints: Int? = null
34
+ private var clusterMaxZoom: Int? = null
35
+ private var clusterProperties: MutableList<MutableMap.MutableEntry<String, ClusterPropertyEntry>>? =
36
+ null
37
+
38
+
39
+ val eventDispatcher: EventDispatcher?
40
+ get() {
41
+ val reactContext = context as ReactContext
42
+
43
+ return UIManagerHelper.getEventDispatcherForReactTag(reactContext, getId())
44
+ }
45
+
46
+ val surfaceId: Int
47
+ get() {
48
+ val reactContext = context as ReactContext
49
+
50
+ return UIManagerHelper.getSurfaceId(reactContext)
51
+ }
52
+
53
+ override fun addToMap(mapView: MLRNMapView) {
54
+ // Wait for style before adding the source to the map
55
+ mapView.mapLibreMap!!.getStyle {
56
+ super@MLRNShapeSource.addToMap(mapView)
57
+ }
58
+ }
59
+
60
+ override fun makeSource(): GeoJsonSource {
61
+ val options = this.options
62
+
63
+ if (geoJson != null) {
64
+ return GeoJsonSource(mID, geoJson, options)
65
+ }
66
+
67
+ return GeoJsonSource(mID, uri!!, options)
68
+ }
69
+
70
+ fun setURI(url: URI) {
71
+ uri = url
72
+
73
+ if (mSource != null && mMapView != null && !mMapView!!.isDestroyed) {
74
+ mSource!!.setUri(uri!!)
75
+ }
76
+ }
77
+
78
+ fun setGeoJson(geoJson: String?) {
79
+ this.geoJson = geoJson
80
+
81
+ if (mSource != null && mMapView != null && !mMapView!!.isDestroyed) {
82
+ mSource!!.setGeoJson(geoJson!!)
83
+ }
84
+ }
85
+
86
+ fun setMaxZoom(value: Int?) {
87
+ this.maxZoom = value
88
+ }
89
+
90
+ fun setBuffer(value: Int?) {
91
+ this.buffer = value
92
+ }
93
+
94
+ fun setTolerance(value: Double?) {
95
+ this.tolerance = value
96
+ }
97
+
98
+ fun setLineMetrics(lineMetrics: Boolean) {
99
+ this.lineMetrics = lineMetrics
100
+ }
101
+
102
+ fun setCluster(cluster: Boolean) {
103
+ this.cluster = cluster
104
+ }
105
+
106
+ fun setClusterRadius(clusterRadius: Int?) {
107
+ this.clusterRadius = clusterRadius
108
+ }
109
+
110
+ fun setClusterMinPoints(clusterMinPoints: Int?) {
111
+ this.clusterMinPoints = clusterMinPoints
112
+ }
113
+
114
+ fun setClusterMaxZoom(clusterMaxZoom: Int?) {
115
+ this.clusterMaxZoom = clusterMaxZoom
116
+ }
117
+
118
+ fun setClusterProperties(clusterProperties: MutableList<MutableMap.MutableEntry<String, ClusterPropertyEntry>>?) {
119
+ this.clusterProperties = clusterProperties
120
+ }
121
+
122
+
123
+ override fun onPress(event: OnPressEvent) {
124
+ val event = MapPressEventWithFeatures(
125
+ surfaceId, id, "onPress", event.latLng, event.screenPoint, event.features
126
+ )
127
+ eventDispatcher?.dispatchEvent(event)
128
+ }
129
+
130
+ private val options: GeoJsonOptions
131
+ get() {
132
+ val options = GeoJsonOptions()
133
+
134
+ if (cluster != null) {
135
+ options.withCluster(cluster!!)
136
+ }
137
+
138
+ if (clusterRadius != null) {
139
+ options.withClusterRadius(clusterRadius!!)
140
+ }
141
+
142
+ if (clusterMinPoints != null) {
143
+ options.withClusterMinPoints(clusterMinPoints!!)
144
+ }
145
+
146
+ if (clusterMaxZoom != null) {
147
+ options.withClusterMaxZoom(clusterMaxZoom!!)
148
+ }
149
+
150
+ if (clusterProperties != null) {
151
+ for (entry in clusterProperties) {
152
+ val property: ClusterPropertyEntry = entry.value
153
+
154
+ options.withClusterProperty(entry.key, property.operator, property.mapping)
155
+ }
156
+ }
157
+
158
+ if (maxZoom != null) {
159
+ options.withMaxZoom(maxZoom!!)
160
+ }
161
+
162
+ if (buffer != null) {
163
+ options.withBuffer(buffer!!)
164
+ }
165
+
166
+ if (tolerance != null) {
167
+ options.withTolerance(tolerance!!.toFloat())
168
+ }
169
+
170
+ if (lineMetrics != null) {
171
+ options.withLineMetrics(lineMetrics!!)
172
+ }
173
+
174
+ return options
175
+ }
176
+
177
+ fun getData(
178
+ filter: Expression?
179
+ ): WritableMap {
180
+ if (mSource == null) {
181
+ throw IllegalStateException("Source is not yet loaded")
182
+ }
183
+
184
+ val features: List<Feature> = mSource!!.querySourceFeatures(filter)
185
+
186
+
187
+ return GeoJSONUtils.fromFeatureCollection(
188
+ FeatureCollection.fromFeatures(features)
189
+ )
190
+ }
191
+
192
+ fun getClusterExpansionZoom(clusterId: Int): Int {
193
+ if (mSource == null) {
194
+ throw IllegalStateException("Source is not yet loaded")
195
+ }
196
+
197
+ val zoom = mSource!!.getClusterExpansionZoom(createClusterFeature(clusterId))
198
+
199
+ return zoom
200
+ }
201
+
202
+ fun getClusterLeaves(clusterId: Int, limit: Int, offset: Int): WritableArray {
203
+ if (mSource == null) {
204
+ throw IllegalStateException("Source is not yet loaded")
205
+ }
206
+
207
+ val features = mSource!!.getClusterLeaves(
208
+ createClusterFeature(clusterId), limit.toLong(), offset.toLong()
209
+ )
210
+
211
+ return GeoJSONUtils.fromFeatureList(features.features()?.toList()!!)
212
+ }
213
+
214
+ fun getClusterChildren(clusterId: Int): WritableArray {
215
+ if (mSource == null) {
216
+ throw IllegalStateException("Source is not yet loaded")
217
+ }
218
+
219
+ val leaves = mSource!!.getClusterChildren(createClusterFeature(clusterId))
220
+
221
+ return GeoJSONUtils.fromFeatureList(leaves.features()!!)
222
+ }
223
+
224
+ private fun createClusterFeature(clusterId: Int): Feature {
225
+ val properties = JsonObject()
226
+ properties.addProperty("cluster_id", clusterId)
227
+
228
+ return Feature.fromGeometry(
229
+ Point.fromLngLat(0.0, 0.0), properties
230
+ )
231
+ }
232
+ }