@maplibre/maplibre-react-native 11.0.0-alpha.8 → 11.0.0-alpha.9

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 (337) hide show
  1. package/android/build.gradle +0 -3
  2. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +43 -0
  3. package/android/src/main/java/org/maplibre/reactnative/components/AbstractEvent.kt +24 -0
  4. package/android/src/main/java/org/maplibre/reactnative/components/AbstractEventEmitter.kt +71 -0
  5. package/android/src/main/java/org/maplibre/reactnative/components/annotation/MLRNPointAnnotation.java +1 -1
  6. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.kt +203 -0
  7. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateItem.kt +109 -0
  8. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateQueue.kt +60 -0
  9. package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCamera.kt +409 -0
  10. package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCameraManager.kt +69 -0
  11. package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCameraModule.kt +34 -0
  12. package/android/src/main/java/org/maplibre/reactnative/components/camera/constants/CameraEasing.kt +24 -0
  13. package/android/src/main/java/org/maplibre/reactnative/components/images/MLRNImages.java +1 -2
  14. package/android/src/main/java/org/maplibre/reactnative/components/location/LocationComponentManager.java +1 -1
  15. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapView.kt +23 -0
  16. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapViewManager.kt +23 -0
  17. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +1338 -0
  18. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewManager.kt +187 -0
  19. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +159 -0
  20. package/android/src/main/java/org/maplibre/reactnative/components/mapview/helpers/CameraChangeTracker.kt +26 -0
  21. package/android/src/main/java/org/maplibre/reactnative/components/mapview/helpers/LayerSourceInfo.kt +74 -0
  22. package/android/src/main/java/org/maplibre/reactnative/components/styles/layers/MLRNLayer.java +1 -5
  23. package/android/src/main/java/org/maplibre/reactnative/components/styles/light/MLRNLight.java +1 -6
  24. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +2 -9
  25. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNSource.java +1 -1
  26. package/android/src/main/java/org/maplibre/reactnative/events/AbstractEvent.java +2 -5
  27. package/android/src/main/java/org/maplibre/reactnative/events/MapChangeEvent.kt +18 -0
  28. package/android/src/main/java/org/maplibre/reactnative/events/MapClickEvent.java +4 -0
  29. package/android/src/main/java/org/maplibre/reactnative/events/MapPressEvent.kt +27 -0
  30. package/android/src/main/java/org/maplibre/reactnative/events/TrackUserLocationChangeEvent.kt +24 -0
  31. package/android/src/main/java/org/maplibre/reactnative/events/constants/EventKeys.java +0 -1
  32. package/android/src/main/java/org/maplibre/reactnative/events/constants/EventTypes.java +0 -19
  33. package/android/src/main/java/org/maplibre/reactnative/location/LocationManager.java +1 -1
  34. package/android/src/main/java/org/maplibre/reactnative/location/TrackUserLocationMode.kt +43 -0
  35. package/android/src/main/java/org/maplibre/reactnative/location/{UserTrackingState.java → TrackUserLocationState.java} +1 -1
  36. package/android/src/main/java/org/maplibre/reactnative/location/UserLocation.java +1 -1
  37. package/android/src/main/java/org/maplibre/reactnative/modules/MLRNModule.java +1 -49
  38. package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +2 -9
  39. package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +322 -0
  40. package/android/src/main/java/org/maplibre/reactnative/utils/ReactTagResolver.kt +85 -0
  41. package/ios/MLRNCallout.h +1 -1
  42. package/ios/MLRNEvent.m +3 -1
  43. package/ios/MLRNEventTypes.h +10 -31
  44. package/ios/MLRNEventTypes.m +10 -30
  45. package/ios/MLRNImages.h +1 -1
  46. package/ios/MLRNImages.m +1 -1
  47. package/ios/MLRNLayer.h +1 -1
  48. package/ios/MLRNLayer.m +2 -2
  49. package/ios/MLRNLight.h +2 -1
  50. package/ios/MLRNLocationModule.m +2 -2
  51. package/ios/MLRNMapTouchEvent.h +2 -1
  52. package/ios/MLRNMapTouchEvent.m +12 -10
  53. package/ios/MLRNModule.m +5 -52
  54. package/ios/MLRNNativeUserLocation.m +0 -1
  55. package/ios/MLRNOfflineModule.h +2 -2
  56. package/ios/MLRNOfflineModule.m +9 -9
  57. package/ios/MLRNPointAnnotation.h +1 -1
  58. package/ios/MLRNShapeSource.h +1 -1
  59. package/ios/MLRNSource.h +3 -1
  60. package/ios/MLRNStyle.m +20 -20
  61. package/ios/MLRNUtils.h +17 -2
  62. package/ios/MLRNUtils.m +25 -2
  63. package/ios/components/camera/CameraEasing.h +8 -0
  64. package/ios/{CameraStop.h → components/camera/CameraStop.h} +10 -6
  65. package/ios/components/camera/CameraStop.m +75 -0
  66. package/ios/{CameraUpdateItem.m → components/camera/CameraUpdateItem.m} +45 -46
  67. package/ios/components/camera/MLRNCamera.h +26 -0
  68. package/ios/components/camera/MLRNCamera.m +195 -0
  69. package/ios/components/camera/MLRNCameraComponentView.h +18 -0
  70. package/ios/components/camera/MLRNCameraComponentView.mm +192 -0
  71. package/ios/components/camera/MLRNCameraManager.h +11 -0
  72. package/ios/components/camera/MLRNCameraManager.m +20 -0
  73. package/ios/components/camera/MLRNCameraModule.h +4 -0
  74. package/ios/components/camera/MLRNCameraModule.mm +111 -0
  75. package/ios/{MLRNMapView.h → components/map-view/MLRNMapView.h} +42 -20
  76. package/ios/components/map-view/MLRNMapView.m +809 -0
  77. package/ios/components/map-view/MLRNMapViewComponentView.h +18 -0
  78. package/ios/components/map-view/MLRNMapViewComponentView.mm +400 -0
  79. package/ios/components/map-view/MLRNMapViewManager.h +70 -0
  80. package/ios/components/map-view/MLRNMapViewManager.m +163 -0
  81. package/ios/components/map-view/MLRNMapViewModule.h +4 -0
  82. package/ios/components/map-view/MLRNMapViewModule.mm +249 -0
  83. package/ios/{MLRNSnapshotModule → modules/snapshot}/MLRNSnapshotModule.mm +0 -1
  84. package/lib/commonjs/MLRNModule.js +1 -3
  85. package/lib/commonjs/MLRNModule.js.map +1 -1
  86. package/lib/commonjs/components/Annotation.js +1 -13
  87. package/lib/commonjs/components/Annotation.js.map +1 -1
  88. package/lib/commonjs/components/Images.js.map +1 -1
  89. package/lib/commonjs/components/ShapeSource.js +2 -21
  90. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  91. package/lib/commonjs/components/VectorSource.js +3 -26
  92. package/lib/commonjs/components/VectorSource.js.map +1 -1
  93. package/lib/commonjs/components/camera/Camera.js +97 -0
  94. package/lib/commonjs/components/camera/Camera.js.map +1 -0
  95. package/lib/commonjs/components/camera/CameraNativeComponent.ts +61 -0
  96. package/lib/commonjs/components/camera/NativeCameraModule.js +11 -0
  97. package/lib/commonjs/components/camera/NativeCameraModule.js.map +1 -0
  98. package/lib/commonjs/components/map-view/MapView.js +115 -0
  99. package/lib/commonjs/components/map-view/MapView.js.map +1 -0
  100. package/lib/commonjs/components/map-view/MapViewNativeComponent.ts +96 -0
  101. package/lib/commonjs/components/map-view/NativeMapViewModule.js +9 -0
  102. package/lib/commonjs/components/map-view/NativeMapViewModule.js.map +1 -0
  103. package/lib/commonjs/index.js +246 -4
  104. package/lib/commonjs/index.js.map +1 -1
  105. package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js +2 -2
  106. package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js.map +1 -1
  107. package/lib/commonjs/modules/snapshot/SnapshotManager.js +3 -2
  108. package/lib/commonjs/modules/snapshot/SnapshotManager.js.map +1 -1
  109. package/lib/commonjs/types/Bounds.js +2 -0
  110. package/lib/commonjs/types/{OnPressEvent.js.map → Bounds.js.map} +1 -1
  111. package/lib/commonjs/types/PressEvent.js +2 -0
  112. package/lib/{module/types/OnPressEvent.js.map → commonjs/types/PressEvent.js.map} +1 -1
  113. package/lib/commonjs/types/ViewPadding.js +2 -0
  114. package/lib/commonjs/types/{MapLibreRNEvent.js.map → ViewPadding.js.map} +1 -1
  115. package/lib/commonjs/types/codegen/UnsafeMixed.js +2 -0
  116. package/lib/commonjs/types/codegen/UnsafeMixed.js.map +1 -0
  117. package/lib/commonjs/utils/index.js +0 -11
  118. package/lib/commonjs/utils/index.js.map +1 -1
  119. package/lib/module/MLRNModule.js +0 -1
  120. package/lib/module/MLRNModule.js.map +1 -1
  121. package/lib/module/components/Annotation.js +2 -14
  122. package/lib/module/components/Annotation.js.map +1 -1
  123. package/lib/module/components/Images.js.map +1 -1
  124. package/lib/module/components/ShapeSource.js +3 -22
  125. package/lib/module/components/ShapeSource.js.map +1 -1
  126. package/lib/module/components/VectorSource.js +4 -27
  127. package/lib/module/components/VectorSource.js.map +1 -1
  128. package/lib/module/components/camera/Camera.js +92 -0
  129. package/lib/module/components/camera/Camera.js.map +1 -0
  130. package/lib/module/components/camera/CameraNativeComponent.ts +61 -0
  131. package/lib/module/components/camera/NativeCameraModule.js +10 -0
  132. package/lib/module/components/camera/NativeCameraModule.js.map +1 -0
  133. package/lib/module/components/map-view/MapView.js +110 -0
  134. package/lib/module/components/map-view/MapView.js.map +1 -0
  135. package/lib/module/components/map-view/MapViewNativeComponent.ts +96 -0
  136. package/lib/module/components/map-view/NativeMapViewModule.js +5 -0
  137. package/lib/module/components/map-view/NativeMapViewModule.js.map +1 -0
  138. package/lib/module/index.js +30 -1
  139. package/lib/module/index.js.map +1 -1
  140. package/lib/module/modules/snapshot/NativeSnapshotModule.js +1 -1
  141. package/lib/module/modules/snapshot/NativeSnapshotModule.js.map +1 -1
  142. package/lib/module/modules/snapshot/SnapshotManager.js +1 -1
  143. package/lib/module/modules/snapshot/SnapshotManager.js.map +1 -1
  144. package/lib/module/types/Bounds.js +2 -0
  145. package/lib/module/types/{MapLibreRNEvent.js.map → Bounds.js.map} +1 -1
  146. package/lib/module/types/PressEvent.js +2 -0
  147. package/lib/module/types/PressEvent.js.map +1 -0
  148. package/lib/module/types/ViewPadding.js +2 -0
  149. package/lib/module/types/ViewPadding.js.map +1 -0
  150. package/lib/module/types/codegen/UnsafeMixed.js +2 -0
  151. package/lib/module/types/codegen/UnsafeMixed.js.map +1 -0
  152. package/lib/module/utils/index.js +0 -9
  153. package/lib/module/utils/index.js.map +1 -1
  154. package/lib/typescript/commonjs/src/MLRNModule.d.ts +1 -7
  155. package/lib/typescript/commonjs/src/MLRNModule.d.ts.map +1 -1
  156. package/lib/typescript/commonjs/src/components/Annotation.d.ts +3 -3
  157. package/lib/typescript/commonjs/src/components/Annotation.d.ts.map +1 -1
  158. package/lib/typescript/commonjs/src/components/Images.d.ts +1 -2
  159. package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
  160. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +2 -5
  161. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/src/components/VectorSource.d.ts +3 -2
  163. package/lib/typescript/commonjs/src/components/VectorSource.d.ts.map +1 -1
  164. package/lib/typescript/commonjs/src/components/camera/Camera.d.ts +180 -0
  165. package/lib/typescript/commonjs/src/components/camera/Camera.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts +37 -0
  167. package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts +27 -0
  169. package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts +323 -0
  171. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts +69 -0
  173. package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts +45 -0
  175. package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/src/index.d.ts +41 -1
  177. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  178. package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts +2 -1
  179. package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/src/types/Bounds.d.ts +2 -0
  181. package/lib/typescript/commonjs/src/types/Bounds.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/src/types/PressEvent.d.ts +16 -0
  183. package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/src/types/ViewPadding.d.ts +7 -0
  185. package/lib/typescript/commonjs/src/types/ViewPadding.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/src/types/codegen/UnsafeMixed.d.ts +10 -0
  187. package/lib/typescript/commonjs/src/types/codegen/UnsafeMixed.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/src/utils/index.d.ts +1 -3
  189. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  190. package/lib/typescript/module/src/MLRNModule.d.ts +1 -7
  191. package/lib/typescript/module/src/MLRNModule.d.ts.map +1 -1
  192. package/lib/typescript/module/src/components/Annotation.d.ts +3 -3
  193. package/lib/typescript/module/src/components/Annotation.d.ts.map +1 -1
  194. package/lib/typescript/module/src/components/Images.d.ts +1 -2
  195. package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
  196. package/lib/typescript/module/src/components/ShapeSource.d.ts +2 -5
  197. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  198. package/lib/typescript/module/src/components/VectorSource.d.ts +3 -2
  199. package/lib/typescript/module/src/components/VectorSource.d.ts.map +1 -1
  200. package/lib/typescript/module/src/components/camera/Camera.d.ts +180 -0
  201. package/lib/typescript/module/src/components/camera/Camera.d.ts.map +1 -0
  202. package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts +37 -0
  203. package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts.map +1 -0
  204. package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts +27 -0
  205. package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts.map +1 -0
  206. package/lib/typescript/module/src/components/map-view/MapView.d.ts +323 -0
  207. package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -0
  208. package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts +69 -0
  209. package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -0
  210. package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts +45 -0
  211. package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts.map +1 -0
  212. package/lib/typescript/module/src/index.d.ts +41 -1
  213. package/lib/typescript/module/src/index.d.ts.map +1 -1
  214. package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts +2 -1
  215. package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts.map +1 -1
  216. package/lib/typescript/module/src/types/Bounds.d.ts +2 -0
  217. package/lib/typescript/module/src/types/Bounds.d.ts.map +1 -0
  218. package/lib/typescript/module/src/types/PressEvent.d.ts +16 -0
  219. package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -0
  220. package/lib/typescript/module/src/types/ViewPadding.d.ts +7 -0
  221. package/lib/typescript/module/src/types/ViewPadding.d.ts.map +1 -0
  222. package/lib/typescript/module/src/types/codegen/UnsafeMixed.d.ts +10 -0
  223. package/lib/typescript/module/src/types/codegen/UnsafeMixed.d.ts.map +1 -0
  224. package/lib/typescript/module/src/utils/index.d.ts +1 -3
  225. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  226. package/package.json +38 -28
  227. package/src/MLRNModule.ts +0 -10
  228. package/src/components/Annotation.tsx +8 -23
  229. package/src/components/Images.tsx +2 -4
  230. package/src/components/ShapeSource.tsx +18 -31
  231. package/src/components/VectorSource.tsx +5 -28
  232. package/src/components/camera/Camera.tsx +311 -0
  233. package/src/components/camera/CameraNativeComponent.ts +61 -0
  234. package/src/components/camera/NativeCameraModule.ts +39 -0
  235. package/src/components/map-view/MapView.tsx +582 -0
  236. package/src/components/map-view/MapViewNativeComponent.ts +96 -0
  237. package/src/components/map-view/NativeMapViewModule.ts +83 -0
  238. package/src/index.ts +86 -1
  239. package/src/modules/snapshot/NativeSnapshotModule.ts +1 -2
  240. package/src/modules/snapshot/SnapshotManager.ts +1 -1
  241. package/src/types/Bounds.ts +1 -0
  242. package/src/types/PressEvent.ts +19 -0
  243. package/src/types/ViewPadding.ts +6 -0
  244. package/src/types/codegen/UnsafeMixed.ts +9 -0
  245. package/src/utils/index.ts +1 -14
  246. package/android/src/main/java/org/maplibre/reactnative/components/AbstractEvent.java +0 -35
  247. package/android/src/main/java/org/maplibre/reactnative/components/AbstractEventEmitter.java +0 -80
  248. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.java +0 -245
  249. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateItem.java +0 -121
  250. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateQueue.java +0 -68
  251. package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCamera.java +0 -519
  252. package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCameraManager.java +0 -101
  253. package/android/src/main/java/org/maplibre/reactnative/components/camera/constants/CameraMode.java +0 -18
  254. package/android/src/main/java/org/maplibre/reactnative/components/mapview/LayerSourceInfo.java +0 -59
  255. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapView.java +0 -13
  256. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapViewManager.java +0 -27
  257. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.java +0 -1521
  258. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewManager.java +0 -342
  259. package/android/src/main/java/org/maplibre/reactnative/components/mapview/helpers/CameraChangeTracker.java +0 -37
  260. package/android/src/main/java/org/maplibre/reactnative/events/MapChangeEvent.java +0 -43
  261. package/android/src/main/java/org/maplibre/reactnative/events/MapUserTrackingModeEvent.java +0 -32
  262. package/android/src/main/java/org/maplibre/reactnative/location/UserLocationVerticalAlignment.java +0 -7
  263. package/android/src/main/java/org/maplibre/reactnative/location/UserTrackingMode.java +0 -59
  264. package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java +0 -310
  265. package/ios/CameraMode.h +0 -10
  266. package/ios/CameraMode.m +0 -10
  267. package/ios/CameraStop.m +0 -73
  268. package/ios/MLRNCamera.h +0 -29
  269. package/ios/MLRNCamera.m +0 -236
  270. package/ios/MLRNCameraManager.h +0 -5
  271. package/ios/MLRNCameraManager.m +0 -39
  272. package/ios/MLRNMapView.m +0 -497
  273. package/ios/MLRNMapViewManager.h +0 -9
  274. package/ios/MLRNMapViewManager.m +0 -604
  275. package/lib/commonjs/MapLibreRN.js +0 -266
  276. package/lib/commonjs/MapLibreRN.js.map +0 -1
  277. package/lib/commonjs/components/Camera.js +0 -333
  278. package/lib/commonjs/components/Camera.js.map +0 -1
  279. package/lib/commonjs/components/MapView.js +0 -449
  280. package/lib/commonjs/components/MapView.js.map +0 -1
  281. package/lib/commonjs/hooks/useNativeRef.js +0 -14
  282. package/lib/commonjs/hooks/useNativeRef.js.map +0 -1
  283. package/lib/commonjs/types/CameraMode.js +0 -14
  284. package/lib/commonjs/types/CameraMode.js.map +0 -1
  285. package/lib/commonjs/types/MapLibreRNEvent.js +0 -6
  286. package/lib/commonjs/types/OnPressEvent.js +0 -2
  287. package/lib/module/MapLibreRN.js +0 -33
  288. package/lib/module/MapLibreRN.js.map +0 -1
  289. package/lib/module/components/Camera.js +0 -328
  290. package/lib/module/components/Camera.js.map +0 -1
  291. package/lib/module/components/MapView.js +0 -444
  292. package/lib/module/components/MapView.js.map +0 -1
  293. package/lib/module/hooks/useNativeRef.js +0 -10
  294. package/lib/module/hooks/useNativeRef.js.map +0 -1
  295. package/lib/module/types/CameraMode.js +0 -10
  296. package/lib/module/types/CameraMode.js.map +0 -1
  297. package/lib/module/types/MapLibreRNEvent.js +0 -4
  298. package/lib/module/types/OnPressEvent.js +0 -2
  299. package/lib/typescript/commonjs/src/MapLibreRN.d.ts +0 -41
  300. package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +0 -1
  301. package/lib/typescript/commonjs/src/components/Camera.d.ts +0 -134
  302. package/lib/typescript/commonjs/src/components/Camera.d.ts.map +0 -1
  303. package/lib/typescript/commonjs/src/components/MapView.d.ts +0 -223
  304. package/lib/typescript/commonjs/src/components/MapView.d.ts.map +0 -1
  305. package/lib/typescript/commonjs/src/hooks/useNativeRef.d.ts +0 -8
  306. package/lib/typescript/commonjs/src/hooks/useNativeRef.d.ts.map +0 -1
  307. package/lib/typescript/commonjs/src/types/CameraMode.d.ts +0 -7
  308. package/lib/typescript/commonjs/src/types/CameraMode.d.ts.map +0 -1
  309. package/lib/typescript/commonjs/src/types/MapLibreRNEvent.d.ts +0 -6
  310. package/lib/typescript/commonjs/src/types/MapLibreRNEvent.d.ts.map +0 -1
  311. package/lib/typescript/commonjs/src/types/OnPressEvent.d.ts +0 -12
  312. package/lib/typescript/commonjs/src/types/OnPressEvent.d.ts.map +0 -1
  313. package/lib/typescript/module/src/MapLibreRN.d.ts +0 -41
  314. package/lib/typescript/module/src/MapLibreRN.d.ts.map +0 -1
  315. package/lib/typescript/module/src/components/Camera.d.ts +0 -134
  316. package/lib/typescript/module/src/components/Camera.d.ts.map +0 -1
  317. package/lib/typescript/module/src/components/MapView.d.ts +0 -223
  318. package/lib/typescript/module/src/components/MapView.d.ts.map +0 -1
  319. package/lib/typescript/module/src/hooks/useNativeRef.d.ts +0 -8
  320. package/lib/typescript/module/src/hooks/useNativeRef.d.ts.map +0 -1
  321. package/lib/typescript/module/src/types/CameraMode.d.ts +0 -7
  322. package/lib/typescript/module/src/types/CameraMode.d.ts.map +0 -1
  323. package/lib/typescript/module/src/types/MapLibreRNEvent.d.ts +0 -6
  324. package/lib/typescript/module/src/types/MapLibreRNEvent.d.ts.map +0 -1
  325. package/lib/typescript/module/src/types/OnPressEvent.d.ts +0 -12
  326. package/lib/typescript/module/src/types/OnPressEvent.d.ts.map +0 -1
  327. package/src/MapLibreRN.ts +0 -75
  328. package/src/components/Camera.tsx +0 -568
  329. package/src/components/MapView.tsx +0 -838
  330. package/src/hooks/useNativeRef.ts +0 -14
  331. package/src/types/CameraMode.ts +0 -6
  332. package/src/types/MapLibreRNEvent.ts +0 -7
  333. package/src/types/OnPressEvent.ts +0 -11
  334. /package/ios/{CameraUpdateItem.h → components/camera/CameraUpdateItem.h} +0 -0
  335. /package/ios/{CameraUpdateQueue.h → components/camera/CameraUpdateQueue.h} +0 -0
  336. /package/ios/{CameraUpdateQueue.m → components/camera/CameraUpdateQueue.m} +0 -0
  337. /package/ios/{MLRNSnapshotModule → modules/snapshot}/MLRNSnapshotModule.h +0 -0
