@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.
- 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
|
@@ -4,27 +4,8 @@ public class EventTypes {
|
|
|
4
4
|
// map event types
|
|
5
5
|
public static final String MAP_CLICK = "press";
|
|
6
6
|
public static final String MAP_LONG_CLICK = "longpress";
|
|
7
|
-
public static final String MAP_USER_TRACKING_MODE_CHANGE = "usertrackingmodechange";
|
|
8
|
-
|
|
9
|
-
public static final String REGION_WILL_CHANGE = "regionwillchange";
|
|
10
|
-
public static final String REGION_IS_CHANGING = "regionischanging";
|
|
11
|
-
public static final String REGION_DID_CHANGE = "regiondidchange";
|
|
12
7
|
public static final String USER_LOCATION_UPDATED = "userlocationdupdated";
|
|
13
8
|
|
|
14
|
-
public static final String WILL_START_LOADING_MAP = "willstartloadingmap";
|
|
15
|
-
public static final String DID_FINISH_LOADING_MAP = "didfinishloadingmap";
|
|
16
|
-
public static final String DID_FAIL_LOADING_MAP = "didfailloadingmap";
|
|
17
|
-
|
|
18
|
-
public static final String WILL_START_RENDERING_FRAME = "willstartrenderingframe";
|
|
19
|
-
public static final String DID_FINISH_RENDERING_FRAME = "didfinishrenderingframe";
|
|
20
|
-
public static final String DID_FINISH_RENDERING_FRAME_FULLY = "didfinishrenderingframefully";
|
|
21
|
-
|
|
22
|
-
public static final String WILL_START_RENDERING_MAP = "willstartrenderingmap";
|
|
23
|
-
public static final String DID_FINISH_RENDERING_MAP = "didfinishrenderingmap";
|
|
24
|
-
public static final String DID_FINISH_RENDERING_MAP_FULLY = "didfinishrenderingmapfully";
|
|
25
|
-
|
|
26
|
-
public static final String DID_FINISH_LOADING_STYLE = "didfinishloadingstyle";
|
|
27
|
-
|
|
28
9
|
// point annotation event types
|
|
29
10
|
public static final String ANNOTATION_SELECTED = "annotationselected";
|
|
30
11
|
public static final String ANNOTATION_DESELECTED = "annotationdeselected";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location
|
|
2
|
+
|
|
3
|
+
import org.maplibre.android.location.modes.CameraMode
|
|
4
|
+
|
|
5
|
+
object TrackUserLocationMode {
|
|
6
|
+
const val NONE: Int = 0
|
|
7
|
+
const val DEFAULT: Int = 1
|
|
8
|
+
const val HEADING: Int = 2
|
|
9
|
+
const val COURSE: Int = 3
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@CameraMode.Mode
|
|
13
|
+
fun getCameraMode(mode: Int): Int {
|
|
14
|
+
return when (mode) {
|
|
15
|
+
DEFAULT -> CameraMode.TRACKING
|
|
16
|
+
HEADING -> CameraMode.TRACKING_COMPASS
|
|
17
|
+
COURSE -> CameraMode.TRACKING_GPS
|
|
18
|
+
else -> CameraMode.NONE
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fun isUserGesture(reason: Int): Boolean {
|
|
23
|
+
return reason == 1 || reason == 2 // user gesture or animation
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fun toString(value: Int): String? {
|
|
27
|
+
return when (value) {
|
|
28
|
+
DEFAULT -> "default"
|
|
29
|
+
HEADING -> "heading"
|
|
30
|
+
COURSE -> "course"
|
|
31
|
+
else -> null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fun fromString(value: String?): Int {
|
|
36
|
+
return when (value) {
|
|
37
|
+
"default" -> DEFAULT
|
|
38
|
+
"heading" -> HEADING
|
|
39
|
+
"course" -> COURSE
|
|
40
|
+
else -> NONE
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -8,7 +8,7 @@ public class UserLocation {
|
|
|
8
8
|
private Location currentLocation;
|
|
9
9
|
private Location previousLocation;
|
|
10
10
|
|
|
11
|
-
private int userTrackingMode =
|
|
11
|
+
private int userTrackingMode = TrackUserLocationMode.NONE;
|
|
12
12
|
|
|
13
13
|
public UserLocation() {
|
|
14
14
|
this(null);
|
|
@@ -3,20 +3,15 @@ package org.maplibre.reactnative.modules;
|
|
|
3
3
|
import android.os.Handler;
|
|
4
4
|
import android.util.Log;
|
|
5
5
|
|
|
6
|
-
import com.facebook.react.bridge.Promise;
|
|
7
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
9
8
|
import com.facebook.react.bridge.ReactMethod;
|
|
10
9
|
import com.facebook.react.common.MapBuilder;
|
|
11
10
|
import com.facebook.react.module.annotations.ReactModule;
|
|
11
|
+
|
|
12
12
|
import org.maplibre.android.MapLibre;
|
|
13
|
-
import org.maplibre.android.WellKnownTileServer;
|
|
14
|
-
import org.maplibre.reactnative.components.camera.constants.CameraMode;
|
|
15
13
|
import org.maplibre.reactnative.components.styles.sources.MLRNSource;
|
|
16
|
-
import org.maplibre.reactnative.events.constants.EventTypes;
|
|
17
14
|
import org.maplibre.reactnative.http.CustomHeadersInterceptor;
|
|
18
|
-
import org.maplibre.reactnative.location.UserLocationVerticalAlignment;
|
|
19
|
-
import org.maplibre.reactnative.location.UserTrackingMode;
|
|
20
15
|
|
|
21
16
|
import okhttp3.Dispatcher;
|
|
22
17
|
import okhttp3.OkHttpClient;
|
|
@@ -61,45 +56,6 @@ public class MLRNModule extends ReactContextBaseJavaModule {
|
|
|
61
56
|
Map<String, String> styleURLS = new HashMap<>();
|
|
62
57
|
styleURLS.put("Default", DEFAULT_STYLE_URL);
|
|
63
58
|
|
|
64
|
-
// events
|
|
65
|
-
Map<String, String> eventTypes = new HashMap<>();
|
|
66
|
-
eventTypes.put("MapClick", EventTypes.MAP_CLICK);
|
|
67
|
-
eventTypes.put("MapLongClick", EventTypes.MAP_LONG_CLICK);
|
|
68
|
-
eventTypes.put("RegionWillChange", EventTypes.REGION_WILL_CHANGE);
|
|
69
|
-
eventTypes.put("RegionIsChanging", EventTypes.REGION_IS_CHANGING);
|
|
70
|
-
eventTypes.put("RegionDidChange", EventTypes.REGION_DID_CHANGE);
|
|
71
|
-
eventTypes.put("UserLocationUpdated", EventTypes.USER_LOCATION_UPDATED);
|
|
72
|
-
eventTypes.put("WillStartLoadingMap", EventTypes.WILL_START_LOADING_MAP);
|
|
73
|
-
eventTypes.put("DidFinishLoadingMap", EventTypes.DID_FINISH_LOADING_MAP);
|
|
74
|
-
eventTypes.put("DidFailLoadingMap", EventTypes.DID_FAIL_LOADING_MAP);
|
|
75
|
-
eventTypes.put("WillStartRenderingFrame", EventTypes.WILL_START_RENDERING_FRAME);
|
|
76
|
-
eventTypes.put("DidFinishRenderingFrame", EventTypes.DID_FINISH_RENDERING_FRAME);
|
|
77
|
-
eventTypes.put("DidFinishRenderingFrameFully", EventTypes.DID_FINISH_RENDERING_FRAME_FULLY);
|
|
78
|
-
eventTypes.put("WillStartRenderingMap", EventTypes.WILL_START_RENDERING_MAP);
|
|
79
|
-
eventTypes.put("DidFinishRenderingMap", EventTypes.DID_FINISH_RENDERING_MAP);
|
|
80
|
-
eventTypes.put("DidFinishRenderingMapFully", EventTypes.DID_FINISH_RENDERING_MAP_FULLY);
|
|
81
|
-
eventTypes.put("DidFinishLoadingStyle", EventTypes.DID_FINISH_LOADING_STYLE);
|
|
82
|
-
|
|
83
|
-
// user tracking modes
|
|
84
|
-
Map<String, Integer> userTrackingModes = new HashMap<>();
|
|
85
|
-
userTrackingModes.put("None", UserTrackingMode.NONE);
|
|
86
|
-
userTrackingModes.put("Follow", UserTrackingMode.FOLLOW);
|
|
87
|
-
userTrackingModes.put("FollowWithCourse", UserTrackingMode.FollowWithCourse);
|
|
88
|
-
userTrackingModes.put("FollowWithHeading", UserTrackingMode.FollowWithHeading);
|
|
89
|
-
|
|
90
|
-
// user location vertical alignment
|
|
91
|
-
Map<String, Integer> userLocationVerticalAlignment = new HashMap<>();
|
|
92
|
-
userLocationVerticalAlignment.put("Center", UserLocationVerticalAlignment.CENTER);
|
|
93
|
-
userLocationVerticalAlignment.put("Top", UserLocationVerticalAlignment.TOP);
|
|
94
|
-
userLocationVerticalAlignment.put("Bottom", UserLocationVerticalAlignment.BOTTOM);
|
|
95
|
-
|
|
96
|
-
// camera modes
|
|
97
|
-
Map<String, Integer> cameraModes = new HashMap<>();
|
|
98
|
-
cameraModes.put("Flight", CameraMode.FLIGHT);
|
|
99
|
-
cameraModes.put("Ease", CameraMode.EASE);
|
|
100
|
-
cameraModes.put("Linear", CameraMode.LINEAR);
|
|
101
|
-
cameraModes.put("None", CameraMode.NONE);
|
|
102
|
-
|
|
103
59
|
// style source constants
|
|
104
60
|
Map<String, String> styleSourceConsts = new HashMap<>();
|
|
105
61
|
styleSourceConsts.put("DefaultSourceID", MLRNSource.DEFAULT_ID);
|
|
@@ -121,10 +77,6 @@ public class MLRNModule extends ReactContextBaseJavaModule {
|
|
|
121
77
|
|
|
122
78
|
return MapBuilder.<String, Object>builder()
|
|
123
79
|
.put("StyleURL", styleURLS)
|
|
124
|
-
.put("EventTypes", eventTypes)
|
|
125
|
-
.put("UserTrackingModes", userTrackingModes)
|
|
126
|
-
.put("UserLocationVerticalAlignment", userLocationVerticalAlignment)
|
|
127
|
-
.put("CameraModes", cameraModes)
|
|
128
80
|
.put("StyleSource", styleSourceConsts)
|
|
129
81
|
.put("OfflinePackDownloadState", offlinePackDownloadStates)
|
|
130
82
|
.put("OfflineCallbackName", offlineModuleCallbackNames)
|
|
@@ -203,15 +203,8 @@ public class ConvertUtils {
|
|
|
203
203
|
return list;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
public static PointF toPointF(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (array == null) {
|
|
210
|
-
return pointF;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
pointF.set((float)array.getDouble(0), (float)array.getDouble(1));
|
|
214
|
-
return pointF;
|
|
206
|
+
public static PointF toPointF(ReadableMap map) {
|
|
207
|
+
return new PointF((float) map.getDouble("locationX"), (float) map.getDouble("locationY"));
|
|
215
208
|
}
|
|
216
209
|
|
|
217
210
|
public static RectF toRectF(ReadableArray array) {
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
package org.maplibre.reactnative.utils
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray
|
|
5
|
+
import com.facebook.react.bridge.WritableArray
|
|
6
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
9
|
+
import org.maplibre.android.geometry.LatLng
|
|
10
|
+
import org.maplibre.android.geometry.LatLngBounds
|
|
11
|
+
import org.maplibre.android.geometry.LatLngQuad
|
|
12
|
+
import org.maplibre.android.log.Logger
|
|
13
|
+
import org.maplibre.geojson.Feature
|
|
14
|
+
import org.maplibre.geojson.FeatureCollection
|
|
15
|
+
import org.maplibre.geojson.Geometry
|
|
16
|
+
import org.maplibre.geojson.GeometryCollection
|
|
17
|
+
import org.maplibre.geojson.LineString
|
|
18
|
+
import org.maplibre.geojson.MultiLineString
|
|
19
|
+
import org.maplibre.geojson.MultiPoint
|
|
20
|
+
import org.maplibre.geojson.MultiPolygon
|
|
21
|
+
import org.maplibre.geojson.Point
|
|
22
|
+
import org.maplibre.geojson.Polygon
|
|
23
|
+
import org.maplibre.turf.TurfMeasurement
|
|
24
|
+
import java.util.stream.Collectors
|
|
25
|
+
|
|
26
|
+
object GeoJSONUtils {
|
|
27
|
+
const val LOG_TAG: String = "GeoJSONUtils"
|
|
28
|
+
|
|
29
|
+
@JvmStatic
|
|
30
|
+
fun fromFeature(feature: Feature): WritableMap {
|
|
31
|
+
val map = Arguments.createMap()
|
|
32
|
+
map.putString("type", "Feature")
|
|
33
|
+
map.putString("id", feature.id())
|
|
34
|
+
|
|
35
|
+
val geometry = feature.geometry()
|
|
36
|
+
if (geometry == null) {
|
|
37
|
+
map.putNull("geometry")
|
|
38
|
+
} else {
|
|
39
|
+
map.putMap("geometry", fromGeometry(geometry))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
val properties = feature.properties()
|
|
43
|
+
if (properties == null) {
|
|
44
|
+
map.putNull("properties")
|
|
45
|
+
} else {
|
|
46
|
+
map.putMap("properties", ConvertUtils.toWritableMap(properties))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return map
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun fromGeometry(geometry: Geometry): WritableMap? {
|
|
53
|
+
val type = geometry.type()
|
|
54
|
+
|
|
55
|
+
return when (type) {
|
|
56
|
+
"Point" -> fromPoint(geometry as Point)
|
|
57
|
+
"LineString" -> fromLineString(geometry as LineString)
|
|
58
|
+
"Polygon" -> fromPolygon(geometry as Polygon)
|
|
59
|
+
"MultiPoint" -> fromMultiPoint(geometry as MultiPoint)
|
|
60
|
+
"MultiLineString" -> fromMultiLineString(geometry as MultiLineString)
|
|
61
|
+
"MultiPolygon" -> fromMultiPolygon(geometry as MultiPolygon)
|
|
62
|
+
"GeometryCollection" -> fromGeometryCollection(geometry as GeometryCollection)
|
|
63
|
+
else -> {
|
|
64
|
+
Logger.w(LOG_TAG, "GeoJSONUtils.fromGeometry unsupported type: \"$type\"")
|
|
65
|
+
|
|
66
|
+
null
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun fromPoint(point: Point?): WritableMap {
|
|
72
|
+
val map = Arguments.createMap()
|
|
73
|
+
map.putString("type", "Point")
|
|
74
|
+
map.putArray("coordinates", getCoordinates(point))
|
|
75
|
+
return map
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fun fromLineString(lineString: LineString): WritableMap {
|
|
79
|
+
val map = Arguments.createMap()
|
|
80
|
+
map.putString("type", "LineString")
|
|
81
|
+
map.putArray("coordinates", getCoordinates(lineString))
|
|
82
|
+
return map
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
fun fromPolygon(polygon: Polygon): WritableMap {
|
|
86
|
+
val map = Arguments.createMap()
|
|
87
|
+
map.putString("type", "Polygon")
|
|
88
|
+
map.putArray("coordinates", getCoordinates(polygon))
|
|
89
|
+
return map
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fun fromMultiPoint(multiPoint: MultiPoint): WritableMap {
|
|
93
|
+
val map = Arguments.createMap()
|
|
94
|
+
map.putString("type", "MultiPoint")
|
|
95
|
+
map.putArray("coordinates", getCoordinates(multiPoint))
|
|
96
|
+
return map
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fun fromMultiLineString(multiLineString: MultiLineString): WritableMap {
|
|
100
|
+
val map = Arguments.createMap()
|
|
101
|
+
map.putString("type", "MultiLineString")
|
|
102
|
+
map.putArray("coordinates", getCoordinates(multiLineString))
|
|
103
|
+
return map
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
fun fromMultiPolygon(multiPolygon: MultiPolygon): WritableMap {
|
|
107
|
+
val map = Arguments.createMap()
|
|
108
|
+
map.putString("type", "MultiPolygon")
|
|
109
|
+
map.putArray("coordinates", getCoordinates(multiPolygon))
|
|
110
|
+
return map
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fun fromGeometryCollection(geometryCollection: GeometryCollection): WritableMap {
|
|
114
|
+
val map = Arguments.createMap()
|
|
115
|
+
map.putString("type", "GeometryCollection")
|
|
116
|
+
|
|
117
|
+
map.putArray(
|
|
118
|
+
"geometries",
|
|
119
|
+
Arguments.fromList(
|
|
120
|
+
geometryCollection.geometries().stream()
|
|
121
|
+
.map<WritableMap?> { obj: Geometry -> fromGeometry(obj) }
|
|
122
|
+
.collect(Collectors.toList())))
|
|
123
|
+
|
|
124
|
+
return map
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fun getCoordinates(point: Point?): WritableArray {
|
|
128
|
+
return Arguments.fromArray(pointToDoubleArray(point))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fun getCoordinates(lineString: LineString): WritableArray {
|
|
132
|
+
val array = Arguments.createArray()
|
|
133
|
+
|
|
134
|
+
val points = lineString.coordinates()
|
|
135
|
+
for (point in points) {
|
|
136
|
+
array.pushArray(Arguments.fromArray(pointToDoubleArray(point)))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return array
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fun getCoordinates(polygon: Polygon): WritableArray {
|
|
143
|
+
val array = Arguments.createArray()
|
|
144
|
+
|
|
145
|
+
val points = polygon.coordinates()
|
|
146
|
+
|
|
147
|
+
for (curPoint in points) {
|
|
148
|
+
val innerArray = Arguments.createArray()
|
|
149
|
+
|
|
150
|
+
for (point in curPoint) {
|
|
151
|
+
innerArray.pushArray(Arguments.fromArray(pointToDoubleArray(point)))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
array.pushArray(innerArray)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return array
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fun getCoordinates(multiPoint: MultiPoint): WritableArray {
|
|
161
|
+
val array = Arguments.createArray()
|
|
162
|
+
|
|
163
|
+
val points = multiPoint.coordinates()
|
|
164
|
+
for (point in points) {
|
|
165
|
+
array.pushArray(Arguments.fromArray(pointToDoubleArray(point)))
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return array
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
fun getCoordinates(multiLineString: MultiLineString): WritableArray {
|
|
172
|
+
val array = Arguments.createArray()
|
|
173
|
+
|
|
174
|
+
val lines = multiLineString.coordinates()
|
|
175
|
+
for (line in lines) {
|
|
176
|
+
val lineArray = Arguments.createArray()
|
|
177
|
+
|
|
178
|
+
for (point in line) {
|
|
179
|
+
lineArray.pushArray(Arguments.fromArray(pointToDoubleArray(point)))
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
array.pushArray(lineArray)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return array
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
fun getCoordinates(multiPolygon: MultiPolygon): WritableArray {
|
|
189
|
+
val array = Arguments.createArray()
|
|
190
|
+
|
|
191
|
+
val polygons = multiPolygon.coordinates()
|
|
192
|
+
for (polygon in polygons) {
|
|
193
|
+
val polygonArray = Arguments.createArray()
|
|
194
|
+
|
|
195
|
+
for (ring in polygon) {
|
|
196
|
+
val ringArray = Arguments.createArray()
|
|
197
|
+
|
|
198
|
+
for (point in ring!!) {
|
|
199
|
+
ringArray.pushArray(Arguments.fromArray(pointToDoubleArray(point)))
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
polygonArray.pushArray(ringArray)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
array.pushArray(polygonArray)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return array
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@JvmStatic
|
|
212
|
+
fun toPointFeature(latLng: LatLng, properties: WritableMap?): WritableMap {
|
|
213
|
+
val map: WritableMap = WritableNativeMap()
|
|
214
|
+
map.putString("type", "Feature")
|
|
215
|
+
map.putMap("geometry", toPointGeometry(latLng))
|
|
216
|
+
map.putMap("properties", properties)
|
|
217
|
+
return map
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
fun toPointGeometry(latLng: LatLng): WritableMap {
|
|
221
|
+
val geometry: WritableMap = WritableNativeMap()
|
|
222
|
+
geometry.putString("type", "Point")
|
|
223
|
+
geometry.putArray("coordinates", fromLatLng(latLng))
|
|
224
|
+
return geometry
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
fun fromLatLng(latLng: LatLng): WritableArray {
|
|
228
|
+
val coords = doubleArrayOf(latLng.longitude, latLng.latitude)
|
|
229
|
+
val writableCoords: WritableArray = WritableNativeArray()
|
|
230
|
+
writableCoords.pushDouble(coords[0])
|
|
231
|
+
writableCoords.pushDouble(coords[1])
|
|
232
|
+
return writableCoords
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@JvmStatic
|
|
236
|
+
fun toLatLng(point: Point?): LatLng? {
|
|
237
|
+
if (point == null) {
|
|
238
|
+
return null
|
|
239
|
+
}
|
|
240
|
+
return LatLng(point.latitude(), point.longitude())
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
fun toLatLng(coordinates: ReadableArray?): LatLng? {
|
|
244
|
+
if (coordinates == null || coordinates.size() < 2) {
|
|
245
|
+
return null
|
|
246
|
+
}
|
|
247
|
+
return LatLng(coordinates.getDouble(1), coordinates.getDouble(0))
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@JvmStatic
|
|
251
|
+
fun toPointGeometry(featureJSONString: String): Point? {
|
|
252
|
+
val feature = Feature.fromJson(featureJSONString)
|
|
253
|
+
if (feature == null) {
|
|
254
|
+
return null
|
|
255
|
+
}
|
|
256
|
+
return feature.geometry() as Point?
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@JvmStatic
|
|
260
|
+
fun fromLatLngBounds(latLngBounds: LatLngBounds): WritableArray {
|
|
261
|
+
val array = Arguments.createArray()
|
|
262
|
+
array.pushDouble(latLngBounds.getLonWest())
|
|
263
|
+
array.pushDouble(latLngBounds.getLatSouth())
|
|
264
|
+
array.pushDouble(latLngBounds.getLonEast())
|
|
265
|
+
array.pushDouble(latLngBounds.getLatNorth())
|
|
266
|
+
|
|
267
|
+
return array
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private fun toGeometryCollection(features: MutableList<Feature>): GeometryCollection {
|
|
271
|
+
val geometries = ArrayList<Geometry?>()
|
|
272
|
+
geometries.ensureCapacity(features.size)
|
|
273
|
+
for (feature in features) {
|
|
274
|
+
geometries.add(feature.geometry())
|
|
275
|
+
}
|
|
276
|
+
return GeometryCollection.fromGeometries(geometries)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@JvmStatic
|
|
280
|
+
fun toLatLngBounds(featureCollection: FeatureCollection): LatLngBounds {
|
|
281
|
+
val features = featureCollection.features()
|
|
282
|
+
|
|
283
|
+
val bbox = TurfMeasurement.bbox(toGeometryCollection(features!!))
|
|
284
|
+
|
|
285
|
+
return LatLngBounds.from(bbox[3], bbox[2], bbox[1], bbox[0])
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@JvmStatic
|
|
289
|
+
fun toLatLngBounds(array: ReadableArray?): LatLngBounds? {
|
|
290
|
+
if (array != null && array.size() == 4) {
|
|
291
|
+
return LatLngBounds.from(
|
|
292
|
+
array.getDouble(3),
|
|
293
|
+
array.getDouble(2),
|
|
294
|
+
array.getDouble(1),
|
|
295
|
+
array.getDouble(0)
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@JvmStatic
|
|
303
|
+
fun toLatLngQuad(array: ReadableArray?): LatLngQuad? {
|
|
304
|
+
// [top left, top right, bottom right, bottom left]
|
|
305
|
+
if (array == null || array.size() < 4) {
|
|
306
|
+
return null
|
|
307
|
+
}
|
|
308
|
+
return LatLngQuad(
|
|
309
|
+
toLatLng(array.getArray(0))!!,
|
|
310
|
+
toLatLng(array.getArray(1))!!,
|
|
311
|
+
toLatLng(array.getArray(2))!!,
|
|
312
|
+
toLatLng(array.getArray(3))!!
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
fun pointToDoubleArray(point: Point?): DoubleArray {
|
|
317
|
+
if (point == null) {
|
|
318
|
+
return doubleArrayOf(0.0, 0.0)
|
|
319
|
+
}
|
|
320
|
+
return doubleArrayOf(point.longitude(), point.latitude())
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package org.maplibre.reactnative.utils
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.UIManager
|
|
7
|
+
import com.facebook.react.uimanager.IllegalViewOperationException
|
|
8
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
9
|
+
import com.facebook.react.uimanager.common.UIManagerType
|
|
10
|
+
import org.maplibre.android.log.Logger
|
|
11
|
+
|
|
12
|
+
data class Await<V>(
|
|
13
|
+
val fn: (V) -> Unit,
|
|
14
|
+
val reject: Promise?
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const val LOG_TAG = "ReactTagResolver"
|
|
18
|
+
|
|
19
|
+
typealias ReactTag = Double
|
|
20
|
+
|
|
21
|
+
// https://github.com/rnmapbox/maps/pull/3074
|
|
22
|
+
open class ReactTagResolver(val context: ReactApplicationContext) {
|
|
23
|
+
private val createdViews: HashSet<Int> = hashSetOf<Int>()
|
|
24
|
+
private val awaitedViews: HashMap<Int, MutableList<Await<View?>>> = hashMapOf()
|
|
25
|
+
|
|
26
|
+
// To be called from view.setId
|
|
27
|
+
fun tagAssigned(reactTag: Int) {
|
|
28
|
+
createdViews.add(reactTag)
|
|
29
|
+
|
|
30
|
+
val list = awaitedViews[reactTag]
|
|
31
|
+
if (list != null) {
|
|
32
|
+
context.runOnUiQueueThread {
|
|
33
|
+
try {
|
|
34
|
+
val view = manager.resolveView(reactTag)
|
|
35
|
+
|
|
36
|
+
list.forEach { it.fn(view) }
|
|
37
|
+
} catch (err: IllegalViewOperationException) {
|
|
38
|
+
list.forEach { it.reject?.reject(err) }
|
|
39
|
+
}
|
|
40
|
+
awaitedViews.remove(reactTag)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun viewRemoved(reactTag: Int) {
|
|
46
|
+
awaitedViews.remove(reactTag)
|
|
47
|
+
createdViews.remove(reactTag)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private val manager: UIManager
|
|
51
|
+
get() = UIManagerHelper.getUIManager(context, UIManagerType.FABRIC)!!
|
|
52
|
+
|
|
53
|
+
fun <V> withViewResolved(reactTag: Int, promise: Promise? = null, fn: (V) -> Unit) {
|
|
54
|
+
context.runOnUiQueueThread() {
|
|
55
|
+
try {
|
|
56
|
+
val resolvedView: View? = manager.resolveView(reactTag)
|
|
57
|
+
val view = resolvedView as? V
|
|
58
|
+
if (view != null) {
|
|
59
|
+
fn(view)
|
|
60
|
+
} else {
|
|
61
|
+
val message =
|
|
62
|
+
"`reactTag` $reactTag resolved to `view` $resolvedView which is null or a wrong type"
|
|
63
|
+
Logger.e(LOG_TAG, message)
|
|
64
|
+
promise?.reject(Throwable(message))
|
|
65
|
+
}
|
|
66
|
+
} catch (err: IllegalViewOperationException) {
|
|
67
|
+
if (!createdViews.contains(reactTag)) {
|
|
68
|
+
awaitedViews.getOrPut(reactTag) { mutableListOf() }.add(
|
|
69
|
+
Await({ view ->
|
|
70
|
+
if (view != null) {
|
|
71
|
+
fn(view as V)
|
|
72
|
+
} else {
|
|
73
|
+
val message = "`reactTag` $reactTag resolved null"
|
|
74
|
+
Logger.e(LOG_TAG, message)
|
|
75
|
+
promise?.reject(Throwable(message))
|
|
76
|
+
}
|
|
77
|
+
}, promise)
|
|
78
|
+
)
|
|
79
|
+
} else {
|
|
80
|
+
promise?.reject(err)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
package/ios/MLRNCallout.h
CHANGED
package/ios/MLRNEvent.m
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
if (self = [super init]) {
|
|
7
7
|
_timestamp = [[NSDate date] timeIntervalSince1970];
|
|
8
8
|
}
|
|
9
|
+
|
|
9
10
|
return self;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -13,11 +14,12 @@
|
|
|
13
14
|
if (_payload == nil) {
|
|
14
15
|
return @{};
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
return _payload;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
- (NSDictionary *)toJSON {
|
|
20
|
-
return
|
|
22
|
+
return self.payload;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
+ (MLRNEvent *)makeEvent:(NSString *)type {
|
package/ios/MLRNEventTypes.h
CHANGED
|
@@ -2,41 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
@interface MLRNEventTypes : NSObject
|
|
4
4
|
|
|
5
|
-
extern NSString *const
|
|
6
|
-
extern NSString *const
|
|
5
|
+
extern NSString *const RCT_MLRN_PRESS;
|
|
6
|
+
extern NSString *const RCT_MLRN_LONG_PRESS;
|
|
7
7
|
|
|
8
|
-
extern NSString *const
|
|
9
|
-
extern NSString *const RCT_MAPBOX_USER_TRACKING_MODE_CHANGE;
|
|
8
|
+
extern NSString *const RCT_MLRN_ANNOTATION_TAP;
|
|
10
9
|
|
|
11
|
-
extern NSString *const
|
|
12
|
-
extern NSString *const
|
|
13
|
-
extern NSString *const
|
|
10
|
+
extern NSString *const RCT_MLRN_OFFLINE_PROGRESS;
|
|
11
|
+
extern NSString *const RCT_MLRN_OFFLINE_ERROR;
|
|
12
|
+
extern NSString *const RCT_MLRN_OFFLINE_TILE_LIMIT;
|
|
14
13
|
|
|
15
|
-
extern NSString *const
|
|
16
|
-
extern NSString *const
|
|
17
|
-
extern NSString *const RCT_MAPBOX_DID_FAIL_LOADING_MAP;
|
|
14
|
+
extern NSString *const RCT_MLRN_SHAPE_SOURCE_LAYER_PRESS;
|
|
15
|
+
extern NSString *const RCT_MLRN_VECTOR_SOURCE_LAYER_PRESS;
|
|
18
16
|
|
|
19
|
-
extern NSString *const
|
|
20
|
-
extern NSString *const RCT_MAPBOX_DID_FINSIH_RENDERING_FRAME;
|
|
21
|
-
extern NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_FRAME_FULLY;
|
|
17
|
+
extern NSString *const RCT_MLRN_USER_LOCATION_UPDATE;
|
|
22
18
|
|
|
23
|
-
extern NSString *const
|
|
24
|
-
extern NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_MAP;
|
|
25
|
-
extern NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_MAP_FULLY;
|
|
26
|
-
|
|
27
|
-
extern NSString *const RCT_MAPBOX_DID_FINISH_LOADING_STYLE;
|
|
28
|
-
|
|
29
|
-
extern NSString *const RCT_MAPBOX_ANNOTATION_TAP;
|
|
30
|
-
|
|
31
|
-
extern NSString *const RCT_MAPBOX_OFFLINE_PROGRESS;
|
|
32
|
-
extern NSString *const RCT_MAPBOX_OFFLINE_ERROR;
|
|
33
|
-
extern NSString *const RCT_MAPBOX_OFFLINE_TILE_LIMIT;
|
|
34
|
-
|
|
35
|
-
extern NSString *const RCT_MAPBOX_SHAPE_SOURCE_LAYER_PRESS;
|
|
36
|
-
extern NSString *const RCT_MAPBOX_VECTOR_SOURCE_LAYER_PRESS;
|
|
37
|
-
|
|
38
|
-
extern NSString *const RCT_MAPBOX_USER_LOCATION_UPDATE;
|
|
39
|
-
|
|
40
|
-
extern NSString *const RCT_MAPBOX_IMAGES_MISSING_IMAGE;
|
|
19
|
+
extern NSString *const RCT_MLRN_MISSING_IMAGE;
|
|
41
20
|
|
|
42
21
|
@end
|