@maplibre/maplibre-react-native 10.1.5 → 11.0.0-alpha.2

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 (258) hide show
  1. package/{maplibre-react-native.podspec → MapLibreReactNative.podspec} +15 -16
  2. package/android/build.gradle +89 -110
  3. package/android/gradle.properties +5 -5
  4. package/android/src/main/AndroidManifest.xml +1 -3
  5. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +144 -0
  6. package/android/src/main/java/org/maplibre/reactnative/components/AbstractEventEmitter.java +1 -5
  7. package/android/src/main/java/org/maplibre/reactnative/modules/MLRNModule.java +0 -34
  8. package/android/src/main/java/org/maplibre/reactnative/modules/MLRNSnapshotModule.kt +128 -0
  9. package/ios/{MLRN/MLRNModule.m → MLRNModule.m} +0 -26
  10. package/ios/MLRNSnapshotModule/MLRNSnapshotModule.h +4 -0
  11. package/ios/MLRNSnapshotModule/MLRNSnapshotModule.mm +78 -0
  12. package/ios/{MLRN/MLRNUtils.h → MLRNUtils.h} +1 -2
  13. package/lib/commonjs/MLRNModule.js +1 -5
  14. package/lib/commonjs/MLRNModule.js.map +1 -1
  15. package/lib/commonjs/MapLibreRN.js +0 -21
  16. package/lib/commonjs/MapLibreRN.js.map +1 -1
  17. package/lib/commonjs/components/MapView.js +1 -1
  18. package/lib/commonjs/components/MapView.js.map +1 -1
  19. package/lib/commonjs/components/PointAnnotation.js +1 -1
  20. package/lib/commonjs/components/PointAnnotation.js.map +1 -1
  21. package/lib/commonjs/components/ShapeSource.js +1 -1
  22. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  23. package/lib/commonjs/hooks/useNativeRef.js.map +1 -1
  24. package/lib/commonjs/index.js +4 -12
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js +9 -0
  27. package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js.map +1 -0
  28. package/lib/commonjs/modules/snapshot/SnapshotManager.js +2 -4
  29. package/lib/commonjs/modules/snapshot/SnapshotManager.js.map +1 -1
  30. package/lib/commonjs/modules/snapshot/SnapshotOptions.js +4 -4
  31. package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
  32. package/lib/commonjs/package.json +1 -0
  33. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +1 -7
  34. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  35. package/lib/module/MLRNModule.js +0 -2
  36. package/lib/module/MLRNModule.js.map +1 -1
  37. package/lib/module/MapLibreRN.js +3 -15
  38. package/lib/module/MapLibreRN.js.map +1 -1
  39. package/lib/module/components/MapView.js +1 -1
  40. package/lib/module/components/MapView.js.map +1 -1
  41. package/lib/module/components/PointAnnotation.js +1 -1
  42. package/lib/module/components/PointAnnotation.js.map +1 -1
  43. package/lib/module/components/ShapeSource.js +1 -1
  44. package/lib/module/components/ShapeSource.js.map +1 -1
  45. package/lib/module/hooks/useNativeRef.js.map +1 -1
  46. package/lib/module/index.js +0 -6
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/modules/snapshot/NativeSnapshotModule.js +5 -0
  49. package/lib/module/modules/snapshot/NativeSnapshotModule.js.map +1 -0
  50. package/lib/module/modules/snapshot/SnapshotManager.js +2 -3
  51. package/lib/module/modules/snapshot/SnapshotManager.js.map +1 -1
  52. package/lib/module/modules/snapshot/SnapshotOptions.js +4 -4
  53. package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
  54. package/lib/module/package.json +1 -0
  55. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +1 -7
  56. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  57. package/lib/typescript/commonjs/src/MLRNModule.d.ts +1 -1
  58. package/lib/typescript/commonjs/src/MLRNModule.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/src/MapLibreRN.d.ts +3 -15
  60. package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/src/components/Camera.d.ts +1 -1
  62. package/lib/typescript/commonjs/src/components/Camera.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/src/components/MapView.d.ts +1 -1
  64. package/lib/typescript/commonjs/src/components/MapView.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +2 -2
  66. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/src/components/UserLocation.d.ts +1 -1
  68. package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/src/components/VectorSource.d.ts +1 -1
  70. package/lib/typescript/commonjs/src/components/VectorSource.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/src/hooks/useNativeRef.d.ts +1 -1
  72. package/lib/typescript/commonjs/src/hooks/useNativeRef.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/src/index.d.ts +0 -5
  74. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts +18 -0
  76. package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/src/modules/snapshot/SnapshotManager.d.ts.map +1 -1
  78. package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts +5 -25
  79. package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +1 -1
  81. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +0 -4
  82. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  83. package/lib/typescript/module/src/MLRNModule.d.ts +1 -1
  84. package/lib/typescript/module/src/MLRNModule.d.ts.map +1 -1
  85. package/lib/typescript/module/src/MapLibreRN.d.ts +3 -15
  86. package/lib/typescript/module/src/MapLibreRN.d.ts.map +1 -1
  87. package/lib/typescript/module/src/components/Camera.d.ts +1 -1
  88. package/lib/typescript/module/src/components/Camera.d.ts.map +1 -1
  89. package/lib/typescript/module/src/components/MapView.d.ts +1 -1
  90. package/lib/typescript/module/src/components/MapView.d.ts.map +1 -1
  91. package/lib/typescript/module/src/components/ShapeSource.d.ts +2 -2
  92. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  93. package/lib/typescript/module/src/components/UserLocation.d.ts +1 -1
  94. package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
  95. package/lib/typescript/module/src/components/VectorSource.d.ts +1 -1
  96. package/lib/typescript/module/src/components/VectorSource.d.ts.map +1 -1
  97. package/lib/typescript/module/src/hooks/useNativeRef.d.ts +1 -1
  98. package/lib/typescript/module/src/hooks/useNativeRef.d.ts.map +1 -1
  99. package/lib/typescript/module/src/index.d.ts +0 -5
  100. package/lib/typescript/module/src/index.d.ts.map +1 -1
  101. package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts +18 -0
  102. package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts.map +1 -0
  103. package/lib/typescript/module/src/modules/snapshot/SnapshotManager.d.ts.map +1 -1
  104. package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts +5 -25
  105. package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
  106. package/lib/typescript/module/src/utils/animated/Animated.d.ts +1 -1
  107. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +0 -4
  108. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  109. package/package.json +20 -12
  110. package/src/MLRNModule.ts +0 -14
  111. package/src/MapLibreRN.ts +2 -18
  112. package/src/components/MapView.tsx +1 -1
  113. package/src/components/PointAnnotation.tsx +1 -1
  114. package/src/components/ShapeSource.tsx +2 -2
  115. package/src/hooks/useNativeRef.ts +3 -3
  116. package/src/index.ts +0 -6
  117. package/src/modules/snapshot/NativeSnapshotModule.ts +24 -0
  118. package/src/modules/snapshot/SnapshotManager.ts +3 -6
  119. package/src/modules/snapshot/SnapshotOptions.ts +10 -27
  120. package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +1 -14
  121. package/android/src/main/AndroidManifestNew.xml +0 -5
  122. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java +0 -90
  123. package/android/src/main/java/org/maplibre/reactnative/modules/MLRNSnapshotModule.java +0 -135
  124. package/ios/MLRN/MLRNSnapshotModule.h +0 -5
  125. package/ios/MLRN/MLRNSnapshotModule.m +0 -70
  126. package/ios/MLRN.xcodeproj/project.pbxproj +0 -1
  127. /package/ios/{MLRN/CameraMode.h → CameraMode.h} +0 -0
  128. /package/ios/{MLRN/CameraMode.m → CameraMode.m} +0 -0
  129. /package/ios/{MLRN/CameraStop.h → CameraStop.h} +0 -0
  130. /package/ios/{MLRN/CameraStop.m → CameraStop.m} +0 -0
  131. /package/ios/{MLRN/CameraUpdateItem.h → CameraUpdateItem.h} +0 -0
  132. /package/ios/{MLRN/CameraUpdateItem.m → CameraUpdateItem.m} +0 -0
  133. /package/ios/{MLRN/CameraUpdateQueue.h → CameraUpdateQueue.h} +0 -0
  134. /package/ios/{MLRN/CameraUpdateQueue.m → CameraUpdateQueue.m} +0 -0
  135. /package/ios/{MLRN/FilterParser.h → FilterParser.h} +0 -0
  136. /package/ios/{MLRN/FilterParser.m → FilterParser.m} +0 -0
  137. /package/ios/{MLRN/MLRN.h → MLRN.h} +0 -0
  138. /package/ios/{MLRN/MLRN.m → MLRN.m} +0 -0
  139. /package/ios/{MLRN/MLRNBackgroundLayer.h → MLRNBackgroundLayer.h} +0 -0
  140. /package/ios/{MLRN/MLRNBackgroundLayer.m → MLRNBackgroundLayer.m} +0 -0
  141. /package/ios/{MLRN/MLRNBackgroundLayerManager.h → MLRNBackgroundLayerManager.h} +0 -0
  142. /package/ios/{MLRN/MLRNBackgroundLayerManager.m → MLRNBackgroundLayerManager.m} +0 -0
  143. /package/ios/{MLRN/MLRNCallout.h → MLRNCallout.h} +0 -0
  144. /package/ios/{MLRN/MLRNCallout.m → MLRNCallout.m} +0 -0
  145. /package/ios/{MLRN/MLRNCalloutManager.h → MLRNCalloutManager.h} +0 -0
  146. /package/ios/{MLRN/MLRNCalloutManager.m → MLRNCalloutManager.m} +0 -0
  147. /package/ios/{MLRN/MLRNCamera.h → MLRNCamera.h} +0 -0
  148. /package/ios/{MLRN/MLRNCamera.m → MLRNCamera.m} +0 -0
  149. /package/ios/{MLRN/MLRNCameraManager.h → MLRNCameraManager.h} +0 -0
  150. /package/ios/{MLRN/MLRNCameraManager.m → MLRNCameraManager.m} +0 -0
  151. /package/ios/{MLRN/MLRNCircleLayer.h → MLRNCircleLayer.h} +0 -0
  152. /package/ios/{MLRN/MLRNCircleLayer.m → MLRNCircleLayer.m} +0 -0
  153. /package/ios/{MLRN/MLRNCircleLayerManager.h → MLRNCircleLayerManager.h} +0 -0
  154. /package/ios/{MLRN/MLRNCircleLayerManager.m → MLRNCircleLayerManager.m} +0 -0
  155. /package/ios/{MLRN/MLRNCustomHeaders.h → MLRNCustomHeaders.h} +0 -0
  156. /package/ios/{MLRN/MLRNCustomHeaders.m → MLRNCustomHeaders.m} +0 -0
  157. /package/ios/{MLRN/MLRNEvent.h → MLRNEvent.h} +0 -0
  158. /package/ios/{MLRN/MLRNEvent.m → MLRNEvent.m} +0 -0
  159. /package/ios/{MLRN/MLRNEventProtocol.h → MLRNEventProtocol.h} +0 -0
  160. /package/ios/{MLRN/MLRNEventTypes.h → MLRNEventTypes.h} +0 -0
  161. /package/ios/{MLRN/MLRNEventTypes.m → MLRNEventTypes.m} +0 -0
  162. /package/ios/{MLRN/MLRNFillExtrusionLayer.h → MLRNFillExtrusionLayer.h} +0 -0
  163. /package/ios/{MLRN/MLRNFillExtrusionLayer.m → MLRNFillExtrusionLayer.m} +0 -0
  164. /package/ios/{MLRN/MLRNFillExtrusionLayerManager.h → MLRNFillExtrusionLayerManager.h} +0 -0
  165. /package/ios/{MLRN/MLRNFillExtrusionLayerManager.m → MLRNFillExtrusionLayerManager.m} +0 -0
  166. /package/ios/{MLRN/MLRNFillLayer.h → MLRNFillLayer.h} +0 -0
  167. /package/ios/{MLRN/MLRNFillLayer.m → MLRNFillLayer.m} +0 -0
  168. /package/ios/{MLRN/MLRNFillLayerManager.h → MLRNFillLayerManager.h} +0 -0
  169. /package/ios/{MLRN/MLRNFillLayerManager.m → MLRNFillLayerManager.m} +0 -0
  170. /package/ios/{MLRN/MLRNHeatmapLayer.h → MLRNHeatmapLayer.h} +0 -0
  171. /package/ios/{MLRN/MLRNHeatmapLayer.m → MLRNHeatmapLayer.m} +0 -0
  172. /package/ios/{MLRN/MLRNHeatmapLayerManager.h → MLRNHeatmapLayerManager.h} +0 -0
  173. /package/ios/{MLRN/MLRNHeatmapLayerManager.m → MLRNHeatmapLayerManager.m} +0 -0
  174. /package/ios/{MLRN/MLRNImageQueue.h → MLRNImageQueue.h} +0 -0
  175. /package/ios/{MLRN/MLRNImageQueue.m → MLRNImageQueue.m} +0 -0
  176. /package/ios/{MLRN/MLRNImageQueueOperation.h → MLRNImageQueueOperation.h} +0 -0
  177. /package/ios/{MLRN/MLRNImageQueueOperation.m → MLRNImageQueueOperation.m} +0 -0
  178. /package/ios/{MLRN/MLRNImageSource.h → MLRNImageSource.h} +0 -0
  179. /package/ios/{MLRN/MLRNImageSource.m → MLRNImageSource.m} +0 -0
  180. /package/ios/{MLRN/MLRNImageSourceManager.h → MLRNImageSourceManager.h} +0 -0
  181. /package/ios/{MLRN/MLRNImageSourceManager.m → MLRNImageSourceManager.m} +0 -0
  182. /package/ios/{MLRN/MLRNImageUtils.h → MLRNImageUtils.h} +0 -0
  183. /package/ios/{MLRN/MLRNImageUtils.m → MLRNImageUtils.m} +0 -0
  184. /package/ios/{MLRN/MLRNImages.h → MLRNImages.h} +0 -0
  185. /package/ios/{MLRN/MLRNImages.m → MLRNImages.m} +0 -0
  186. /package/ios/{MLRN/MLRNImagesManager.h → MLRNImagesManager.h} +0 -0
  187. /package/ios/{MLRN/MLRNImagesManager.m → MLRNImagesManager.m} +0 -0
  188. /package/ios/{MLRN/MLRNLayer.h → MLRNLayer.h} +0 -0
  189. /package/ios/{MLRN/MLRNLayer.m → MLRNLayer.m} +0 -0
  190. /package/ios/{MLRN/MLRNLight.h → MLRNLight.h} +0 -0
  191. /package/ios/{MLRN/MLRNLight.m → MLRNLight.m} +0 -0
  192. /package/ios/{MLRN/MLRNLightManager.h → MLRNLightManager.h} +0 -0
  193. /package/ios/{MLRN/MLRNLightManager.m → MLRNLightManager.m} +0 -0
  194. /package/ios/{MLRN/MLRNLineLayer.h → MLRNLineLayer.h} +0 -0
  195. /package/ios/{MLRN/MLRNLineLayer.m → MLRNLineLayer.m} +0 -0
  196. /package/ios/{MLRN/MLRNLineLayerManager.h → MLRNLineLayerManager.h} +0 -0
  197. /package/ios/{MLRN/MLRNLineLayerManager.m → MLRNLineLayerManager.m} +0 -0
  198. /package/ios/{MLRN/MLRNLocation.h → MLRNLocation.h} +0 -0
  199. /package/ios/{MLRN/MLRNLocation.m → MLRNLocation.m} +0 -0
  200. /package/ios/{MLRN/MLRNLocationManager.h → MLRNLocationManager.h} +0 -0
  201. /package/ios/{MLRN/MLRNLocationManager.m → MLRNLocationManager.m} +0 -0
  202. /package/ios/{MLRN/MLRNLocationManagerDelegate.h → MLRNLocationManagerDelegate.h} +0 -0
  203. /package/ios/{MLRN/MLRNLocationModule.h → MLRNLocationModule.h} +0 -0
  204. /package/ios/{MLRN/MLRNLocationModule.m → MLRNLocationModule.m} +0 -0
  205. /package/ios/{MLRN/MLRNLogging.h → MLRNLogging.h} +0 -0
  206. /package/ios/{MLRN/MLRNLogging.m → MLRNLogging.m} +0 -0
  207. /package/ios/{MLRN/MLRNMapTouchEvent.h → MLRNMapTouchEvent.h} +0 -0
  208. /package/ios/{MLRN/MLRNMapTouchEvent.m → MLRNMapTouchEvent.m} +0 -0
  209. /package/ios/{MLRN/MLRNMapView.h → MLRNMapView.h} +0 -0
  210. /package/ios/{MLRN/MLRNMapView.m → MLRNMapView.m} +0 -0
  211. /package/ios/{MLRN/MLRNMapViewManager.h → MLRNMapViewManager.h} +0 -0
  212. /package/ios/{MLRN/MLRNMapViewManager.m → MLRNMapViewManager.m} +0 -0
  213. /package/ios/{MLRN/MLRNModule.h → MLRNModule.h} +0 -0
  214. /package/ios/{MLRN/MLRNNativeUserLocation.h → MLRNNativeUserLocation.h} +0 -0
  215. /package/ios/{MLRN/MLRNNativeUserLocation.m → MLRNNativeUserLocation.m} +0 -0
  216. /package/ios/{MLRN/MLRNNativeUserLocationManager.h → MLRNNativeUserLocationManager.h} +0 -0
  217. /package/ios/{MLRN/MLRNNativeUserLocationManager.m → MLRNNativeUserLocationManager.m} +0 -0
  218. /package/ios/{MLRN/MLRNOfflineModule.h → MLRNOfflineModule.h} +0 -0
  219. /package/ios/{MLRN/MLRNOfflineModule.m → MLRNOfflineModule.m} +0 -0
  220. /package/ios/{MLRN/MLRNPointAnnotation.h → MLRNPointAnnotation.h} +0 -0
  221. /package/ios/{MLRN/MLRNPointAnnotation.m → MLRNPointAnnotation.m} +0 -0
  222. /package/ios/{MLRN/MLRNPointAnnotationManager.h → MLRNPointAnnotationManager.h} +0 -0
  223. /package/ios/{MLRN/MLRNPointAnnotationManager.m → MLRNPointAnnotationManager.m} +0 -0
  224. /package/ios/{MLRN/MLRNRasterLayer.h → MLRNRasterLayer.h} +0 -0
  225. /package/ios/{MLRN/MLRNRasterLayer.m → MLRNRasterLayer.m} +0 -0
  226. /package/ios/{MLRN/MLRNRasterLayerManager.h → MLRNRasterLayerManager.h} +0 -0
  227. /package/ios/{MLRN/MLRNRasterLayerManager.m → MLRNRasterLayerManager.m} +0 -0
  228. /package/ios/{MLRN/MLRNRasterSource.h → MLRNRasterSource.h} +0 -0
  229. /package/ios/{MLRN/MLRNRasterSource.m → MLRNRasterSource.m} +0 -0
  230. /package/ios/{MLRN/MLRNRasterSourceManager.h → MLRNRasterSourceManager.h} +0 -0
  231. /package/ios/{MLRN/MLRNRasterSourceManager.m → MLRNRasterSourceManager.m} +0 -0
  232. /package/ios/{MLRN/MLRNShapeSource.h → MLRNShapeSource.h} +0 -0
  233. /package/ios/{MLRN/MLRNShapeSource.m → MLRNShapeSource.m} +0 -0
  234. /package/ios/{MLRN/MLRNShapeSourceManager.h → MLRNShapeSourceManager.h} +0 -0
  235. /package/ios/{MLRN/MLRNShapeSourceManager.m → MLRNShapeSourceManager.m} +0 -0
  236. /package/ios/{MLRN/MLRNSource.h → MLRNSource.h} +0 -0
  237. /package/ios/{MLRN/MLRNSource.m → MLRNSource.m} +0 -0
  238. /package/ios/{MLRN/MLRNStyle.h → MLRNStyle.h} +0 -0
  239. /package/ios/{MLRN/MLRNStyle.m → MLRNStyle.m} +0 -0
  240. /package/ios/{MLRN/MLRNStyleValue.h → MLRNStyleValue.h} +0 -0
  241. /package/ios/{MLRN/MLRNStyleValue.m → MLRNStyleValue.m} +0 -0
  242. /package/ios/{MLRN/MLRNSymbolLayer.h → MLRNSymbolLayer.h} +0 -0
  243. /package/ios/{MLRN/MLRNSymbolLayer.m → MLRNSymbolLayer.m} +0 -0
  244. /package/ios/{MLRN/MLRNSymbolLayerManager.h → MLRNSymbolLayerManager.h} +0 -0
  245. /package/ios/{MLRN/MLRNSymbolLayerManager.m → MLRNSymbolLayerManager.m} +0 -0
  246. /package/ios/{MLRN/MLRNTileSource.h → MLRNTileSource.h} +0 -0
  247. /package/ios/{MLRN/MLRNTileSource.m → MLRNTileSource.m} +0 -0
  248. /package/ios/{MLRN/MLRNUserLocation.h → MLRNUserLocation.h} +0 -0
  249. /package/ios/{MLRN/MLRNUserLocation.m → MLRNUserLocation.m} +0 -0
  250. /package/ios/{MLRN/MLRNUtils.m → MLRNUtils.m} +0 -0
  251. /package/ios/{MLRN/MLRNVectorLayer.h → MLRNVectorLayer.h} +0 -0
  252. /package/ios/{MLRN/MLRNVectorLayer.m → MLRNVectorLayer.m} +0 -0
  253. /package/ios/{MLRN/MLRNVectorSource.h → MLRNVectorSource.h} +0 -0
  254. /package/ios/{MLRN/MLRNVectorSource.m → MLRNVectorSource.m} +0 -0
  255. /package/ios/{MLRN/MLRNVectorSourceManager.h → MLRNVectorSourceManager.h} +0 -0
  256. /package/ios/{MLRN/MLRNVectorSourceManager.m → MLRNVectorSourceManager.m} +0 -0
  257. /package/ios/{MLRN/ViewManager.h → ViewManager.h} +0 -0
  258. /package/ios/{MLRN/ViewManager.m → ViewManager.m} +0 -0
