@maplibre/maplibre-react-native 11.0.0-alpha.7 → 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.
- package/MapLibreReactNative.podspec +1 -1
- package/android/build.gradle +0 -3
- package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +43 -0
- package/android/src/main/java/org/maplibre/reactnative/components/AbstractEvent.kt +24 -0
- package/android/src/main/java/org/maplibre/reactnative/components/AbstractEventEmitter.kt +71 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotation/MLRNPointAnnotation.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.kt +203 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateItem.kt +109 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateQueue.kt +60 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCamera.kt +409 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCameraManager.kt +69 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCameraModule.kt +34 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/constants/CameraEasing.kt +24 -0
- package/android/src/main/java/org/maplibre/reactnative/components/images/MLRNImages.java +1 -2
- package/android/src/main/java/org/maplibre/reactnative/components/location/LocationComponentManager.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapView.kt +23 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapViewManager.kt +23 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +1338 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewManager.kt +187 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +159 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/helpers/CameraChangeTracker.kt +26 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/helpers/LayerSourceInfo.kt +74 -0
- package/android/src/main/java/org/maplibre/reactnative/components/styles/layers/MLRNLayer.java +1 -5
- package/android/src/main/java/org/maplibre/reactnative/components/styles/light/MLRNLight.java +1 -6
- package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +2 -9
- package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNSource.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/events/AbstractEvent.java +2 -5
- package/android/src/main/java/org/maplibre/reactnative/events/MapChangeEvent.kt +18 -0
- package/android/src/main/java/org/maplibre/reactnative/events/MapClickEvent.java +4 -0
- package/android/src/main/java/org/maplibre/reactnative/events/MapPressEvent.kt +27 -0
- package/android/src/main/java/org/maplibre/reactnative/events/TrackUserLocationChangeEvent.kt +24 -0
- package/android/src/main/java/org/maplibre/reactnative/events/constants/EventKeys.java +0 -1
- package/android/src/main/java/org/maplibre/reactnative/events/constants/EventTypes.java +0 -19
- package/android/src/main/java/org/maplibre/reactnative/location/LocationManager.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/location/TrackUserLocationMode.kt +43 -0
- package/android/src/main/java/org/maplibre/reactnative/location/{UserTrackingState.java → TrackUserLocationState.java} +1 -1
- package/android/src/main/java/org/maplibre/reactnative/location/UserLocation.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNModule.java +1 -49
- package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +2 -9
- package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +322 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/ReactTagResolver.kt +85 -0
- package/ios/MLRNCallout.h +1 -1
- package/ios/MLRNEvent.m +3 -1
- package/ios/MLRNEventTypes.h +10 -31
- package/ios/MLRNEventTypes.m +10 -30
- package/ios/MLRNImages.h +1 -1
- package/ios/MLRNImages.m +1 -1
- package/ios/MLRNLayer.h +1 -1
- package/ios/MLRNLayer.m +2 -2
- package/ios/MLRNLight.h +2 -1
- package/ios/MLRNLocationModule.m +2 -2
- package/ios/MLRNMapTouchEvent.h +2 -1
- package/ios/MLRNMapTouchEvent.m +12 -10
- package/ios/MLRNModule.m +5 -52
- package/ios/MLRNNativeUserLocation.m +0 -1
- package/ios/MLRNOfflineModule.h +2 -2
- package/ios/MLRNOfflineModule.m +9 -9
- package/ios/MLRNPointAnnotation.h +1 -1
- package/ios/MLRNShapeSource.h +1 -1
- package/ios/MLRNSource.h +3 -1
- package/ios/MLRNStyle.m +20 -20
- package/ios/MLRNUtils.h +17 -2
- package/ios/MLRNUtils.m +25 -2
- package/ios/components/camera/CameraEasing.h +8 -0
- package/ios/{CameraStop.h → components/camera/CameraStop.h} +10 -6
- package/ios/components/camera/CameraStop.m +75 -0
- package/ios/{CameraUpdateItem.m → components/camera/CameraUpdateItem.m} +45 -46
- package/ios/components/camera/MLRNCamera.h +26 -0
- package/ios/components/camera/MLRNCamera.m +195 -0
- package/ios/components/camera/MLRNCameraComponentView.h +18 -0
- package/ios/components/camera/MLRNCameraComponentView.mm +192 -0
- package/ios/components/camera/MLRNCameraManager.h +11 -0
- package/ios/components/camera/MLRNCameraManager.m +20 -0
- package/ios/components/camera/MLRNCameraModule.h +4 -0
- package/ios/components/camera/MLRNCameraModule.mm +111 -0
- package/ios/{MLRNMapView.h → components/map-view/MLRNMapView.h} +42 -20
- package/ios/components/map-view/MLRNMapView.m +809 -0
- package/ios/components/map-view/MLRNMapViewComponentView.h +18 -0
- package/ios/components/map-view/MLRNMapViewComponentView.mm +400 -0
- package/ios/components/map-view/MLRNMapViewManager.h +70 -0
- package/ios/components/map-view/MLRNMapViewManager.m +163 -0
- package/ios/components/map-view/MLRNMapViewModule.h +4 -0
- package/ios/components/map-view/MLRNMapViewModule.mm +249 -0
- package/ios/{MLRNSnapshotModule → modules/snapshot}/MLRNSnapshotModule.mm +0 -1
- package/lib/commonjs/MLRNModule.js +1 -3
- package/lib/commonjs/MLRNModule.js.map +1 -1
- package/lib/commonjs/components/Annotation.js +1 -13
- package/lib/commonjs/components/Annotation.js.map +1 -1
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/commonjs/components/ShapeSource.js +2 -21
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/VectorSource.js +3 -26
- package/lib/commonjs/components/VectorSource.js.map +1 -1
- package/lib/commonjs/components/camera/Camera.js +97 -0
- package/lib/commonjs/components/camera/Camera.js.map +1 -0
- package/lib/commonjs/components/camera/CameraNativeComponent.ts +61 -0
- package/lib/commonjs/components/camera/NativeCameraModule.js +11 -0
- package/lib/commonjs/components/camera/NativeCameraModule.js.map +1 -0
- package/lib/commonjs/components/map-view/MapView.js +115 -0
- package/lib/commonjs/components/map-view/MapView.js.map +1 -0
- package/lib/commonjs/components/map-view/MapViewNativeComponent.ts +96 -0
- package/lib/commonjs/components/map-view/NativeMapViewModule.js +9 -0
- package/lib/commonjs/components/map-view/NativeMapViewModule.js.map +1 -0
- package/lib/commonjs/index.js +246 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js +2 -2
- package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js.map +1 -1
- package/lib/commonjs/modules/snapshot/SnapshotManager.js +3 -2
- package/lib/commonjs/modules/snapshot/SnapshotManager.js.map +1 -1
- package/lib/commonjs/types/Bounds.js +2 -0
- package/lib/commonjs/types/{OnPressEvent.js.map → Bounds.js.map} +1 -1
- package/lib/commonjs/types/PressEvent.js +2 -0
- package/lib/{module/types/OnPressEvent.js.map → commonjs/types/PressEvent.js.map} +1 -1
- package/lib/commonjs/types/ViewPadding.js +2 -0
- package/lib/commonjs/types/{MapLibreRNEvent.js.map → ViewPadding.js.map} +1 -1
- package/lib/commonjs/types/codegen/UnsafeMixed.js +2 -0
- package/lib/commonjs/types/codegen/UnsafeMixed.js.map +1 -0
- package/lib/commonjs/utils/index.js +0 -11
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/MLRNModule.js +0 -1
- package/lib/module/MLRNModule.js.map +1 -1
- package/lib/module/components/Annotation.js +2 -14
- package/lib/module/components/Annotation.js.map +1 -1
- package/lib/module/components/Images.js.map +1 -1
- package/lib/module/components/ShapeSource.js +3 -22
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/VectorSource.js +4 -27
- package/lib/module/components/VectorSource.js.map +1 -1
- package/lib/module/components/camera/Camera.js +92 -0
- package/lib/module/components/camera/Camera.js.map +1 -0
- package/lib/module/components/camera/CameraNativeComponent.ts +61 -0
- package/lib/module/components/camera/NativeCameraModule.js +10 -0
- package/lib/module/components/camera/NativeCameraModule.js.map +1 -0
- package/lib/module/components/map-view/MapView.js +110 -0
- package/lib/module/components/map-view/MapView.js.map +1 -0
- package/lib/module/components/map-view/MapViewNativeComponent.ts +96 -0
- package/lib/module/components/map-view/NativeMapViewModule.js +5 -0
- package/lib/module/components/map-view/NativeMapViewModule.js.map +1 -0
- package/lib/module/index.js +30 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/snapshot/NativeSnapshotModule.js +1 -1
- package/lib/module/modules/snapshot/NativeSnapshotModule.js.map +1 -1
- package/lib/module/modules/snapshot/SnapshotManager.js +1 -1
- package/lib/module/modules/snapshot/SnapshotManager.js.map +1 -1
- package/lib/module/types/Bounds.js +2 -0
- package/lib/module/types/{MapLibreRNEvent.js.map → Bounds.js.map} +1 -1
- package/lib/module/types/PressEvent.js +2 -0
- package/lib/module/types/PressEvent.js.map +1 -0
- package/lib/module/types/ViewPadding.js +2 -0
- package/lib/module/types/ViewPadding.js.map +1 -0
- package/lib/module/types/codegen/UnsafeMixed.js +2 -0
- package/lib/module/types/codegen/UnsafeMixed.js.map +1 -0
- package/lib/module/utils/index.js +0 -9
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/commonjs/src/MLRNModule.d.ts +1 -7
- package/lib/typescript/commonjs/src/MLRNModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Annotation.d.ts +3 -3
- package/lib/typescript/commonjs/src/components/Annotation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Images.d.ts +1 -2
- package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +2 -5
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/VectorSource.d.ts +3 -2
- package/lib/typescript/commonjs/src/components/VectorSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/camera/Camera.d.ts +180 -0
- package/lib/typescript/commonjs/src/components/camera/Camera.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts +37 -0
- package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts +27 -0
- package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts +323 -0
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts +69 -0
- package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts +45 -0
- package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +41 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts +2 -1
- package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/Bounds.d.ts +2 -0
- package/lib/typescript/commonjs/src/types/Bounds.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PressEvent.d.ts +16 -0
- package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/ViewPadding.d.ts +7 -0
- package/lib/typescript/commonjs/src/types/ViewPadding.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/codegen/UnsafeMixed.d.ts +10 -0
- package/lib/typescript/commonjs/src/types/codegen/UnsafeMixed.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/index.d.ts +1 -3
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/MLRNModule.d.ts +1 -7
- package/lib/typescript/module/src/MLRNModule.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Annotation.d.ts +3 -3
- package/lib/typescript/module/src/components/Annotation.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Images.d.ts +1 -2
- package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts +2 -5
- package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/VectorSource.d.ts +3 -2
- package/lib/typescript/module/src/components/VectorSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/camera/Camera.d.ts +180 -0
- package/lib/typescript/module/src/components/camera/Camera.d.ts.map +1 -0
- package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts +37 -0
- package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts +27 -0
- package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts.map +1 -0
- package/lib/typescript/module/src/components/map-view/MapView.d.ts +323 -0
- package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts +69 -0
- package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts +45 -0
- package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +41 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts +2 -1
- package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts.map +1 -1
- package/lib/typescript/module/src/types/Bounds.d.ts +2 -0
- package/lib/typescript/module/src/types/Bounds.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PressEvent.d.ts +16 -0
- package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -0
- package/lib/typescript/module/src/types/ViewPadding.d.ts +7 -0
- package/lib/typescript/module/src/types/ViewPadding.d.ts.map +1 -0
- package/lib/typescript/module/src/types/codegen/UnsafeMixed.d.ts +10 -0
- package/lib/typescript/module/src/types/codegen/UnsafeMixed.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/index.d.ts +1 -3
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/package.json +38 -28
- package/src/MLRNModule.ts +0 -10
- package/src/components/Annotation.tsx +8 -23
- package/src/components/Images.tsx +2 -4
- package/src/components/ShapeSource.tsx +18 -31
- package/src/components/VectorSource.tsx +5 -28
- package/src/components/camera/Camera.tsx +311 -0
- package/src/components/camera/CameraNativeComponent.ts +61 -0
- package/src/components/camera/NativeCameraModule.ts +39 -0
- package/src/components/map-view/MapView.tsx +582 -0
- package/src/components/map-view/MapViewNativeComponent.ts +96 -0
- package/src/components/map-view/NativeMapViewModule.ts +83 -0
- package/src/index.ts +86 -1
- package/src/modules/snapshot/NativeSnapshotModule.ts +1 -2
- package/src/modules/snapshot/SnapshotManager.ts +1 -1
- package/src/types/Bounds.ts +1 -0
- package/src/types/PressEvent.ts +19 -0
- package/src/types/ViewPadding.ts +6 -0
- package/src/types/codegen/UnsafeMixed.ts +9 -0
- package/src/utils/index.ts +1 -14
- package/android/src/main/java/org/maplibre/reactnative/components/AbstractEvent.java +0 -35
- package/android/src/main/java/org/maplibre/reactnative/components/AbstractEventEmitter.java +0 -80
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.java +0 -245
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateItem.java +0 -121
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraUpdateQueue.java +0 -68
- package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCamera.java +0 -519
- package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCameraManager.java +0 -101
- package/android/src/main/java/org/maplibre/reactnative/components/camera/constants/CameraMode.java +0 -18
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/LayerSourceInfo.java +0 -59
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapView.java +0 -13
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNAndroidTextureMapViewManager.java +0 -27
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.java +0 -1521
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewManager.java +0 -342
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/helpers/CameraChangeTracker.java +0 -37
- package/android/src/main/java/org/maplibre/reactnative/events/MapChangeEvent.java +0 -43
- package/android/src/main/java/org/maplibre/reactnative/events/MapUserTrackingModeEvent.java +0 -32
- package/android/src/main/java/org/maplibre/reactnative/location/UserLocationVerticalAlignment.java +0 -7
- package/android/src/main/java/org/maplibre/reactnative/location/UserTrackingMode.java +0 -59
- package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java +0 -310
- package/ios/CameraMode.h +0 -10
- package/ios/CameraMode.m +0 -10
- package/ios/CameraStop.m +0 -73
- package/ios/MLRNCamera.h +0 -29
- package/ios/MLRNCamera.m +0 -236
- package/ios/MLRNCameraManager.h +0 -5
- package/ios/MLRNCameraManager.m +0 -39
- package/ios/MLRNMapView.m +0 -497
- package/ios/MLRNMapViewManager.h +0 -9
- package/ios/MLRNMapViewManager.m +0 -604
- package/lib/commonjs/MapLibreRN.js +0 -266
- package/lib/commonjs/MapLibreRN.js.map +0 -1
- package/lib/commonjs/components/Camera.js +0 -333
- package/lib/commonjs/components/Camera.js.map +0 -1
- package/lib/commonjs/components/MapView.js +0 -449
- package/lib/commonjs/components/MapView.js.map +0 -1
- package/lib/commonjs/hooks/useNativeRef.js +0 -14
- package/lib/commonjs/hooks/useNativeRef.js.map +0 -1
- package/lib/commonjs/types/CameraMode.js +0 -14
- package/lib/commonjs/types/CameraMode.js.map +0 -1
- package/lib/commonjs/types/MapLibreRNEvent.js +0 -6
- package/lib/commonjs/types/OnPressEvent.js +0 -2
- package/lib/module/MapLibreRN.js +0 -33
- package/lib/module/MapLibreRN.js.map +0 -1
- package/lib/module/components/Camera.js +0 -328
- package/lib/module/components/Camera.js.map +0 -1
- package/lib/module/components/MapView.js +0 -444
- package/lib/module/components/MapView.js.map +0 -1
- package/lib/module/hooks/useNativeRef.js +0 -10
- package/lib/module/hooks/useNativeRef.js.map +0 -1
- package/lib/module/types/CameraMode.js +0 -10
- package/lib/module/types/CameraMode.js.map +0 -1
- package/lib/module/types/MapLibreRNEvent.js +0 -4
- package/lib/module/types/OnPressEvent.js +0 -2
- package/lib/typescript/commonjs/src/MapLibreRN.d.ts +0 -41
- package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/Camera.d.ts +0 -134
- package/lib/typescript/commonjs/src/components/Camera.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/MapView.d.ts +0 -223
- package/lib/typescript/commonjs/src/components/MapView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/hooks/useNativeRef.d.ts +0 -8
- package/lib/typescript/commonjs/src/hooks/useNativeRef.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/CameraMode.d.ts +0 -7
- package/lib/typescript/commonjs/src/types/CameraMode.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/MapLibreRNEvent.d.ts +0 -6
- package/lib/typescript/commonjs/src/types/MapLibreRNEvent.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/OnPressEvent.d.ts +0 -12
- package/lib/typescript/commonjs/src/types/OnPressEvent.d.ts.map +0 -1
- package/lib/typescript/module/src/MapLibreRN.d.ts +0 -41
- package/lib/typescript/module/src/MapLibreRN.d.ts.map +0 -1
- package/lib/typescript/module/src/components/Camera.d.ts +0 -134
- package/lib/typescript/module/src/components/Camera.d.ts.map +0 -1
- package/lib/typescript/module/src/components/MapView.d.ts +0 -223
- package/lib/typescript/module/src/components/MapView.d.ts.map +0 -1
- package/lib/typescript/module/src/hooks/useNativeRef.d.ts +0 -8
- package/lib/typescript/module/src/hooks/useNativeRef.d.ts.map +0 -1
- package/lib/typescript/module/src/types/CameraMode.d.ts +0 -7
- package/lib/typescript/module/src/types/CameraMode.d.ts.map +0 -1
- package/lib/typescript/module/src/types/MapLibreRNEvent.d.ts +0 -6
- package/lib/typescript/module/src/types/MapLibreRNEvent.d.ts.map +0 -1
- package/lib/typescript/module/src/types/OnPressEvent.d.ts +0 -12
- package/lib/typescript/module/src/types/OnPressEvent.d.ts.map +0 -1
- package/src/MapLibreRN.ts +0 -75
- package/src/components/Camera.tsx +0 -568
- package/src/components/MapView.tsx +0 -838
- package/src/hooks/useNativeRef.ts +0 -14
- package/src/types/CameraMode.ts +0 -6
- package/src/types/MapLibreRNEvent.ts +0 -7
- package/src/types/OnPressEvent.ts +0 -11
- /package/ios/{CameraUpdateItem.h → components/camera/CameraUpdateItem.h} +0 -0
- /package/ios/{CameraUpdateQueue.h → components/camera/CameraUpdateQueue.h} +0 -0
- /package/ios/{CameraUpdateQueue.m → components/camera/CameraUpdateQueue.m} +0 -0
- /package/ios/{MLRNSnapshotModule → modules/snapshot}/MLRNSnapshotModule.h +0 -0
|
@@ -73,7 +73,7 @@ Pod::Spec.new do |s|
|
|
|
73
73
|
s.source = { :git => "https://github.com/maplibre/maplibre-react-native.git", :tag => "#{s.version}" }
|
|
74
74
|
|
|
75
75
|
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
76
|
-
s.
|
|
76
|
+
s.public_header_files = "ios/MLRNCustomHeaders.h"
|
|
77
77
|
|
|
78
78
|
install_modules_dependencies(s)
|
|
79
79
|
end
|
package/android/build.gradle
CHANGED
|
@@ -93,9 +93,6 @@ dependencies {
|
|
|
93
93
|
implementation "org.maplibre.gl:android-sdk-${getConfigurableExtOrDefault('nativeVariant')}:${getConfigurableExtOrDefault('nativeVersion')}"
|
|
94
94
|
|
|
95
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
96
|
implementation("org.maplibre.gl:android-plugin-annotation-v9:${getConfigurableExtOrDefault('pluginVersion')}") {
|
|
100
97
|
exclude(group: "org.maplibre.gl", module: "android-sdk")
|
|
101
98
|
}
|
|
@@ -10,10 +10,12 @@ import org.maplibre.reactnative.components.annotation.MLRNCalloutManager
|
|
|
10
10
|
import org.maplibre.reactnative.components.annotation.MLRNMarkerViewManager
|
|
11
11
|
import org.maplibre.reactnative.components.annotation.MLRNPointAnnotationManager
|
|
12
12
|
import org.maplibre.reactnative.components.camera.MLRNCameraManager
|
|
13
|
+
import org.maplibre.reactnative.components.camera.MLRNCameraModule
|
|
13
14
|
import org.maplibre.reactnative.components.images.MLRNImagesManager
|
|
14
15
|
import org.maplibre.reactnative.components.location.MLRNNativeUserLocationManager
|
|
15
16
|
import org.maplibre.reactnative.components.mapview.MLRNAndroidTextureMapViewManager
|
|
16
17
|
import org.maplibre.reactnative.components.mapview.MLRNMapViewManager
|
|
18
|
+
import org.maplibre.reactnative.components.mapview.MLRNMapViewModule
|
|
17
19
|
import org.maplibre.reactnative.components.styles.layers.MLRNBackgroundLayerManager
|
|
18
20
|
import org.maplibre.reactnative.components.styles.layers.MLRNCircleLayerManager
|
|
19
21
|
import org.maplibre.reactnative.components.styles.layers.MLRNFillExtrusionLayerManager
|
|
@@ -32,6 +34,7 @@ import org.maplibre.reactnative.modules.MLRNLogging
|
|
|
32
34
|
import org.maplibre.reactnative.modules.MLRNModule
|
|
33
35
|
import org.maplibre.reactnative.modules.MLRNOfflineModule
|
|
34
36
|
import org.maplibre.reactnative.modules.MLRNSnapshotModule
|
|
37
|
+
import org.maplibre.reactnative.utils.ReactTagResolver
|
|
35
38
|
|
|
36
39
|
|
|
37
40
|
class MLRNPackage : BaseReactPackage() {
|
|
@@ -41,6 +44,16 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
41
44
|
): NativeModule? {
|
|
42
45
|
when (name) {
|
|
43
46
|
MLRNModule.REACT_CLASS -> return MLRNModule(reactContext)
|
|
47
|
+
MLRNMapViewModule.NAME -> return MLRNMapViewModule(
|
|
48
|
+
reactContext,
|
|
49
|
+
getReactTagResolver(reactContext)
|
|
50
|
+
)
|
|
51
|
+
MLRNCameraModule.NAME -> return MLRNCameraModule(
|
|
52
|
+
reactContext,
|
|
53
|
+
getReactTagResolver(reactContext)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
44
57
|
MLRNOfflineModule.REACT_CLASS -> return MLRNOfflineModule(reactContext)
|
|
45
58
|
MLRNSnapshotModule.NAME -> return MLRNSnapshotModule(reactContext)
|
|
46
59
|
MLRNLocationModule.REACT_CLASS -> return MLRNLocationModule(reactContext)
|
|
@@ -63,6 +76,24 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
63
76
|
isTurboModule = false
|
|
64
77
|
)
|
|
65
78
|
|
|
79
|
+
moduleInfos[MLRNMapViewModule.NAME] = ReactModuleInfo(
|
|
80
|
+
MLRNMapViewModule.NAME,
|
|
81
|
+
MLRNMapViewModule.NAME,
|
|
82
|
+
canOverrideExistingModule = false,
|
|
83
|
+
needsEagerInit = false,
|
|
84
|
+
isCxxModule = false,
|
|
85
|
+
isTurboModule = true
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
moduleInfos[MLRNCameraModule.NAME] = ReactModuleInfo(
|
|
89
|
+
MLRNCameraModule.NAME,
|
|
90
|
+
MLRNCameraModule.NAME,
|
|
91
|
+
canOverrideExistingModule = false,
|
|
92
|
+
needsEagerInit = false,
|
|
93
|
+
isCxxModule = false,
|
|
94
|
+
isTurboModule = true
|
|
95
|
+
)
|
|
96
|
+
|
|
66
97
|
moduleInfos[MLRNOfflineModule.REACT_CLASS] = ReactModuleInfo(
|
|
67
98
|
MLRNOfflineModule.REACT_CLASS,
|
|
68
99
|
MLRNOfflineModule.REACT_CLASS,
|
|
@@ -137,4 +168,16 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
137
168
|
|
|
138
169
|
return managers
|
|
139
170
|
}
|
|
171
|
+
|
|
172
|
+
private var reactTagResolver: ReactTagResolver? = null
|
|
173
|
+
|
|
174
|
+
private fun getReactTagResolver(context: ReactApplicationContext): ReactTagResolver {
|
|
175
|
+
val reactTagResolver = reactTagResolver
|
|
176
|
+
if (reactTagResolver == null) {
|
|
177
|
+
val result = ReactTagResolver(context)
|
|
178
|
+
this.reactTagResolver = result
|
|
179
|
+
return result
|
|
180
|
+
}
|
|
181
|
+
return reactTagResolver
|
|
182
|
+
}
|
|
140
183
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
class AbstractEvent(
|
|
8
|
+
viewId: Int,
|
|
9
|
+
private val mEventName: String,
|
|
10
|
+
private val mCanCoalesce: Boolean,
|
|
11
|
+
private val mEvent: WritableMap?
|
|
12
|
+
) : Event<AbstractEvent>(viewId) {
|
|
13
|
+
override fun getEventName(): String {
|
|
14
|
+
return mEventName
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) {
|
|
18
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEvent)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun canCoalesce(): Boolean {
|
|
22
|
+
return mCanCoalesce
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components
|
|
2
|
+
|
|
3
|
+
import android.view.ViewGroup
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.common.MapBuilder
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
8
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
9
|
+
import com.facebook.react.uimanager.common.UIManagerType
|
|
10
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
11
|
+
import org.maplibre.reactnative.events.IEvent
|
|
12
|
+
|
|
13
|
+
abstract class AbstractEventEmitter<T : ViewGroup>(private val reactContext: ReactApplicationContext) :
|
|
14
|
+
ViewGroupManager<T>() {
|
|
15
|
+
private val mRateLimitedEvents: MutableMap<String?, Long?> = HashMap()
|
|
16
|
+
private var mEventDispatcher: EventDispatcher? = null
|
|
17
|
+
|
|
18
|
+
fun handleEvent(event: IEvent) {
|
|
19
|
+
val eventCacheKey = getEventCacheKey(event)
|
|
20
|
+
|
|
21
|
+
// fail safe to protect bridge from being spammed
|
|
22
|
+
if (shouldDropEvent(eventCacheKey, event)) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
mRateLimitedEvents.put(eventCacheKey, System.currentTimeMillis())
|
|
27
|
+
mEventDispatcher!!.dispatchEvent(
|
|
28
|
+
AbstractEvent(
|
|
29
|
+
event.getID(), event.getKey(), event.canCoalesce(), event.toJSON()
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun addEventEmitters(context: ThemedReactContext, view: T) {
|
|
35
|
+
mEventDispatcher =
|
|
36
|
+
UIManagerHelper.getUIManager(context, UIManagerType.Companion.FABRIC)!!.eventDispatcher
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String?, Any?>? {
|
|
40
|
+
val events = customEvents()
|
|
41
|
+
|
|
42
|
+
if (events == null) {
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
val exportedEvents: MutableMap<String?, Any?> = HashMap<String?, Any?>()
|
|
47
|
+
|
|
48
|
+
for (event in events.entries) {
|
|
49
|
+
exportedEvents.put(
|
|
50
|
+
event.key, MapBuilder.of<String?, String?>("registrationName", event.value!!)
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return exportedEvents
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
abstract fun customEvents(): Map<String, String>?
|
|
58
|
+
|
|
59
|
+
private fun shouldDropEvent(cacheKey: String?, event: IEvent): Boolean {
|
|
60
|
+
val lastEventTimestamp = mRateLimitedEvents.get(cacheKey)
|
|
61
|
+
return lastEventTimestamp != null && (event.getTimestamp() - lastEventTimestamp) <= BRIDGE_TIMEOUT_MS
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private fun getEventCacheKey(event: IEvent): String {
|
|
65
|
+
return String.format("%s-%s", event.getKey(), event.getType())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
companion object {
|
|
69
|
+
private const val BRIDGE_TIMEOUT_MS = 10.0
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -94,7 +94,7 @@ public class MLRNPointAnnotation extends AbstractMapFeature implements View.OnLa
|
|
|
94
94
|
@Override
|
|
95
95
|
public void addToMap(MLRNMapView mapView) {
|
|
96
96
|
mMapView = mapView;
|
|
97
|
-
mMap = mapView.
|
|
97
|
+
mMap = mapView.getMapLibreMap();
|
|
98
98
|
makeMarker();
|
|
99
99
|
|
|
100
100
|
if (mChildView != null) {
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.camera
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import org.maplibre.android.camera.CameraPosition
|
|
6
|
+
import org.maplibre.android.camera.CameraUpdateFactory.newCameraPosition
|
|
7
|
+
import org.maplibre.android.camera.CameraUpdateFactory.newLatLngBounds
|
|
8
|
+
import org.maplibre.android.geometry.LatLng
|
|
9
|
+
import org.maplibre.android.geometry.LatLngBounds
|
|
10
|
+
import org.maplibre.android.maps.MapLibreMap.CancelableCallback
|
|
11
|
+
import org.maplibre.reactnative.components.camera.constants.CameraEasing
|
|
12
|
+
import org.maplibre.reactnative.components.mapview.MLRNMapView
|
|
13
|
+
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
14
|
+
|
|
15
|
+
class CameraStop {
|
|
16
|
+
var center: LatLng? = null
|
|
17
|
+
|
|
18
|
+
var bounds: LatLngBounds? = null
|
|
19
|
+
|
|
20
|
+
var paddingTop = 0
|
|
21
|
+
var paddingRight = 0
|
|
22
|
+
var paddingBottom = 0
|
|
23
|
+
var paddingLeft = 0
|
|
24
|
+
|
|
25
|
+
var zoom: Double? = null
|
|
26
|
+
var bearing: Double? = null
|
|
27
|
+
var pitch: Double? = null
|
|
28
|
+
|
|
29
|
+
var duration = 0
|
|
30
|
+
var easing = CameraEasing.NONE
|
|
31
|
+
|
|
32
|
+
var callback: CancelableCallback? = null
|
|
33
|
+
|
|
34
|
+
fun setPadding(paddingLeft: Int, paddingRight: Int, paddingTop: Int, paddingBottom: Int) {
|
|
35
|
+
this.paddingLeft = paddingLeft
|
|
36
|
+
this.paddingRight = paddingRight
|
|
37
|
+
this.paddingTop = paddingTop
|
|
38
|
+
this.paddingBottom = paddingBottom
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun toCameraUpdate(mapView: MLRNMapView): CameraUpdateItem {
|
|
42
|
+
val map = mapView.mapLibreMap
|
|
43
|
+
val currentCamera = map!!.cameraPosition
|
|
44
|
+
val builder = CameraPosition.Builder(currentCamera)
|
|
45
|
+
|
|
46
|
+
// Adding map padding to the camera padding to mimic MLN iOS behavior
|
|
47
|
+
val contentInset = mapView.contentInset
|
|
48
|
+
|
|
49
|
+
val paddingLeft: Int = contentInset[0].toInt() + paddingLeft
|
|
50
|
+
val paddingTop: Int = contentInset[1].toInt() + paddingTop
|
|
51
|
+
val paddingRight: Int = contentInset[2].toInt() + paddingRight
|
|
52
|
+
val paddingBottom: Int = contentInset[3].toInt() + paddingBottom
|
|
53
|
+
|
|
54
|
+
val cameraPadding = intArrayOf(paddingLeft, paddingTop, paddingRight, paddingBottom)
|
|
55
|
+
val cameraPaddingClipped: IntArray = clippedPadding(cameraPadding, mapView)
|
|
56
|
+
|
|
57
|
+
var hasSetZoom = false
|
|
58
|
+
|
|
59
|
+
if (center != null) {
|
|
60
|
+
builder.target(center)
|
|
61
|
+
builder.padding(
|
|
62
|
+
cameraPaddingClipped[0].toDouble(),
|
|
63
|
+
cameraPaddingClipped[1].toDouble(),
|
|
64
|
+
cameraPaddingClipped[2].toDouble(),
|
|
65
|
+
cameraPaddingClipped[3].toDouble()
|
|
66
|
+
)
|
|
67
|
+
} else if (bounds != null) {
|
|
68
|
+
val tilt = (if (pitch != null) pitch else currentCamera.tilt)!!
|
|
69
|
+
val bearing = (if (bearing != null) bearing else currentCamera.bearing)!!
|
|
70
|
+
|
|
71
|
+
val boundsCamera =
|
|
72
|
+
map.getCameraForLatLngBounds(bounds!!, cameraPaddingClipped, bearing, tilt)
|
|
73
|
+
if (boundsCamera != null) {
|
|
74
|
+
builder.target(boundsCamera.target)
|
|
75
|
+
builder.zoom(boundsCamera.zoom)
|
|
76
|
+
builder.padding(boundsCamera.padding)
|
|
77
|
+
} else {
|
|
78
|
+
val update = newLatLngBounds(
|
|
79
|
+
bounds!!,
|
|
80
|
+
cameraPaddingClipped[0],
|
|
81
|
+
cameraPaddingClipped[1],
|
|
82
|
+
cameraPaddingClipped[2],
|
|
83
|
+
cameraPaddingClipped[3]
|
|
84
|
+
)
|
|
85
|
+
return CameraUpdateItem(map, update, duration, easing, callback)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
hasSetZoom = true
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (zoom != null && !hasSetZoom) {
|
|
92
|
+
builder.zoom(zoom!!)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (bearing != null) {
|
|
96
|
+
builder.bearing(bearing!!)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (pitch != null) {
|
|
100
|
+
builder.tilt(pitch!!)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return CameraUpdateItem(
|
|
104
|
+
map, newCameraPosition(builder.build()), duration, easing, callback,
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
companion object {
|
|
109
|
+
fun fromReadableMap(
|
|
110
|
+
context: Context, readableMap: ReadableMap, callback: CancelableCallback?
|
|
111
|
+
): CameraStop {
|
|
112
|
+
val stop = CameraStop()
|
|
113
|
+
|
|
114
|
+
if (readableMap.hasKey("longitude") && readableMap.hasKey("latitude")) {
|
|
115
|
+
stop.center =
|
|
116
|
+
LatLng(readableMap.getDouble("latitude"), readableMap.getDouble("longitude"))
|
|
117
|
+
} else if (readableMap.hasKey("bounds")) {
|
|
118
|
+
stop.bounds = GeoJSONUtils.toLatLngBounds(readableMap.getArray("bounds"))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var paddingTop: Int = getPaddingByKey(readableMap, "top")
|
|
122
|
+
var paddingRight: Int = getPaddingByKey(readableMap, "right")
|
|
123
|
+
var paddingBottom: Int = getPaddingByKey(readableMap, "bottom")
|
|
124
|
+
var paddingLeft: Int = getPaddingByKey(readableMap, "left")
|
|
125
|
+
|
|
126
|
+
val density = context.resources.displayMetrics.density;
|
|
127
|
+
paddingTop = (paddingTop * density).toInt()
|
|
128
|
+
paddingRight = (paddingRight * density).toInt()
|
|
129
|
+
paddingBottom = (paddingBottom * density).toInt()
|
|
130
|
+
paddingLeft = (paddingLeft * density).toInt()
|
|
131
|
+
|
|
132
|
+
stop.setPadding(
|
|
133
|
+
paddingLeft, paddingRight, paddingTop, paddingBottom
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
if (readableMap.hasKey("zoom")) {
|
|
137
|
+
stop.zoom = readableMap.getDouble("zoom")
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (readableMap.hasKey("bearing")) {
|
|
141
|
+
stop.bearing = readableMap.getDouble("bearing")
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (readableMap.hasKey("pitch")) {
|
|
145
|
+
stop.pitch = readableMap.getDouble("pitch")
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (readableMap.hasKey("duration")) {
|
|
149
|
+
stop.duration = readableMap.getInt("duration")
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (readableMap.hasKey("easing")) {
|
|
153
|
+
stop.easing = CameraEasing.fromString(readableMap.getString("easing"))
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
stop.callback = callback
|
|
157
|
+
|
|
158
|
+
return stop
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private fun clippedPadding(padding: IntArray, mapView: MLRNMapView): IntArray {
|
|
162
|
+
val mapHeight = mapView.height
|
|
163
|
+
val mapWidth = mapView.width
|
|
164
|
+
|
|
165
|
+
val left = padding[0]
|
|
166
|
+
val top = padding[1]
|
|
167
|
+
val right = padding[2]
|
|
168
|
+
val bottom = padding[3]
|
|
169
|
+
|
|
170
|
+
var resultLeft = left
|
|
171
|
+
var resultTop = top
|
|
172
|
+
var resultRight = right
|
|
173
|
+
var resultBottom = bottom
|
|
174
|
+
|
|
175
|
+
if (top + bottom >= mapHeight) {
|
|
176
|
+
val totalPadding = (top + bottom).toDouble()
|
|
177
|
+
val extra =
|
|
178
|
+
totalPadding - mapHeight + 1.0 // Add 1 to compensate for floating point math
|
|
179
|
+
resultTop = (resultTop - (top * extra) / totalPadding).toInt()
|
|
180
|
+
resultBottom = (resultBottom - (bottom * extra) / totalPadding).toInt()
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (left + right >= mapWidth) {
|
|
184
|
+
val totalPadding = (left + right).toDouble()
|
|
185
|
+
val extra =
|
|
186
|
+
totalPadding - mapWidth + 1.0 // Add 1 to compensate for floating point math
|
|
187
|
+
resultLeft = (resultLeft - (left * extra) / totalPadding).toInt()
|
|
188
|
+
resultRight = (resultRight - (right * extra) / totalPadding).toInt()
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return intArrayOf(resultLeft, resultTop, resultRight, resultBottom)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private fun getPaddingByKey(map: ReadableMap?, key: String): Int {
|
|
195
|
+
val paddingMap = map?.getMap("padding")
|
|
196
|
+
return if (paddingMap != null && paddingMap.hasKey(key)) {
|
|
197
|
+
paddingMap.getInt(key)
|
|
198
|
+
} else {
|
|
199
|
+
0
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.camera
|
|
2
|
+
|
|
3
|
+
import org.maplibre.android.camera.CameraUpdate
|
|
4
|
+
import org.maplibre.android.constants.MapLibreConstants
|
|
5
|
+
import org.maplibre.android.maps.MapLibreMap
|
|
6
|
+
import org.maplibre.android.maps.MapLibreMap.CancelableCallback
|
|
7
|
+
import org.maplibre.reactnative.components.camera.constants.CameraEasing
|
|
8
|
+
import java.lang.ref.WeakReference
|
|
9
|
+
import java.util.concurrent.ExecutionException
|
|
10
|
+
import java.util.concurrent.RunnableFuture
|
|
11
|
+
import java.util.concurrent.TimeUnit
|
|
12
|
+
import java.util.concurrent.TimeoutException
|
|
13
|
+
|
|
14
|
+
class CameraUpdateItem(
|
|
15
|
+
map: MapLibreMap?,
|
|
16
|
+
|
|
17
|
+
private val cameraUpdate: CameraUpdate,
|
|
18
|
+
|
|
19
|
+
private val duration: Int,
|
|
20
|
+
@param:CameraEasing.Easing private val easing: Int,
|
|
21
|
+
|
|
22
|
+
private val callback: CancelableCallback?,
|
|
23
|
+
) : RunnableFuture<Void?> {
|
|
24
|
+
private var isCameraActionFinished = false
|
|
25
|
+
private var isCameraActionCancelled = false
|
|
26
|
+
|
|
27
|
+
private val mMap: WeakReference<MapLibreMap?> = WeakReference<MapLibreMap?>(map)
|
|
28
|
+
|
|
29
|
+
override fun run() {
|
|
30
|
+
val callback: CancelableCallback = object : CancelableCallback {
|
|
31
|
+
override fun onCancel() {
|
|
32
|
+
handleCallbackResponse(true)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun onFinish() {
|
|
36
|
+
handleCallbackResponse(false)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
val map = mMap.get()
|
|
41
|
+
if (map == null) {
|
|
42
|
+
isCameraActionCancelled = true
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// animateCamera / easeCamera only allows positive duration
|
|
47
|
+
if (this.duration == 0 || easing == CameraEasing.NONE) {
|
|
48
|
+
map.moveCamera(cameraUpdate, callback)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// On iOS a duration of -1 means default or dynamic duration (based on flight-path length)
|
|
53
|
+
// On Android we can fallback to MapLibre's default duration as there is no such API
|
|
54
|
+
// TODO: Implement in MapLibre Native Android
|
|
55
|
+
val duration =
|
|
56
|
+
if (this.duration < 0) MapLibreConstants.ANIMATION_DURATION else this.duration
|
|
57
|
+
|
|
58
|
+
when (easing) {
|
|
59
|
+
CameraEasing.LINEAR -> {
|
|
60
|
+
map.easeCamera(cameraUpdate, duration, false, callback)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
CameraEasing.EASE -> {
|
|
64
|
+
map.easeCamera(cameraUpdate, duration, true, callback)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
CameraEasing.FLY -> {
|
|
68
|
+
map.animateCamera(cameraUpdate, duration, callback)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override fun cancel(mayInterruptIfRunning: Boolean): Boolean {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun isCancelled(): Boolean {
|
|
78
|
+
return isCameraActionCancelled
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun isDone(): Boolean {
|
|
82
|
+
return isCameraActionFinished
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Throws(InterruptedException::class, ExecutionException::class)
|
|
86
|
+
override fun get(): Void? {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Throws(InterruptedException::class, ExecutionException::class, TimeoutException::class)
|
|
91
|
+
override fun get(timeout: Long, unit: TimeUnit): Void? {
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private fun handleCallbackResponse(isCancel: Boolean) {
|
|
96
|
+
if (callback == null) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isCameraActionCancelled = isCancel
|
|
101
|
+
isCameraActionFinished = !isCancel
|
|
102
|
+
|
|
103
|
+
if (isCancel) {
|
|
104
|
+
callback.onCancel()
|
|
105
|
+
} else {
|
|
106
|
+
callback.onFinish()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.camera
|
|
2
|
+
|
|
3
|
+
import org.maplibre.reactnative.components.mapview.MLRNMapView
|
|
4
|
+
import java.util.LinkedList
|
|
5
|
+
import java.util.Queue
|
|
6
|
+
|
|
7
|
+
class CameraUpdateQueue {
|
|
8
|
+
private var queue: Queue<CameraStop?>
|
|
9
|
+
|
|
10
|
+
private var completeListener: OnCompleteAllListener? = null
|
|
11
|
+
|
|
12
|
+
interface OnCompleteAllListener {
|
|
13
|
+
fun onCompleteAll()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
init {
|
|
17
|
+
queue = LinkedList<CameraStop?>()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fun offer(item: CameraStop?) {
|
|
21
|
+
queue.offer(item)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fun size(): Int {
|
|
25
|
+
return queue.size
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
val isEmpty: Boolean
|
|
29
|
+
get() = queue.isEmpty()
|
|
30
|
+
|
|
31
|
+
fun flush() {
|
|
32
|
+
while (queue.size > 0) {
|
|
33
|
+
queue.remove()
|
|
34
|
+
}
|
|
35
|
+
queue = LinkedList<CameraStop?>()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fun setOnCompleteAllListener(listener: OnCompleteAllListener?) {
|
|
39
|
+
completeListener = listener
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fun execute(map: MLRNMapView) {
|
|
43
|
+
if (queue.isEmpty()) {
|
|
44
|
+
if (completeListener != null) {
|
|
45
|
+
completeListener!!.onCompleteAll()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
val stop = queue.poll()
|
|
52
|
+
if (stop == null) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
val item = stop.toCameraUpdate(map)
|
|
57
|
+
item.run()
|
|
58
|
+
execute(map)
|
|
59
|
+
}
|
|
60
|
+
}
|