@@ -1,121 +0,0 @@
1
- package org.maplibre.reactnative.components.camera;
2
-
3
- import androidx.annotation.NonNull;
4
-
5
- import org.maplibre.android.camera.CameraUpdate;
6
- import org.maplibre.android.constants.MapLibreConstants;
7
- import org.maplibre.android.maps.MapLibreMap;
8
- import org.maplibre.reactnative.components.camera.constants.CameraMode;
9
-
10
- import java.lang.ref.WeakReference;
11
- import java.util.concurrent.Callable;
12
- import java.util.concurrent.ExecutionException;
13
- import java.util.concurrent.ExecutorService;
14
- import java.util.concurrent.Future;
15
- import java.util.concurrent.FutureTask;
16
- import java.util.concurrent.RunnableFuture;
17
- import java.util.concurrent.TimeUnit;
18
- import java.util.concurrent.TimeoutException;
19
-
20
- public class CameraUpdateItem implements RunnableFuture<Void> {
21
- private int mDuration;
22
- private MapLibreMap.CancelableCallback mCallback;
23
- private CameraUpdate mCameraUpdate;
24
- private int mCameraMode;
25
-
26
- private boolean isCameraActionFinished;
27
- private boolean isCameraActionCancelled;
28
-
29
- private WeakReference<MapLibreMap> mMap;
30
-
31
- public CameraUpdateItem(MapLibreMap map, CameraUpdate update, int duration, MapLibreMap.CancelableCallback callback, @CameraMode.Mode int cameraMode) {
32
- mCameraUpdate = update;
33
- mDuration = duration;
34
- mCallback = callback;
35
- mCameraMode = cameraMode;
36
- mMap = new WeakReference<>(map);
37
- }
38
-
39
- public int getDuration() {
40
- return mDuration;
41
- }
42
-
43
- @Override
44
- public void run() {
45
- final MapLibreMap.CancelableCallback callback = new MapLibreMap.CancelableCallback() {
46
- @Override
47
- public void onCancel() {
48
- handleCallbackResponse(true);
49
- }
50
-
51
- @Override
52
- public void onFinish() {
53
- handleCallbackResponse(false);
54
- }
55
- };
56
-
57
- MapLibreMap map = mMap.get();
58
- if (map == null) {
59
- isCameraActionCancelled = true;
60
- return;
61
- }
62
-
63
- // animateCamera / easeCamera only allows positive duration
64
- if (mDuration == 0 || mCameraMode == CameraMode.NONE) {
65
- map.moveCamera(mCameraUpdate, callback);
66
- return;
67
- }
68
-
69
- // On iOS a duration of -1 means default or dynamic duration (based on flight-path length)
70
- // On Android we can fallback to MapLibre's default duration as there is no such API
71
- int duration = mDuration < 0 ? MapLibreConstants.ANIMATION_DURATION : mDuration;
72
-
73
- if (mCameraMode == CameraMode.FLIGHT) {
74
- map.animateCamera(mCameraUpdate, duration, callback);
75
- } else if (mCameraMode == CameraMode.LINEAR) {
76
- map.easeCamera(mCameraUpdate, duration, false, callback);
77
- } else if (mCameraMode == CameraMode.EASE) {
78
- map.easeCamera(mCameraUpdate, duration, true, callback);
79
- }
80
- }
81
-
82
- @Override
83
- public boolean cancel(boolean mayInterruptIfRunning) {
84
- return false;
85
- }
86
-
87
- @Override
88
- public boolean isCancelled() {
89
- return isCameraActionCancelled;
90
- }
91
-
92
- @Override
93
- public boolean isDone() {
94
- return isCameraActionFinished;
95
- }
96
-
97
- @Override
98
- public Void get() throws InterruptedException, ExecutionException {
99
- return null;
100
- }
101
-
102
- @Override
103
- public Void get(long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
104
- return null;
105
- }
106
-
107
- private void handleCallbackResponse(boolean isCancel) {
108
- if (mCallback == null) {
109
- return;
110
- }
111
-
112
- isCameraActionCancelled = isCancel;
113
- isCameraActionFinished = !isCancel;
114
-
115
- if (isCancel) {
116
- mCallback.onCancel();
117
- } else {
118
- mCallback.onFinish();
119
- }
120
- }
121
- }
@@ -1,68 +0,0 @@
1
- package org.maplibre.reactnative.components.camera;
2
-
3
- import org.maplibre.android.maps.MapLibreMap;
4
- import org.maplibre.reactnative.components.mapview.MLRNMapView;
5
-
6
- import java.util.ArrayList;
7
- import java.util.Iterator;
8
- import java.util.LinkedList;
9
- import java.util.List;
10
- import java.util.Queue;
11
- import java.util.concurrent.ExecutorService;
12
- import java.util.concurrent.Executors;
13
- import java.util.concurrent.FutureTask;
14
-
15
- public class CameraUpdateQueue {
16
- private Queue<CameraStop> mQueue;
17
-
18
- private OnCompleteAllListener mCompleteListener;
19
-
20
- public interface OnCompleteAllListener {
21
- void onCompleteAll();
22
- }
23
-
24
- public CameraUpdateQueue() {
25
- mQueue = new LinkedList<>();
26
- }
27
-
28
- public void offer(CameraStop item) {
29
- mQueue.offer(item);
30
- }
31
-
32
- public int size() {
33
- return mQueue.size();
34
- }
35
-
36
- public boolean isEmpty() {
37
- return mQueue.isEmpty();
38
- }
39
-
40
- public void flush() {
41
- while (mQueue.size() > 0) {
42
- mQueue.remove();
43
- }
44
- mQueue = new LinkedList<>();
45
- }
46
-
47
- public void setOnCompleteAllListener(OnCompleteAllListener listener) {
48
- mCompleteListener = listener;
49
- }
50
-
51
- public void execute(MLRNMapView map) {
52
- if (mQueue.isEmpty()) {
53
- if (mCompleteListener != null) {
54
- mCompleteListener.onCompleteAll();
55
- }
56
- return;
57
- }
58
-
59
- final CameraStop stop = mQueue.poll();
60
- if (stop == null) {
61
- return;
62
- }
63
-
64
- CameraUpdateItem item = stop.toCameraUpdate(map);
65
- item.run();
66
- execute(map);
67
- }
68
- }
@@ -1,519 +0,0 @@
1
- package org.maplibre.reactnative.components.camera;
2
-
3
- import android.content.Context;
4
- import android.location.Location;
5
- import android.util.Log;
6
-
7
- import org.maplibre.android.camera.CameraPosition;
8
- import org.maplibre.android.camera.CameraUpdate;
9
- import org.maplibre.android.camera.CameraUpdateFactory;
10
- import org.maplibre.android.geometry.LatLng;
11
- import org.maplibre.android.geometry.LatLngBounds;
12
- import org.maplibre.android.geometry.VisibleRegion;
13
- import org.maplibre.android.location.OnCameraTrackingChangedListener;
14
- import org.maplibre.android.location.modes.CameraMode;
15
- import org.maplibre.android.maps.MapLibreMap;
16
- import org.maplibre.android.maps.Style;
17
-
18
- import org.maplibre.reactnative.components.AbstractMapFeature;
19
- import org.maplibre.reactnative.components.location.LocationComponentManager;
20
- import org.maplibre.reactnative.components.mapview.MLRNMapView;
21
- import org.maplibre.reactnative.events.IEvent;
22
- import org.maplibre.reactnative.events.MapUserTrackingModeEvent;
23
- import org.maplibre.reactnative.events.MapChangeEvent;
24
- import org.maplibre.reactnative.location.LocationManager;
25
- import org.maplibre.reactnative.location.UserLocation;
26
- import org.maplibre.reactnative.location.UserLocationVerticalAlignment;
27
- import org.maplibre.reactnative.location.UserTrackingMode;
28
- import org.maplibre.reactnative.location.UserTrackingState;
29
- import org.maplibre.reactnative.utils.GeoJSONUtils;
30
-
31
- import org.maplibre.reactnative.events.constants.EventTypes;
32
-
33
- import com.facebook.react.bridge.WritableMap;
34
- import com.facebook.react.bridge.WritableNativeMap;
35
-
36
- import org.maplibre.geojson.Point;
37
-
38
- import org.maplibre.android.location.permissions.PermissionsManager;
39
-
40
- import androidx.annotation.NonNull;
41
-
42
- public class MLRNCamera extends AbstractMapFeature {
43
- private MLRNCameraManager mManager;
44
- private MLRNMapView mMapView;
45
-
46
- private boolean hasSentFirstRegion = false;
47
-
48
- private CameraStop mDefaultStop;
49
- private CameraStop mCameraStop;
50
- private CameraUpdateQueue mCameraUpdateQueue;
51
-
52
- // private LocationComponent mLocationComponent;
53
- private LocationComponentManager mLocationComponentManager;
54
-
55
- private int mUserTrackingMode;
56
- private int mUserTrackingState = UserTrackingState.POSSIBLE;
57
- private int mUserLocationVerticalAlignment = UserLocationVerticalAlignment.CENTER;
58
-
59
- public static final int USER_LOCATION_CAMERA_MOVE_DURATION = 1000;
60
-
61
- private LocationManager mLocationManager;
62
- private UserLocation mUserLocation;
63
-
64
- private Point mCenterCoordinate;
65
-
66
- private boolean mAnimated;
67
- private double mHeading;
68
- private double mPitch;
69
- private double mZoomLevel = -1;
70
-
71
- private double mMinZoomLevel = -1;
72
- private double mMaxZoomLevel = -1;
73
-
74
- private LatLngBounds mMaxBounds;
75
-
76
- private boolean mFollowUserLocation;
77
- private String mFollowUserMode;
78
-
79
- private Context mContext;
80
-
81
-
82
- private LocationManager.OnUserLocationChange mLocationChangeListener = new LocationManager.OnUserLocationChange() {
83
- @Override
84
- public void onLocationChange(Location nextLocation) {
85
- if (getMapboxMap() == null || mLocationComponentManager == null || !mLocationComponentManager.hasLocationComponent() || (!mFollowUserLocation)) {
86
- return;
87
- }
88
-
89
- mUserLocation.setCurrentLocation(nextLocation);
90
- sendUserLocationUpdateEvent(nextLocation);
91
- }
92
- };
93
-
94
- private MapLibreMap.CancelableCallback mCameraCallback = new MapLibreMap.CancelableCallback() {
95
- @Override
96
- public void onCancel() {
97
- if (!hasSentFirstRegion) {
98
- mMapView.sendRegionChangeEvent(false);
99
- hasSentFirstRegion = true;
100
- }
101
- }
102
-
103
- @Override
104
- public void onFinish() {
105
- if (!hasSentFirstRegion) {
106
- mMapView.sendRegionChangeEvent(false);
107
- hasSentFirstRegion = true;
108
- }
109
- }
110
- };
111
-
112
- public MLRNCamera(Context context, MLRNCameraManager manager) {
113
- super(context);
114
- mContext = context;
115
- mManager = manager;
116
- mCameraUpdateQueue = new CameraUpdateQueue();
117
-
118
- mUserLocation = new UserLocation();
119
- mLocationManager = LocationManager.getInstance(context);
120
- }
121
-
122
- @Override
123
- public void addToMap(MLRNMapView mapView) {
124
- mMapView = mapView;
125
-
126
- setInitialCamera();
127
- updateMaxMinZoomLevel();
128
- updateMaxBounds();
129
-
130
- if (mCameraStop != null) {
131
- updateCamera();
132
- }
133
-
134
- if (mFollowUserLocation) {
135
- enableLocation();
136
- }
137
- }
138
-
139
- @Override
140
- public void removeFromMap(MLRNMapView mapView) {
141
-
142
- }
143
-
144
- public void setStop(CameraStop stop) {
145
- mCameraStop = stop;
146
- mCameraStop.setCallback(mCameraCallback);
147
-
148
- if (mMapView != null) {
149
- updateCamera();
150
- }
151
- }
152
-
153
- public void setDefaultStop(CameraStop stop) {
154
- mDefaultStop = stop;
155
- }
156
-
157
- public void setFollowPitch(double pitch) {
158
- mPitch = pitch;
159
- updateCameraPositionIfNeeded(true);
160
- }
161
-
162
- public void setMaxBounds(LatLngBounds bounds) {
163
- mMaxBounds = bounds;
164
- updateMaxBounds();
165
- }
166
-
167
- private void updateMaxBounds() {
168
- MapLibreMap map = getMapboxMap();
169
- if (map != null && mMaxBounds != null) {
170
- map.setLatLngBoundsForCameraTarget(mMaxBounds);
171
- }
172
- }
173
-
174
- private void updateMaxMinZoomLevel() {
175
- MapLibreMap map = getMapboxMap();
176
- if (map != null) {
177
- if (mMinZoomLevel >= 0.0) {
178
- map.setMinZoomPreference(mMinZoomLevel);
179
- }
180
- if (mMaxZoomLevel >= 0.0) {
181
- map.setMaxZoomPreference(mMaxZoomLevel);
182
- }
183
- }
184
- }
185
-
186
- private void setInitialCamera() {
187
- if (mDefaultStop != null) {
188
- mDefaultStop.setDuration(0);
189
- mDefaultStop.setMode(org.maplibre.reactnative.components.camera.constants.CameraMode.NONE);
190
- CameraUpdateItem item = mDefaultStop.toCameraUpdate(mMapView);
191
- item.run();
192
- }
193
- }
194
-
195
- private void updateCamera() {
196
- mCameraUpdateQueue.offer(mCameraStop);
197
- mCameraUpdateQueue.execute(mMapView);
198
- }
199
-
200
- private void updateUserTrackingMode(int userTrackingMode) {
201
- mUserLocation.setTrackingMode(userTrackingMode);
202
- IEvent event = new MapUserTrackingModeEvent(this, userTrackingMode);
203
- mManager.handleEvent(event);
204
- }
205
-
206
- private void updateUserLocation(boolean isAnimated) {
207
- if ((!mFollowUserLocation) || mUserLocation.getTrackingMode() == UserTrackingMode.NONE) {
208
- return;
209
- }
210
-
211
- if (mUserTrackingState == UserTrackingState.POSSIBLE) {
212
- updateUserLocationSignificantly(isAnimated);
213
- } else if (mUserTrackingState == UserTrackingState.CHANGED) {
214
- updateUserLocationIncrementally(isAnimated);
215
- }
216
- }
217
-
218
- private CameraPosition getUserLocationUpdateCameraPosition(double zoomLevel) {
219
- LatLng center = mUserLocation.getCoordinate();
220
-
221
- if (mUserLocationVerticalAlignment != UserLocationVerticalAlignment.CENTER) {
222
- VisibleRegion region = mMapView.getVisibleRegion(center, zoomLevel);
223
-
224
- switch (mUserLocationVerticalAlignment) {
225
- case UserLocationVerticalAlignment.TOP:
226
- center = new LatLng(region.nearRight.getLatitude(), center.getLongitude());
227
- break;
228
- case UserLocationVerticalAlignment.BOTTOM:
229
- center = new LatLng(region.farLeft.getLatitude(), center.getLongitude());
230
- break;
231
- }
232
- }
233
-
234
- return new CameraPosition.Builder().target(center).bearing(getDirectionForUserLocationUpdate()).tilt(mPitch).zoom(zoomLevel).build();
235
- }
236
-
237
- private double getDirectionForUserLocationUpdate() {
238
- // NOTE: The direction of this is used for map rotation only, not location layer rotation
239
- CameraPosition currentCamera = mMapView.getCameraPosition();
240
- double direction = currentCamera.bearing;
241
-
242
- int userTrackingMode = mUserLocation.getTrackingMode();
243
- if (userTrackingMode == UserTrackingMode.FollowWithHeading || userTrackingMode == UserTrackingMode.FollowWithCourse) {
244
- direction = mUserLocation.getBearing();
245
- } else if (mHeading != 0.0) {
246
- direction = mHeading;
247
- }
248
-
249
- return direction;
250
- }
251
-
252
- private void sendUserLocationUpdateEvent(Location location) {
253
- if (location == null) {
254
- return;
255
- }
256
- IEvent event = new MapChangeEvent(this, EventTypes.USER_LOCATION_UPDATED, makeLocationChangePayload(location));
257
- mManager.handleEvent(event);
258
- }
259
-
260
- private boolean hasSetCenterCoordinate() {
261
- CameraPosition cameraPosition = mMapView.getCameraPosition();
262
- LatLng center = cameraPosition.target;
263
- return center.getLatitude() != 0.0 && center.getLongitude() != 0.0;
264
- }
265
-
266
- static final double minimumZoomLevelForUserTracking = 10.5;
267
- static final double defaultZoomLevelForUserTracking = 14.0;
268
-
269
- private void updateUserLocationSignificantly(boolean isAnimated) {
270
- mUserTrackingState = UserTrackingState.BEGAN;
271
-
272
- double zoom = mZoomLevel;
273
- if (zoom < 0) {
274
- double cameraZoom = mMapView.getMapboxMap().getCameraPosition().zoom;
275
- if (cameraZoom < minimumZoomLevelForUserTracking) {
276
- zoom = defaultZoomLevelForUserTracking;
277
- } else {
278
- zoom = cameraZoom;
279
- }
280
- }
281
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(getUserLocationUpdateCameraPosition(zoom));
282
- MapLibreMap.CancelableCallback cameraCallback = new MapLibreMap.CancelableCallback() {
283
- @Override
284
- public void onCancel() {
285
- mUserTrackingState = UserTrackingState.CHANGED;
286
- }
287
-
288
- @Override
289
- public void onFinish() {
290
- mUserTrackingState = UserTrackingState.CHANGED;
291
- }
292
- };
293
-
294
- if (isAnimated && hasSetCenterCoordinate()) {
295
- mMapView.animateCamera(cameraUpdate, cameraCallback);
296
- } else {
297
- mMapView.moveCamera(cameraUpdate, cameraCallback);
298
- }
299
- }
300
-
301
- private void updateUserLocationIncrementally(boolean isAnimated) {
302
- mUserTrackingState = UserTrackingState.BEGAN;
303
-
304
- CameraPosition cameraPosition = mMapView.getCameraPosition();
305
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(getUserLocationUpdateCameraPosition(cameraPosition.zoom));
306
-
307
- MapLibreMap.CancelableCallback callback = new MapLibreMap.CancelableCallback() {
308
- @Override
309
- public void onCancel() {
310
- mUserTrackingState = UserTrackingState.CHANGED;
311
- }
312
-
313
- @Override
314
- public void onFinish() {
315
- mUserTrackingState = UserTrackingState.CHANGED;
316
- }
317
- };
318
-
319
- if (isAnimated) {
320
- mMapView.easeCamera(cameraUpdate, USER_LOCATION_CAMERA_MOVE_DURATION, true, callback);
321
- } else {
322
- mMapView.moveCamera(cameraUpdate, callback);
323
- }
324
- }
325
-
326
- private void enableLocation() {
327
- if (!PermissionsManager.areLocationPermissionsGranted(mContext)) {
328
- return;
329
- }
330
-
331
- if (!mLocationManager.isActive()) {
332
- mLocationManager.enable();
333
- }
334
-
335
- mMapView.getMapboxMap().getStyle(new Style.OnStyleLoaded() {
336
- @Override
337
- public void onStyleLoaded(@NonNull Style style) {
338
- enableLocationComponent(style);
339
- }
340
- });
341
- }
342
-
343
- private void enableLocationComponent(@NonNull Style style) {
344
- updateUserLocation(false);
345
- updateLocationLayer(style);
346
-
347
- Location lastKnownLocation = mLocationManager.getLastKnownLocation();
348
- mLocationManager.addLocationListener(mLocationChangeListener);
349
-
350
- if (lastKnownLocation != null) {
351
- mLocationChangeListener.onLocationChange(lastKnownLocation);
352
-
353
- postDelayed(new Runnable() {
354
- @Override
355
- public void run() {
356
- mMapView.sendRegionDidChangeEvent();
357
- }
358
- }, 200);
359
- }
360
-
361
- }
362
-
363
- private void updateLocationLayer(@NonNull Style style) {
364
- if (mLocationComponentManager == null) {
365
- mLocationComponentManager = mMapView.getLocationComponentManager();
366
- }
367
-
368
- mLocationComponentManager.update(style);
369
- mLocationComponentManager.setFollowUserLocation(mFollowUserLocation);
370
-
371
- if (mFollowUserLocation) {
372
- mLocationComponentManager.setCameraMode(UserTrackingMode.getCameraMode(mUserTrackingMode));
373
- mLocationComponentManager.addOnCameraTrackingChangedListener(new OnCameraTrackingChangedListener() {
374
- @Override
375
- public void onCameraTrackingChanged(int currentMode) {
376
- int userTrackingMode;
377
-
378
- switch (currentMode) {
379
- case CameraMode.NONE:
380
- userTrackingMode = UserTrackingMode.NONE;
381
- break;
382
- case CameraMode.TRACKING:
383
- userTrackingMode = UserTrackingMode.FOLLOW;
384
- break;
385
- case CameraMode.TRACKING_COMPASS:
386
- userTrackingMode = UserTrackingMode.FollowWithHeading;
387
- break;
388
- case CameraMode.TRACKING_GPS:
389
- userTrackingMode = UserTrackingMode.FollowWithCourse;
390
- break;
391
- default:
392
- userTrackingMode = UserTrackingMode.NONE;
393
- }
394
-
395
- updateUserTrackingMode(userTrackingMode);
396
- }
397
-
398
- @Override
399
- public void onCameraTrackingDismissed() {
400
- }
401
- });
402
- } else {
403
- mLocationComponentManager.setCameraMode(CameraMode.NONE);
404
- }
405
- }
406
-
407
- public void setMinZoomLevel(double zoomLevel) {
408
- mMinZoomLevel = zoomLevel;
409
- updateMaxMinZoomLevel();
410
- }
411
-
412
- public void setMaxZoomLevel(double zoomLevel) {
413
- mMaxZoomLevel = zoomLevel;
414
- updateMaxMinZoomLevel();
415
- }
416
-
417
- public void setZoomLevel(double zoomLevel) {
418
- mZoomLevel = zoomLevel;
419
- updateCameraPositionIfNeeded(false);
420
- }
421
-
422
- private CameraPosition buildCamera(CameraPosition previousPosition, boolean shouldUpdateTarget) {
423
- CameraPosition.Builder builder = new CameraPosition.Builder(previousPosition).bearing(mHeading).tilt(mPitch).zoom(mZoomLevel);
424
-
425
- if (shouldUpdateTarget) {
426
- builder.target(GeoJSONUtils.toLatLng(mCenterCoordinate));
427
- }
428
-
429
- return builder.build();
430
- }
431
-
432
- private void updateCameraPositionIfNeeded(boolean shouldUpdateTarget) {
433
- if (mMapView != null) {
434
- CameraPosition prevPosition = mMapView.getCameraPosition();
435
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(buildCamera(prevPosition, shouldUpdateTarget));
436
-
437
- if (mAnimated) {
438
- mMapView.easeCamera(cameraUpdate);
439
- } else {
440
- mMapView.moveCamera(cameraUpdate);
441
- }
442
- }
443
- }
444
-
445
- public void setUserTrackingMode(int userTrackingMode) {
446
- int oldTrackingMode = mUserTrackingMode;
447
- mUserTrackingMode = userTrackingMode;
448
- updateUserTrackingMode(userTrackingMode);
449
-
450
- switch (mUserTrackingMode) {
451
- case UserTrackingMode.NONE:
452
- mUserTrackingState = UserTrackingState.POSSIBLE;
453
- break;
454
- case UserTrackingMode.FOLLOW:
455
- case UserTrackingMode.FollowWithCourse:
456
- case UserTrackingMode.FollowWithHeading:
457
- if (oldTrackingMode == UserTrackingMode.NONE) {
458
- mUserTrackingState = UserTrackingState.POSSIBLE;
459
- }
460
- break;
461
-
462
- }
463
-
464
- if (getMapboxMap() != null) {
465
- updateLocationLayer(getMapboxMap().getStyle());
466
- }
467
- }
468
-
469
-
470
- public void setFollowUserLocation(boolean value) {
471
- mFollowUserLocation = value;
472
- updatedFollowUserMode();
473
- }
474
-
475
- public void setFollowUserMode(String mode) {
476
- mFollowUserMode = mode;
477
- updatedFollowUserMode();
478
- }
479
-
480
- private void updatedFollowUserMode() {
481
- if (mFollowUserLocation) {
482
- setUserTrackingMode(UserTrackingMode.fromString(mFollowUserMode));
483
- } else {
484
- setUserTrackingMode(UserTrackingMode.NONE);
485
- }
486
- }
487
-
488
- MapLibreMap getMapboxMap() {
489
- if (mMapView == null) {
490
- return null;
491
- }
492
- return mMapView.getMapboxMap();
493
- }
494
-
495
- /**
496
- * Create a payload of the location data per the web api geolocation spec
497
- * https://dev.w3.org/geo/api/spec-source.html#position
498
- *
499
- * @return
500
- */
501
- private WritableMap makeLocationChangePayload(Location location) {
502
- WritableMap positionProperties = new WritableNativeMap();
503
- WritableMap coords = new WritableNativeMap();
504
-
505
- coords.putDouble("longitude", location.getLongitude());
506
- coords.putDouble("latitude", location.getLatitude());
507
- coords.putDouble("altitude", location.getAltitude());
508
- coords.putDouble("accuracy", location.getAccuracy());
509
- // A better solution will be to pull the heading from the compass engine,
510
- // unfortunately the api is not publicly available in the mapbox sdk
511
- coords.putDouble("heading", location.getBearing());
512
- coords.putDouble("course", location.getBearing());
513
- coords.putDouble("speed", location.getSpeed());
514
-
515
- positionProperties.putMap("coords", coords);
516
- positionProperties.putDouble("timestamp", location.getTime());
517
- return positionProperties;
518
- }
519
- }