@@ -1,6 +1,6 @@
1
- require 'json'
1
+ require "json"
2
2
 
3
- package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
5
  # Global Variable Defaults
6
6
  $MLRN_NATIVE_VERSION ||= "6.11.0"
@@ -40,7 +40,7 @@ def $MLRN.post_install(installer)
40
40
  project = installer.pods_project
41
41
  self._add_spm_to_target(
42
42
  project,
43
- project.targets.find { |t| t.name == "maplibre-react-native"},
43
+ project.targets.find { |t| t.name == "MapLibreReactNative"},
44
44
  spm_spec[:url],
45
45
  spm_spec[:requirement],
46
46
  spm_spec[:product_name]
@@ -62,19 +62,18 @@ def $MLRN.post_install(installer)
62
62
  end
63
63
 
64
64
  Pod::Spec.new do |s|
65
- s.name = "maplibre-react-native"
66
- s.summary = "React Native library for creating maps with MapLibre Native"
67
- s.version = package['version']
68
- s.authors = { "MapLibre" => "" }
69
- s.homepage = "https://github.com/maplibre/maplibre-react-native"
70
- s.source = { :git => "https://github.com/maplibre/maplibre-react-native.git" }
71
- s.license = "MIT"
72
- s.platform = :ios, "8.0"
65
+ s.name = "MapLibreReactNative"
66
+ s.version = package["version"]
67
+ s.summary = package["description"]
68
+ s.homepage = package["homepage"]
69
+ s.license = package["license"]
70
+ s.authors = package["author"]
73
71
 
74
- s.dependency 'React-Core'
75
- s.dependency 'React'
72
+ s.platforms = { :ios => min_ios_version_supported }
73
+ s.source = { :git => "https://github.com/maplibre/maplibre-react-native.git", :tag => "#{s.version}" }
76
74
 
77
- s.subspec 'DynamicLibrary' do |sp|
78
- sp.source_files = "ios/MLRN/**/*.{h,m}"
79
- end
75
+ s.source_files = "ios/**/*.{h,m,mm,cpp}"
76
+ s.private_header_files = "ios/**/*.h"
77
+
78
+ install_modules_dependencies(s)
80
79
  end
@@ -1,145 +1,124 @@
1
1
  buildscript {
2
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
- def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["org.maplibre.reactnative.kotlinVersion"]
4
-
5
- repositories {
6
- google()
7
- mavenCentral()
8
- }
2
+ ext.getExtOrDefault = { name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['org.maplibre.reactnative.' + name]
4
+ }
9
5
 
10
- dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
12
- // noinspection DifferentKotlinGradleVersion
13
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
- }
15
- }
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
16
10
 
