@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
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
forwardRef,
|
|
5
|
+
memo,
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from "react";
|
|
14
|
+
import {
|
|
15
|
+
findNodeHandle as rnFindNodeHandle,
|
|
16
|
+
type HostComponent,
|
|
17
|
+
type NativeMethods,
|
|
18
|
+
NativeModules,
|
|
19
|
+
type NativeSyntheticEvent,
|
|
20
|
+
requireNativeComponent,
|
|
21
|
+
StyleSheet,
|
|
22
|
+
View,
|
|
23
|
+
type ViewProps,
|
|
24
|
+
} from "react-native";
|
|
25
|
+
|
|
26
|
+
import NativeMapViewComponent, {
|
|
27
|
+
type NativeProps,
|
|
28
|
+
} from "./MapViewNativeComponent";
|
|
29
|
+
import NativeMapViewModule from "./NativeMapViewModule";
|
|
30
|
+
import { type BaseProps } from "../../types/BaseProps";
|
|
31
|
+
import type { Bounds } from "../../types/Bounds";
|
|
32
|
+
import { type FilterExpression } from "../../types/MapLibreRNStyles";
|
|
33
|
+
import type { PressEvent } from "../../types/PressEvent";
|
|
34
|
+
import type { ViewPadding } from "../../types/ViewPadding";
|
|
35
|
+
import { isAndroid } from "../../utils";
|
|
36
|
+
import { Logger } from "../../utils/Logger";
|
|
37
|
+
import { getFilter } from "../../utils/filterUtils";
|
|
38
|
+
|
|
39
|
+
const MLRNModule = NativeModules.MLRNModule;
|
|
40
|
+
if (MLRNModule == null) {
|
|
41
|
+
console.error(
|
|
42
|
+
"Native module of @maplibre/maplibre-react-native library was not registered properly, please consult the docs: https://github.com/maplibre/maplibre-react-native",
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const NativeAndroidTextureMapViewComponent = isAndroid()
|
|
47
|
+
? (requireNativeComponent<NativeProps>(
|
|
48
|
+
"MLRNAndroidTextureMapView",
|
|
49
|
+
) as HostComponent<NativeProps>)
|
|
50
|
+
: undefined;
|
|
51
|
+
|
|
52
|
+
const styles = StyleSheet.create({
|
|
53
|
+
matchParent: { flex: 1 },
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const findNodeHandle = (ref: Component | null) => {
|
|
57
|
+
const nodeHandle = rnFindNodeHandle(ref);
|
|
58
|
+
|
|
59
|
+
if (!nodeHandle) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
"NativeMapViewComponent ref is null, wait for the map being initialized",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return nodeHandle;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type OrnamentViewPosition =
|
|
69
|
+
| { top: number; left: number }
|
|
70
|
+
| { top: number; right: number }
|
|
71
|
+
| { bottom: number; right: number }
|
|
72
|
+
| { bottom: number; left: number };
|
|
73
|
+
|
|
74
|
+
export type ViewState = {
|
|
75
|
+
longitude: number;
|
|
76
|
+
latitude: number;
|
|
77
|
+
zoom: number;
|
|
78
|
+
bearing: number;
|
|
79
|
+
pitch: number;
|
|
80
|
+
bounds: Bounds;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type ViewStateChangeEvent = ViewState & {
|
|
84
|
+
animated: boolean;
|
|
85
|
+
userInteraction: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type QueryRenderedFeaturesOptions = {
|
|
89
|
+
filter?: FilterExpression;
|
|
90
|
+
layers?: string[];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export interface MapViewRef {
|
|
94
|
+
/**
|
|
95
|
+
* Returns the current center coordinates of the map
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* await mapViewRef.current?.getCenter();
|
|
99
|
+
*
|
|
100
|
+
* @return Current center coordinates of the map
|
|
101
|
+
*/
|
|
102
|
+
getCenter(): Promise<Pick<ViewState, "longitude" | "latitude">>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Returns the current zoom level of the map
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* await mapViewRef.current?.getZoom();
|
|
109
|
+
*
|
|
110
|
+
* @return Current zoom level of the map
|
|
111
|
+
*/
|
|
112
|
+
getZoom(): Promise<ViewState["zoom"]>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Returns the current bearing of the map
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* await mapViewRef.current?.getBearing();
|
|
119
|
+
*
|
|
120
|
+
* @return Current bearing of the map
|
|
121
|
+
*/
|
|
122
|
+
getBearing(): Promise<ViewState["bearing"]>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns the current pitch of the map
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* await mapViewRef.current?.getPitch();
|
|
129
|
+
*
|
|
130
|
+
* @return Current pitch of the map
|
|
131
|
+
*/
|
|
132
|
+
getPitch(): Promise<ViewState["pitch"]>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns the current bounds of the map
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* await mapViewRef.current?.getBounds();
|
|
139
|
+
*
|
|
140
|
+
* @return Current bounds of the map
|
|
141
|
+
*/
|
|
142
|
+
getBounds(): Promise<ViewState["bounds"]>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns the current view state of the map
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* await mapViewRef.current?.getViewState();
|
|
149
|
+
*
|
|
150
|
+
* @return Current view state of the map
|
|
151
|
+
*/
|
|
152
|
+
getViewState(): Promise<ViewState>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Converts a geographic coordinate to a pixel point of the view
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* await mapViewRef.current?.getPointInView([-37.817070, 144.949901]);
|
|
159
|
+
*
|
|
160
|
+
* @param coordinate Geographic coordinate
|
|
161
|
+
* @return Pixel point
|
|
162
|
+
*/
|
|
163
|
+
project(coordinate: {
|
|
164
|
+
longitude: number;
|
|
165
|
+
latitude: number;
|
|
166
|
+
}): Promise<{ locationX: number; locationY: number }>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Converts a pixel point of the view to a geographic coordinate.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* await mapViewRef.current?.getCoordinateFromView([100, 100]);
|
|
173
|
+
*
|
|
174
|
+
* @param point Pixel point
|
|
175
|
+
* @return Geographic coordinate
|
|
176
|
+
*/
|
|
177
|
+
unproject(point: {
|
|
178
|
+
locationX: number;
|
|
179
|
+
locationY: number;
|
|
180
|
+
}): Promise<{ longitude: number; latitude: number }>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Returns an array of rendered map features.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* await mapViewRef.current?.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])
|
|
187
|
+
*
|
|
188
|
+
* @param options.filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
|
|
189
|
+
* @param options.layers - A array of layer id's to filter the features by
|
|
190
|
+
* @return FeatureCollection containing queried features
|
|
191
|
+
*/
|
|
192
|
+
queryRenderedFeatures(
|
|
193
|
+
coordinate: { longitude: number; latitude: number },
|
|
194
|
+
options?: QueryRenderedFeaturesOptions,
|
|
195
|
+
): Promise<GeoJSON.FeatureCollection>;
|
|
196
|
+
queryRenderedFeatures(
|
|
197
|
+
bounds: Bounds,
|
|
198
|
+
options?: QueryRenderedFeaturesOptions,
|
|
199
|
+
): Promise<GeoJSON.FeatureCollection>;
|
|
200
|
+
queryRenderedFeatures(
|
|
201
|
+
options?: QueryRenderedFeaturesOptions,
|
|
202
|
+
): Promise<GeoJSON.FeatureCollection>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Takes snapshot of map with current tiles and returns a URI to the image
|
|
206
|
+
* @param writeToDisk If true will create a temp file, otherwise it is in base64
|
|
207
|
+
* @return URL of snapshot file or base64 encoded image
|
|
208
|
+
*/
|
|
209
|
+
takeSnap(writeToDisk?: boolean): Promise<string>;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Sets the visibility of all the layers referencing the specified `source` and optionally `sourceLayer`
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* await mapViewRef.current?.setSourceVisibility(false, 'composite', 'building')
|
|
216
|
+
*
|
|
217
|
+
* @param visible - Visibility of the layers
|
|
218
|
+
* @param source - Identifier of the target source (e.g. 'composite')
|
|
219
|
+
* @param sourceLayer - Identifier of the target source-layer (e.g. 'building')
|
|
220
|
+
*/
|
|
221
|
+
setSourceVisibility(
|
|
222
|
+
visible: boolean,
|
|
223
|
+
source: string,
|
|
224
|
+
sourceLayer?: string,
|
|
225
|
+
): Promise<void>;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Show the attribution action sheet, can be used to implement a
|
|
229
|
+
* custom attribution button
|
|
230
|
+
*/
|
|
231
|
+
showAttribution(): Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
interface MapViewProps extends BaseProps {
|
|
235
|
+
children?: ReactNode;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Style for wrapping React Native View
|
|
239
|
+
*/
|
|
240
|
+
style?: ViewProps["style"];
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The map's Maplibre style - either a URL or a Style JSON (https://maplibre.org/maplibre-style-spec/).
|
|
244
|
+
*
|
|
245
|
+
* @default "https://demotiles.maplibre.org/style.json"
|
|
246
|
+
*/
|
|
247
|
+
mapStyle?: string | object;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The distance from the edges of the map view’s frame to the edges of the map view’s logical viewport.
|
|
251
|
+
*/
|
|
252
|
+
contentInset?: ViewPadding;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* iOS: The preferred frame rate at which the map view is rendered.
|
|
256
|
+
* The default value for this property is MLNMapViewPreferredFramesPerSecondDefault,
|
|
257
|
+
* which will adaptively set the preferred frame rate based on the capability of
|
|
258
|
+
* the user’s device to maintain a smooth experience. This property can be set to arbitrary integer values.
|
|
259
|
+
*
|
|
260
|
+
* Android: The maximum frame rate at which the map view is rendered, but it can't excess the ability of device hardware.
|
|
261
|
+
* This property can be set to arbitrary integer values.
|
|
262
|
+
*/
|
|
263
|
+
preferredFramesPerSecond?: number;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Toggle pan interaction of the map
|
|
267
|
+
*
|
|
268
|
+
* @default true
|
|
269
|
+
*/
|
|
270
|
+
dragPan?: boolean;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Toggle zoom interaction of the map
|
|
274
|
+
*
|
|
275
|
+
* @default true
|
|
276
|
+
*/
|
|
277
|
+
touchAndDoubleTapZoom?: boolean;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Toggle rotate interaction of the map
|
|
281
|
+
*
|
|
282
|
+
* @default true
|
|
283
|
+
*/
|
|
284
|
+
touchRotate?: boolean;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Toggle pitch interaction of the map
|
|
288
|
+
*
|
|
289
|
+
* @default true
|
|
290
|
+
*/
|
|
291
|
+
touchPitch?: boolean;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Tints UI elements like the attribution button
|
|
295
|
+
*/
|
|
296
|
+
tintColor?: string;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Toggle the attribution button of the map
|
|
300
|
+
*/
|
|
301
|
+
attribution?: boolean;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Positions the attribution button
|
|
305
|
+
*
|
|
306
|
+
* @example Position in the top-left corner
|
|
307
|
+
* { top: 8, left: 8 }
|
|
308
|
+
*/
|
|
309
|
+
attributionPosition?: OrnamentViewPosition;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Toggle the logo on the map
|
|
313
|
+
*/
|
|
314
|
+
logo?: boolean;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Positions the logo
|
|
318
|
+
*
|
|
319
|
+
* @example Position in the top-left corner
|
|
320
|
+
* { top: 8, left: 8 }
|
|
321
|
+
*/
|
|
322
|
+
logoPosition?: OrnamentViewPosition;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Toggle the compass from appearing on the map
|
|
326
|
+
*/
|
|
327
|
+
compass?: boolean;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Positions the compass
|
|
331
|
+
*
|
|
332
|
+
* @example Position in the top-left corner
|
|
333
|
+
* { top: 8, left: 8 }
|
|
334
|
+
*/
|
|
335
|
+
compassPosition?: OrnamentViewPosition;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Android only: Switch between TextureView (default) and GLSurfaceView for
|
|
339
|
+
* rendering the map
|
|
340
|
+
*
|
|
341
|
+
* @default "surface"
|
|
342
|
+
*/
|
|
343
|
+
androidView?: "surface" | "texture";
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Called when a user presses the map
|
|
347
|
+
*/
|
|
348
|
+
onPress?: (event: NativeSyntheticEvent<PressEvent>) => void;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Called when a user long presses the map
|
|
352
|
+
*/
|
|
353
|
+
onLongPress?: (event: NativeSyntheticEvent<PressEvent>) => void;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Called when the currently displayed map region is about to change
|
|
357
|
+
*/
|
|
358
|
+
onRegionWillChange?: (
|
|
359
|
+
event: NativeSyntheticEvent<ViewStateChangeEvent>,
|
|
360
|
+
) => void;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Called when the currently displayed map region is changing
|
|
364
|
+
*/
|
|
365
|
+
onRegionIsChanging?: (
|
|
366
|
+
event: NativeSyntheticEvent<ViewStateChangeEvent>,
|
|
367
|
+
) => void;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Called when the currently displayed map region finished changing
|
|
371
|
+
*/
|
|
372
|
+
onRegionDidChange?: (
|
|
373
|
+
event: NativeSyntheticEvent<ViewStateChangeEvent>,
|
|
374
|
+
) => void;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Called when the map is about to start loading a new map style
|
|
378
|
+
*/
|
|
379
|
+
onWillStartLoadingMap?: (event: NativeSyntheticEvent<null>) => void;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Called when the map has successfully loaded a new map style
|
|
383
|
+
*/
|
|
384
|
+
onDidFinishLoadingMap?: (event: NativeSyntheticEvent<null>) => void;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Called when the map has failed to load a new map style
|
|
388
|
+
*/
|
|
389
|
+
onDidFailLoadingMap?: (event: NativeSyntheticEvent<null>) => void;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Called when the map will start rendering a frame
|
|
393
|
+
*/
|
|
394
|
+
onWillStartRenderingFrame?: (event: NativeSyntheticEvent<null>) => void;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Called when the map finished rendering a frame
|
|
398
|
+
*/
|
|
399
|
+
onDidFinishRenderingFrame?: (event: NativeSyntheticEvent<null>) => void;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Called when the map fully finished rendering a frame
|
|
403
|
+
*/
|
|
404
|
+
onDidFinishRenderingFrameFully?: (event: NativeSyntheticEvent<null>) => void;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Called when the map will start rendering itself
|
|
408
|
+
*/
|
|
409
|
+
onWillStartRenderingMap?: (event: NativeSyntheticEvent<null>) => void;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Called when the map has finished rendering itself
|
|
413
|
+
*/
|
|
414
|
+
onDidFinishRenderingMap?: (event: NativeSyntheticEvent<null>) => void;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Called when the map has fully finished rendering itself
|
|
418
|
+
*/
|
|
419
|
+
onDidFinishRenderingMapFully?: (event: NativeSyntheticEvent<null>) => void;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Triggered when a style has finished loading
|
|
423
|
+
*/
|
|
424
|
+
onDidFinishLoadingStyle?: (event: NativeSyntheticEvent<null>) => void;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* MapLibre Native MapView
|
|
429
|
+
*/
|
|
430
|
+
export const MapView = memo(
|
|
431
|
+
forwardRef<MapViewRef, MapViewProps>(
|
|
432
|
+
({ androidView = "surface", style, testID, ...props }, ref) => {
|
|
433
|
+
const [isReady, setIsReady] = useState(false);
|
|
434
|
+
|
|
435
|
+
const nativeRef = useRef<
|
|
436
|
+
Component<ComponentProps<typeof NativeMapViewComponent>> &
|
|
437
|
+
Readonly<NativeMethods>
|
|
438
|
+
>(null);
|
|
439
|
+
|
|
440
|
+
useImperativeHandle(ref, () => ({
|
|
441
|
+
getCenter: () =>
|
|
442
|
+
NativeMapViewModule.getCenter(findNodeHandle(nativeRef.current)),
|
|
443
|
+
|
|
444
|
+
getZoom: () =>
|
|
445
|
+
NativeMapViewModule.getZoom(findNodeHandle(nativeRef.current)),
|
|
446
|
+
|
|
447
|
+
getBearing: () =>
|
|
448
|
+
NativeMapViewModule.getBearing(findNodeHandle(nativeRef.current)),
|
|
449
|
+
|
|
450
|
+
getPitch: () =>
|
|
451
|
+
NativeMapViewModule.getPitch(findNodeHandle(nativeRef.current)),
|
|
452
|
+
|
|
453
|
+
getBounds: () =>
|
|
454
|
+
NativeMapViewModule.getBounds(
|
|
455
|
+
findNodeHandle(nativeRef.current),
|
|
456
|
+
) as Promise<Bounds>,
|
|
457
|
+
|
|
458
|
+
getViewState: () =>
|
|
459
|
+
NativeMapViewModule.getViewState(
|
|
460
|
+
findNodeHandle(nativeRef.current),
|
|
461
|
+
) as Promise<ViewState>,
|
|
462
|
+
|
|
463
|
+
project: (coordinate) =>
|
|
464
|
+
NativeMapViewModule.project(
|
|
465
|
+
findNodeHandle(nativeRef.current),
|
|
466
|
+
coordinate,
|
|
467
|
+
),
|
|
468
|
+
|
|
469
|
+
unproject: (point) =>
|
|
470
|
+
NativeMapViewModule.unproject(
|
|
471
|
+
findNodeHandle(nativeRef.current),
|
|
472
|
+
point,
|
|
473
|
+
),
|
|
474
|
+
|
|
475
|
+
queryRenderedFeatures: async (
|
|
476
|
+
geometryOrOptions?:
|
|
477
|
+
| { longitude: number; latitude: number }
|
|
478
|
+
| Bounds
|
|
479
|
+
| QueryRenderedFeaturesOptions,
|
|
480
|
+
options?: QueryRenderedFeaturesOptions,
|
|
481
|
+
) => {
|
|
482
|
+
if (
|
|
483
|
+
geometryOrOptions &&
|
|
484
|
+
"longitude" in geometryOrOptions &&
|
|
485
|
+
"latitude" in geometryOrOptions
|
|
486
|
+
) {
|
|
487
|
+
return (await NativeMapViewModule.queryRenderedFeaturesWithCoordinate(
|
|
488
|
+
findNodeHandle(nativeRef.current),
|
|
489
|
+
geometryOrOptions,
|
|
490
|
+
options?.layers ?? [],
|
|
491
|
+
getFilter(options?.filter),
|
|
492
|
+
)) as GeoJSON.FeatureCollection;
|
|
493
|
+
} else if (Array.isArray(geometryOrOptions)) {
|
|
494
|
+
return (await NativeMapViewModule.queryRenderedFeaturesWithBounds(
|
|
495
|
+
findNodeHandle(nativeRef.current),
|
|
496
|
+
geometryOrOptions,
|
|
497
|
+
options?.layers ?? [],
|
|
498
|
+
getFilter(options?.filter),
|
|
499
|
+
)) as GeoJSON.FeatureCollection;
|
|
500
|
+
} else {
|
|
501
|
+
return (await NativeMapViewModule.queryRenderedFeaturesWithBounds(
|
|
502
|
+
findNodeHandle(nativeRef.current),
|
|
503
|
+
// TODO: Solve this natively
|
|
504
|
+
await NativeMapViewModule.getBounds(
|
|
505
|
+
findNodeHandle(nativeRef.current),
|
|
506
|
+
),
|
|
507
|
+
options?.layers ?? [],
|
|
508
|
+
getFilter(options?.filter),
|
|
509
|
+
)) as GeoJSON.FeatureCollection;
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
|
|
513
|
+
takeSnap: (writeToDisk = false) =>
|
|
514
|
+
NativeMapViewModule.takeSnap(
|
|
515
|
+
findNodeHandle(nativeRef.current),
|
|
516
|
+
writeToDisk,
|
|
517
|
+
),
|
|
518
|
+
|
|
519
|
+
setSourceVisibility: (visible, source, sourceLayer) =>
|
|
520
|
+
NativeMapViewModule.setSourceVisibility(
|
|
521
|
+
findNodeHandle(nativeRef.current),
|
|
522
|
+
visible,
|
|
523
|
+
source,
|
|
524
|
+
sourceLayer ?? null,
|
|
525
|
+
),
|
|
526
|
+
|
|
527
|
+
showAttribution: () =>
|
|
528
|
+
NativeMapViewModule.showAttribution(
|
|
529
|
+
findNodeHandle(nativeRef.current),
|
|
530
|
+
),
|
|
531
|
+
}));
|
|
532
|
+
|
|
533
|
+
// Start before rendering
|
|
534
|
+
useLayoutEffect(() => {
|
|
535
|
+
Logger.sharedInstance().start();
|
|
536
|
+
|
|
537
|
+
return () => {
|
|
538
|
+
Logger.sharedInstance().stop();
|
|
539
|
+
};
|
|
540
|
+
}, []);
|
|
541
|
+
|
|
542
|
+
const nativeProps = useMemo(() => {
|
|
543
|
+
const { mapStyle, ...otherProps } = props;
|
|
544
|
+
|
|
545
|
+
let nativeMapStyle = undefined;
|
|
546
|
+
if (mapStyle) {
|
|
547
|
+
if (typeof mapStyle === "string") {
|
|
548
|
+
nativeMapStyle = mapStyle;
|
|
549
|
+
} else if (typeof mapStyle === "object") {
|
|
550
|
+
nativeMapStyle = JSON.stringify(mapStyle);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return {
|
|
555
|
+
...otherProps,
|
|
556
|
+
ref: nativeRef,
|
|
557
|
+
style: styles.matchParent,
|
|
558
|
+
mapStyle: nativeMapStyle,
|
|
559
|
+
};
|
|
560
|
+
}, [props]);
|
|
561
|
+
|
|
562
|
+
let mapView: ReactElement | null = null;
|
|
563
|
+
if (isReady) {
|
|
564
|
+
if (NativeAndroidTextureMapViewComponent && androidView === "texture") {
|
|
565
|
+
mapView = <NativeAndroidTextureMapViewComponent {...nativeProps} />;
|
|
566
|
+
} else {
|
|
567
|
+
mapView = <NativeMapViewComponent {...nativeProps} />;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return (
|
|
572
|
+
<View
|
|
573
|
+
onLayout={() => setIsReady(true)}
|
|
574
|
+
style={style}
|
|
575
|
+
testID={mapView ? undefined : testID}
|
|
576
|
+
>
|
|
577
|
+
{mapView}
|
|
578
|
+
</View>
|
|
579
|
+
);
|
|
580
|
+
},
|
|
581
|
+
),
|
|
582
|
+
);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ColorValue,
|
|
5
|
+
type HostComponent,
|
|
6
|
+
type ViewProps,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
|
|
9
|
+
import type { UnsafeMixed } from "../../types/codegen/UnsafeMixed";
|
|
10
|
+
|
|
11
|
+
type NativeViewPadding = {
|
|
12
|
+
top?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
13
|
+
right?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
14
|
+
bottom?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
15
|
+
left?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type NativeOrnamentViewPosition = {
|
|
19
|
+
top?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
20
|
+
right?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
21
|
+
bottom?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
22
|
+
left?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type NativePressEvent = {
|
|
26
|
+
longitude: CodegenTypes.Double;
|
|
27
|
+
latitude: CodegenTypes.Double;
|
|
28
|
+
locationX: CodegenTypes.Double;
|
|
29
|
+
locationY: CodegenTypes.Double;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type NativeViewStateEvent = {
|
|
33
|
+
longitude: CodegenTypes.Double;
|
|
34
|
+
latitude: CodegenTypes.Double;
|
|
35
|
+
zoom: CodegenTypes.Double;
|
|
36
|
+
bearing: CodegenTypes.Double;
|
|
37
|
+
pitch: CodegenTypes.Double;
|
|
38
|
+
bounds: UnsafeMixed<
|
|
39
|
+
[
|
|
40
|
+
west: CodegenTypes.Double,
|
|
41
|
+
south: CodegenTypes.Double,
|
|
42
|
+
east: CodegenTypes.Double,
|
|
43
|
+
north: CodegenTypes.Double,
|
|
44
|
+
]
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
|
+
animated: boolean;
|
|
48
|
+
userInteraction: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export interface NativeProps extends ViewProps {
|
|
52
|
+
mapStyle?: string;
|
|
53
|
+
contentInset?: NativeViewPadding;
|
|
54
|
+
preferredFramesPerSecond?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
55
|
+
|
|
56
|
+
dragPan?: CodegenTypes.WithDefault<boolean, true>;
|
|
57
|
+
touchAndDoubleTapZoom?: CodegenTypes.WithDefault<boolean, true>;
|
|
58
|
+
touchRotate?: CodegenTypes.WithDefault<boolean, true>;
|
|
59
|
+
touchPitch?: CodegenTypes.WithDefault<boolean, true>;
|
|
60
|
+
|
|
61
|
+
tintColor?: ColorValue | undefined;
|
|
62
|
+
|
|
63
|
+
attribution?: CodegenTypes.WithDefault<boolean, true>;
|
|
64
|
+
attributionPosition?: NativeOrnamentViewPosition;
|
|
65
|
+
|
|
66
|
+
logo?: CodegenTypes.WithDefault<boolean, true>;
|
|
67
|
+
logoPosition?: NativeOrnamentViewPosition;
|
|
68
|
+
|
|
69
|
+
compass?: CodegenTypes.WithDefault<boolean, false>;
|
|
70
|
+
compassPosition?: NativeOrnamentViewPosition;
|
|
71
|
+
|
|
72
|
+
onPress?: CodegenTypes.BubblingEventHandler<NativePressEvent>;
|
|
73
|
+
onLongPress?: CodegenTypes.BubblingEventHandler<NativePressEvent>;
|
|
74
|
+
|
|
75
|
+
onRegionWillChange?: CodegenTypes.DirectEventHandler<NativeViewStateEvent>;
|
|
76
|
+
onRegionIsChanging?: CodegenTypes.DirectEventHandler<NativeViewStateEvent>;
|
|
77
|
+
onRegionDidChange?: CodegenTypes.DirectEventHandler<NativeViewStateEvent>;
|
|
78
|
+
|
|
79
|
+
onWillStartLoadingMap?: CodegenTypes.DirectEventHandler<null>;
|
|
80
|
+
onDidFinishLoadingMap?: CodegenTypes.DirectEventHandler<null>;
|
|
81
|
+
onDidFailLoadingMap?: CodegenTypes.DirectEventHandler<null>;
|
|
82
|
+
|
|
83
|
+
onWillStartRenderingFrame?: CodegenTypes.DirectEventHandler<null>;
|
|
84
|
+
onDidFinishRenderingFrame?: CodegenTypes.DirectEventHandler<null>;
|
|
85
|
+
onDidFinishRenderingFrameFully?: CodegenTypes.DirectEventHandler<null>;
|
|
86
|
+
|
|
87
|
+
onWillStartRenderingMap?: CodegenTypes.DirectEventHandler<null>;
|
|
88
|
+
onDidFinishRenderingMap?: CodegenTypes.DirectEventHandler<null>;
|
|
89
|
+
onDidFinishRenderingMapFully?: CodegenTypes.DirectEventHandler<null>;
|
|
90
|
+
|
|
91
|
+
onDidFinishLoadingStyle?: CodegenTypes.DirectEventHandler<null>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default codegenNativeComponent<NativeProps>(
|
|
95
|
+
"MLRNMapView",
|
|
96
|
+
) as HostComponent<NativeProps>;
|