17
- def reactNativeArchitectures() {
18
- def value = rootProject.getProperties().get("reactNativeArchitectures")
19
- return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
20
16
  }
21
17
 
22
- def isNewArchitectureEnabled() {
23
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24
- }
25
18
 
26
19
  apply plugin: "com.android.library"
27
20
  apply plugin: "kotlin-android"
28
21
 
29
- // TODO: Currently breaks new arch support, but works without
30
- // if (isNewArchitectureEnabled()) {
31
- // apply plugin: "com.facebook.react"
32
- // }
33
-
34
- def getExtOrDefault(name) {
35
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["org.maplibre.reactnative." + name]
36
- }
37
-
38
- def getConfigurableExtOrDefault(name) {
39
- return rootProject.ext.has("org.maplibre.reactnative." + name) ? rootProject.ext.get("org.maplibre.reactnative." + name) : project.properties["org.maplibre.reactnative." + name]
40
- }
22
+ apply plugin: "com.facebook.react"
41
23
 
42
24
  def getExtOrIntegerDefault(name) {
43
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["org.maplibre.reactnative." + name]).toInteger()
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["org.maplibre.reactnative." + name]).toInteger()
44
26
  }
45
27
 
46
- def supportsNamespace() {
47
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
48
- def major = parsed[0].toInteger()
49
- def minor = parsed[1].toInteger()
50
-
51
- // Namespace support was added in 7.3.0
52
- return (major == 7 && minor >= 3) || major >= 8
28
+ def getConfigurableExtOrDefault(name) {
29
+ return rootProject.ext.has("org.maplibre.reactnative." + name) ? rootProject.ext.get("org.maplibre.reactnative." + name) : project.properties["org.maplibre.reactnative." + name]
53
30
  }
54
31
 
55
32
  android {
56
- if (supportsNamespace()) {
57
33
  namespace "org.maplibre.reactnative"
58
34
 
59
- sourceSets {
60
- main {
61
- manifest.srcFile "src/main/AndroidManifestNew.xml"
62
- }
63
- }
64
- }
65
-
66
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
35
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
67
36
 
68
- defaultConfig {
69
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
70
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
71
-
72
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
73
- }
37
+ defaultConfig {
38
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
39
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
40
+ }
74
41
 
75
- sourceSets {
76
- main {
77
- java.srcDirs = ['src/main/java']
42
+ buildFeatures {
43
+ buildConfig true
44
+ }
78
45
 
79
- if (getConfigurableExtOrDefault("locationEngine") == "default") {
80
- java.srcDirs += 'src/main/location-engine-default'
81
- } else if (getConfigurableExtOrDefault("locationEngine") == "google") {
82
- java.srcDirs += 'src/main/location-engine-google'
83
- } else {
84
- throw new GradleException("org.maplibre.reactnative.locationEngine.locationEngine should be one of [\"default\", \"google\"]`. \"${getConfigurableExtOrDefault("locationEngine")}\" was provided.")
85
- }
46
+ buildTypes {
47
+ release {
48
+ minifyEnabled false
49
+ }
86
50
  }
87
- }
88
51
 
89
- buildTypes {
90
- release {
91
- minifyEnabled false
52
+ lintOptions {
53
+ disable "GradleCompatible"
92
54
  }
93
- }
94
55
 
95
- lintOptions {
96
- disable "GradleCompatible"
97
- }
56
+ compileOptions {
57
+ sourceCompatibility JavaVersion.VERSION_1_8
58
+ targetCompatibility JavaVersion.VERSION_1_8
59
+ }
98
60
 
99
- compileOptions {
100
- sourceCompatibility JavaVersion.VERSION_1_8
101
- targetCompatibility JavaVersion.VERSION_1_8
102
- }
61
+ sourceSets {
62
+ main {
63
+ java.srcDirs = ['src/main/java']
64
+
65
+ if (getConfigurableExtOrDefault("locationEngine") == "default") {
66
+ java.srcDirs += 'src/main/location-engine-default'
67
+ } else if (getConfigurableExtOrDefault("locationEngine") == "google") {
68
+ java.srcDirs += 'src/main/location-engine-google'
69
+ } else {
70
+ throw new GradleException("org.maplibre.reactnative.locationEngine.locationEngine should be one of [\"default\", \"google\"]`. \"${getConfigurableExtOrDefault("locationEngine")}\" was provided.")
71
+ }
72
+
73
+ java.srcDirs += [
74
+ "generated/java",
75
+ "generated/jni"
76
+ ]
77
+ }
78
+ }
103
79
  }
104
80
 
105
81
  repositories {
106
- mavenCentral()
107
- google()
82
+ mavenCentral()
83
+ google()
108
84
  }
109
85
 
110
86
  def kotlin_version = getExtOrDefault("kotlinVersion")
111
87
 
112
88
  dependencies {
113
- // For < 0.71, this will be from the local maven repo
114
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
115
- //noinspection GradleDynamicVersion
116
- implementation "com.facebook.react:react-native:+"
117
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
118
-
119
- // MapLibre Native
120
- implementation "org.maplibre.gl:android-sdk-${getConfigurableExtOrDefault('nativeVariant')}:${getConfigurableExtOrDefault('nativeVersion')}"
121
-
122
- // MapLibre Plugins
123
- implementation("org.maplibre.gl:android-plugin-localization-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
124
- exclude(group: "org.maplibre.gl", module: "android-sdk")
125
- }
126
- implementation("org.maplibre.gl:android-plugin-annotation-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
127
- exclude(group: "org.maplibre.gl", module: "android-sdk")
128
- }
129
- implementation("org.maplibre.gl:android-plugin-markerview-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
130
- exclude(group: "org.maplibre.gl", module: "android-sdk")
131
- }
132
-
133
- // Dependencies
134
- implementation "org.maplibre.gl:android-sdk-turf:${getConfigurableExtOrDefault('turfVersion')}"
135
- implementation "com.squareup.okhttp3:okhttp:${getConfigurableExtOrDefault('okhttpVersion')}"
136
- implementation "com.squareup.okhttp3:okhttp-urlconnection:${getConfigurableExtOrDefault('okhttpVersion')}"
137
- implementation "androidx.vectordrawable:vectordrawable:1.1.0"
138
- implementation "androidx.annotation:annotation:1.7.0"
139
- implementation "androidx.appcompat:appcompat:1.6.1"
140
-
141
- // Dependencies for Google Location Engine
142
- if (getConfigurableExtOrDefault("locationEngine") == "google") {
143
- implementation "com.google.android.gms:play-services-location:${getConfigurableExtOrDefault('googlePlayServicesLocationVersion')}"
144
- }
89
+ implementation "com.facebook.react:react-android"
90
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
91
+
92
+ // MapLibre Native
93
+ implementation "org.maplibre.gl:android-sdk-${getConfigurableExtOrDefault('nativeVariant')}:${getConfigurableExtOrDefault('nativeVersion')}"
94
+
95
+ // MapLibre Plugins
96
+ implementation("org.maplibre.gl:android-plugin-localization-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
97
+ exclude(group: "org.maplibre.gl", module: "android-sdk")
98
+ }
99
+ implementation("org.maplibre.gl:android-plugin-annotation-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
100
+ exclude(group: "org.maplibre.gl", module: "android-sdk")
101
+ }
102
+ implementation("org.maplibre.gl:android-plugin-markerview-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
103
+ exclude(group: "org.maplibre.gl", module: "android-sdk")
104
+ }
105
+
106
+ // Dependencies
107
+ implementation "org.maplibre.gl:android-sdk-turf:${getConfigurableExtOrDefault('turfVersion')}"
108
+ implementation "com.squareup.okhttp3:okhttp:${getConfigurableExtOrDefault('okhttpVersion')}"
109
+ implementation "com.squareup.okhttp3:okhttp-urlconnection:${getConfigurableExtOrDefault('okhttpVersion')}"
110
+ implementation "androidx.vectordrawable:vectordrawable:1.1.0"
111
+ implementation "androidx.annotation:annotation:1.7.0"
112
+ implementation "androidx.appcompat:appcompat:1.6.1"
113
+
114
+ // Dependencies for Google Location Engine
115
+ if (getConfigurableExtOrDefault("locationEngine") == "google") {
116
+ implementation "com.google.android.gms:play-services-location:${getConfigurableExtOrDefault('googlePlayServicesLocationVersion')}"
117
+ }
118
+ }
119
+
120
+ react {
121
+ jsRootDir = file("../src/")
122
+ libraryName = "MapLibreReactNative"
123
+ codegenJavaPackageName = "org.maplibre.reactnative"
145
124
  }
@@ -1,8 +1,8 @@
1
- org.maplibre.reactnative.kotlinVersion=1.7.0
2
- org.maplibre.reactnative.minSdkVersion=21
3
- org.maplibre.reactnative.targetSdkVersion=31
4
- org.maplibre.reactnative.compileSdkVersion=31
5
- org.maplibre.reactnative.ndkVersion=21.4.7075529
1
+ org.maplibre.reactnative.kotlinVersion=2.0.21
2
+ org.maplibre.reactnative.minSdkVersion=24
3
+ org.maplibre.reactnative.targetSdkVersion=34
4
+ org.maplibre.reactnative.compileSdkVersion=35
5
+ org.maplibre.reactnative.ndkVersion=27.1.12297006
6
6
 
7
7
  # MapLibre React Native
8
8
  org.maplibre.reactnative.nativeVersion=11.8.1
@@ -1,6 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="org.maplibre.reactnative">
3
-
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
4
2
  <uses-permission android:name="android.permission.INTERNET" />
5
3
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
6
4
  </manifest>
@@ -0,0 +1,144 @@
1
+ package org.maplibre.reactnative
2
+
3
+ import com.facebook.react.BaseReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import com.facebook.react.uimanager.ViewManager
9
+ import org.maplibre.reactnative.components.annotation.MLRNCalloutManager
10
+ import org.maplibre.reactnative.components.annotation.MLRNMarkerViewManager
11
+ import org.maplibre.reactnative.components.annotation.MLRNPointAnnotationManager
12
+ import org.maplibre.reactnative.components.camera.MLRNCameraManager
13
+ import org.maplibre.reactnative.components.images.MLRNImagesManager
14
+ import org.maplibre.reactnative.components.location.MLRNNativeUserLocationManager
15
+ import org.maplibre.reactnative.components.mapview.MLRNAndroidTextureMapViewManager
16
+ import org.maplibre.reactnative.components.mapview.MLRNMapViewManager
17
+ import org.maplibre.reactnative.components.styles.layers.MLRNBackgroundLayerManager
18
+ import org.maplibre.reactnative.components.styles.layers.MLRNCircleLayerManager
19
+ import org.maplibre.reactnative.components.styles.layers.MLRNFillExtrusionLayerManager
20
+ import org.maplibre.reactnative.components.styles.layers.MLRNFillLayerManager
21
+ import org.maplibre.reactnative.components.styles.layers.MLRNHeatmapLayerManager
22
+ import org.maplibre.reactnative.components.styles.layers.MLRNLineLayerManager
23
+ import org.maplibre.reactnative.components.styles.layers.MLRNRasterLayerManager
24
+ import org.maplibre.reactnative.components.styles.layers.MLRNSymbolLayerManager
25
+ import org.maplibre.reactnative.components.styles.light.MLRNLightManager
26
+ import org.maplibre.reactnative.components.styles.sources.MLRNImageSourceManager
27
+ import org.maplibre.reactnative.components.styles.sources.MLRNRasterSourceManager
28
+ import org.maplibre.reactnative.components.styles.sources.MLRNShapeSourceManager
29
+ import org.maplibre.reactnative.components.styles.sources.MLRNVectorSourceManager
30
+ import org.maplibre.reactnative.modules.MLRNLocationModule
31
+ import org.maplibre.reactnative.modules.MLRNLogging
32
+ import org.maplibre.reactnative.modules.MLRNModule
33
+ import org.maplibre.reactnative.modules.MLRNOfflineModule
34
+ import org.maplibre.reactnative.modules.MLRNSnapshotModule
35
+
36
+
37
+ class MLRNPackage : BaseReactPackage() {
38
+ override fun getModule(
39
+ name: String,
40
+ reactContext: ReactApplicationContext
41
+ ): NativeModule? {
42
+ when (name) {
43
+ MLRNModule.REACT_CLASS -> return MLRNModule(reactContext)
44
+ MLRNOfflineModule.REACT_CLASS -> return MLRNOfflineModule(reactContext)
45
+ MLRNSnapshotModule.NAME -> return MLRNSnapshotModule(reactContext)
46
+ MLRNLocationModule.REACT_CLASS -> return MLRNLocationModule(reactContext)
47
+ MLRNLogging.REACT_CLASS -> return MLRNLogging(reactContext)
48
+ }
49
+
50
+ return null
51
+ }
52
+
53
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
54
+ return ReactModuleInfoProvider {
55
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
56
+
57
+ moduleInfos[MLRNModule.REACT_CLASS] = ReactModuleInfo(
58
+ MLRNModule.REACT_CLASS,
59
+ MLRNModule.REACT_CLASS,
60
+ false, // canOverrideExistingModule
61
+ false, // needsEagerInit
62
+ true, // hasConstants
63
+ false, // isCxxModule
64
+ false // isTurboModule
65
+ )
66
+
67
+ moduleInfos[MLRNOfflineModule.REACT_CLASS] = ReactModuleInfo(
68
+ MLRNOfflineModule.REACT_CLASS,
69
+ MLRNOfflineModule.REACT_CLASS,
70
+ false, // canOverrideExistingModule
71
+ false, // needsEagerInit
72
+ true, // hasConstants
73
+ false, // isCxxModule
74
+ false // isTurboModule
75
+ )
76
+
77
+ moduleInfos[MLRNSnapshotModule.NAME] = ReactModuleInfo(
78
+ MLRNSnapshotModule.NAME,
79
+ MLRNSnapshotModule.NAME,
80
+ false, // canOverrideExistingModule
81
+ false, // needsEagerInit
82
+ false, // isCxxModule
83
+ true // isTurboModule
84
+ )
85
+
86
+ moduleInfos[MLRNLocationModule.REACT_CLASS] = ReactModuleInfo(
87
+ MLRNLocationModule.REACT_CLASS,
88
+ MLRNLocationModule.REACT_CLASS,
89
+ false, // canOverrideExistingModule
90
+ false, // needsEagerInit
91
+ true, // hasConstants
92
+ false, // isCxxModule
93
+ false // isTurboModule
94
+ )
95
+
96
+ moduleInfos[MLRNLogging.REACT_CLASS] = ReactModuleInfo(
97
+ MLRNLogging.REACT_CLASS,
98
+ MLRNLogging.REACT_CLASS,
99
+ false, // canOverrideExistingModule
100
+ false, // needsEagerInit
101
+ true, // hasConstants
102
+ false, // isCxxModule
103
+ false // isTurboModule
104
+ )
105
+
106
+ moduleInfos
107
+ }
108
+ }
109
+
110
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
111
+ val managers: MutableList<ViewManager<*, *>> = ArrayList()
112
+
113
+ // components
114
+ managers.add(MLRNCameraManager(reactContext))
115
+ managers.add(MLRNMapViewManager(reactContext))
116
+ managers.add(MLRNMarkerViewManager(reactContext))
117
+ managers.add(MLRNAndroidTextureMapViewManager(reactContext))
118
+ managers.add(MLRNLightManager())
119
+ managers.add(MLRNPointAnnotationManager(reactContext))
120
+ managers.add(MLRNCalloutManager())
121
+ managers.add(MLRNNativeUserLocationManager())
122
+
123
+ // sources
124
+ managers.add(MLRNVectorSourceManager(reactContext))
125
+ managers.add(MLRNShapeSourceManager(reactContext))
126
+ managers.add(MLRNRasterSourceManager(reactContext))
127
+ managers.add(MLRNImageSourceManager())
128
+
129
+ // images
130
+ managers.add(MLRNImagesManager(reactContext))
131
+
132
+ // layers
133
+ managers.add(MLRNFillLayerManager())
134
+ managers.add(MLRNFillExtrusionLayerManager())
135
+ managers.add(MLRNHeatmapLayerManager())
136
+ managers.add(MLRNLineLayerManager())
137
+ managers.add(MLRNCircleLayerManager())
138
+ managers.add(MLRNSymbolLayerManager())
139
+ managers.add(MLRNRasterLayerManager())
140
+ managers.add(MLRNBackgroundLayerManager())
141
+
142
+ return managers
143
+ }
144
+ }
@@ -45,11 +45,7 @@ abstract public class AbstractEventEmitter<T extends ViewGroup> extends ViewGrou
45
45
 
46
46
  @Override
47
47
  protected void addEventEmitters(ThemedReactContext context, @Nonnull T view) {
48
- if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
49
- mEventDispatcher = UIManagerHelper.getUIManager(context, UIManagerType.FABRIC).getEventDispatcher();
50
- } else {
51
- mEventDispatcher = context.getNativeModule(UIManagerModule.class).getEventDispatcher();
52
- }
48
+ mEventDispatcher = UIManagerHelper.getUIManager(context, UIManagerType.FABRIC).getEventDispatcher();
53
49
  }
54
50
 
55
51
  @Nullable
@@ -132,25 +132,6 @@ public class MLRNModule extends ReactContextBaseJavaModule {
132
132
  .build();
133
133
  }
134
134
 
135
- /**
136
- * @deprecated This will be removed in the next major version.
137
- * @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
138
- */
139
- @Deprecated
140
- @ReactMethod
141
- public void setAccessToken(final String accessToken) {
142
- mReactContext.runOnUiQueueThread(new Runnable() {
143
- @Override
144
- public void run() {
145
- if (accessToken == null) {
146
- MapLibre.getInstance(getReactApplicationContext());
147
- } else {
148
- MapLibre.getInstance(getReactApplicationContext(), accessToken, WellKnownTileServer.Mapbox);
149
- }
150
- }
151
- });
152
- }
153
-
154
135
  @ReactMethod
155
136
  public void removeCustomHeader(final String headerName) {
156
137
  mReactContext.runOnUiQueueThread(new Runnable() {
@@ -179,21 +160,6 @@ public class MLRNModule extends ReactContextBaseJavaModule {
179
160
  });
180
161
  }
181
162
 
182
- /**
183
- * @deprecated This will be removed in the next major version.
184
- * @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
185
- */
186
- @Deprecated
187
- @ReactMethod
188
- public void getAccessToken(Promise promise) {
189
- String token = MapLibre.getApiKey();
190
- if(token == null) {
191
- promise.reject("missing_access_token", "No access token has been set");
192
- } else {
193
- promise.resolve(token);
194
- }
195
- }
196
-
197
163
  @ReactMethod
198
164
  public void setConnected(final boolean connected) {
199
165
  mReactContext.runOnUiQueueThread(new Runnable() {
@@ -0,0 +1,128 @@
1
+ package org.maplibre.reactnative.modules
2
+
3
+ import android.graphics.Bitmap
4
+ import android.util.Log
5
+ import android.util.TypedValue
6
+ import com.facebook.react.bridge.Promise
7
+ import com.facebook.react.bridge.ReactApplicationContext
8
+ import com.facebook.react.bridge.ReadableMap
9
+ import com.facebook.react.module.annotations.ReactModule
10
+ import org.maplibre.android.camera.CameraPosition
11
+ import org.maplibre.android.maps.Style
12
+ import org.maplibre.android.snapshotter.MapSnapshot
13
+ import org.maplibre.android.snapshotter.MapSnapshotter
14
+ import org.maplibre.geojson.Feature
15
+ import org.maplibre.geojson.FeatureCollection
16
+ import org.maplibre.geojson.Point
17
+ import org.maplibre.reactnative.NativeSnapshotModuleSpec
18
+ import org.maplibre.reactnative.utils.BitmapUtils
19
+ import org.maplibre.reactnative.utils.GeoJSONUtils
20
+ import java.io.IOException
21
+ import java.io.OutputStream
22
+ import java.util.UUID
23
+
24
+ @ReactModule(name = MLRNSnapshotModule.NAME)
25
+ class MLRNSnapshotModule(reactContext: ReactApplicationContext) :
26
+ NativeSnapshotModuleSpec(reactContext) {
27
+ companion object {
28
+ const val NAME = "MLRNSnapshotModule"
29
+ }
30
+
31
+ override fun getName() = NAME
32
+
33
+ private val context: ReactApplicationContext = reactContext
34
+
35
+ // Prevent garbage collection
36
+ private val snapshotterMap: MutableMap<String, MapSnapshotter> =
37
+ HashMap<String, MapSnapshotter>()
38
+
39
+ override fun takeSnap(jsOptions: ReadableMap, promise: Promise) {
40
+ org.maplibre.android.storage.FileSource.getInstance(context).activate()
41
+
42
+ context.runOnUiQueueThread {
43
+ val snapshotterID = UUID.randomUUID().toString()
44
+ val snapshotter: MapSnapshotter = MapSnapshotter(context, getOptions(jsOptions))
45
+ snapshotterMap[snapshotterID] = snapshotter
46
+ snapshotter.start(object :
47
+ MapSnapshotter.SnapshotReadyCallback {
48
+ override fun onSnapshotReady(snapshot: MapSnapshot) {
49
+ val bitmap: Bitmap = snapshot.bitmap
50
+ val result: String? = if (jsOptions.getBoolean("writeToDisk")) {
51
+ BitmapUtils.createTempFile(
52
+ context, bitmap
53
+ )
54
+ } else {
55
+ BitmapUtils.createBase64(bitmap)
56
+ }
57
+
58
+ if (result == null) {
59
+ promise.reject(
60
+ NAME,
61
+ "Could not generate snapshot, please check Android logs for more info."
62
+ )
63
+ return
64
+ }
65
+
66
+ promise.resolve(result)
67
+ snapshotterMap.remove(snapshotterID)
68
+ }
69
+ }) { error ->
70
+ Log.w(NAME, error)
71
+ snapshotterMap.remove(snapshotterID)
72
+ }
73
+ }
74
+ }
75
+
76
+ private fun getOptions(jsOptions: ReadableMap): MapSnapshotter.Options {
77
+ val options: MapSnapshotter.Options =
78
+ MapSnapshotter.Options(
79
+ jsOptions.getDouble("width").toInt(), jsOptions.getDouble("height").toInt()
80
+ )
81
+
82
+ options.withLogo(jsOptions.getBoolean("withLogo"))
83
+ jsOptions.getString("styleURL")?.let { styleUrl ->
84
+ options.withStyleBuilder(
85
+ Style.Builder().fromUri(styleUrl)
86
+ )
87
+ }
88
+ options.withPixelRatio(
89
+ TypedValue.applyDimension(
90
+ TypedValue.COMPLEX_UNIT_DIP,
91
+ 1f,
92
+ context.resources.displayMetrics
93
+ )
94
+ )
95
+
96
+ if (jsOptions.hasKey("bounds")) {
97
+ val bounds = jsOptions.getString("bounds")?.let { boundsStr ->
98
+ FeatureCollection.fromJson(boundsStr)
99
+ }
100
+ bounds?.let {
101
+ options.withRegion(GeoJSONUtils.toLatLngBounds(it))
102
+ }
103
+ } else {
104
+ val centerPoint = jsOptions.getString("centerCoordinate")?.let { coordStr ->
105
+ Feature.fromJson(coordStr)
106
+ }
107
+ val cameraPosition: CameraPosition =
108
+ CameraPosition.Builder()
109
+ .target(GeoJSONUtils.toLatLng(centerPoint?.geometry() as Point?))
110
+ .tilt(jsOptions.getDouble("pitch")).bearing(jsOptions.getDouble("heading"))
111
+ .zoom(jsOptions.getDouble("zoomLevel")).build()
112
+ options.withCameraPosition(cameraPosition)
113
+ }
114
+
115
+ return options
116
+ }
117
+
118
+ private fun closeSnapshotOutputStream(outputStream: OutputStream?) {
119
+ if (outputStream == null) {
120
+ return
121
+ }
122
+ try {
123
+ outputStream.close()
124
+ } catch (e: IOException) {
125
+ e.localizedMessage?.let { Log.w(NAME, it) }
126
+ }
127
+ }
128
+ }