@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
|
@@ -1,838 +0,0 @@
|
|
|
1
|
-
import debounce from "debounce";
|
|
2
|
-
import {
|
|
3
|
-
Component,
|
|
4
|
-
forwardRef,
|
|
5
|
-
memo,
|
|
6
|
-
type ReactElement,
|
|
7
|
-
type ReactNode,
|
|
8
|
-
useCallback,
|
|
9
|
-
useEffect,
|
|
10
|
-
useImperativeHandle,
|
|
11
|
-
useMemo,
|
|
12
|
-
useRef,
|
|
13
|
-
useState,
|
|
14
|
-
} from "react";
|
|
15
|
-
import {
|
|
16
|
-
View,
|
|
17
|
-
StyleSheet,
|
|
18
|
-
NativeModules,
|
|
19
|
-
requireNativeComponent,
|
|
20
|
-
type ViewProps,
|
|
21
|
-
type NativeMethods,
|
|
22
|
-
type NativeSyntheticEvent,
|
|
23
|
-
} from "react-native";
|
|
24
|
-
|
|
25
|
-
import { useNativeBridge } from "../hooks/useNativeBridge";
|
|
26
|
-
import { useOnce } from "../hooks/useOnce";
|
|
27
|
-
import { type Location } from "../modules/location/LocationManager";
|
|
28
|
-
import { type BaseProps } from "../types/BaseProps";
|
|
29
|
-
import { type FilterExpression } from "../types/MapLibreRNStyles";
|
|
30
|
-
import { isFunction, isAndroid } from "../utils";
|
|
31
|
-
import { Logger } from "../utils/Logger";
|
|
32
|
-
import { getFilter } from "../utils/filterUtils";
|
|
33
|
-
|
|
34
|
-
const MLRNModule = NativeModules.MLRNModule;
|
|
35
|
-
if (MLRNModule == null) {
|
|
36
|
-
console.error(
|
|
37
|
-
"Native module of @maplibre/maplibre-react-native library was not registered properly, please consult the docs: https://github.com/maplibre/maplibre-react-native",
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const NATIVE_MODULE_NAME = "MLRNMapView";
|
|
42
|
-
|
|
43
|
-
export const ANDROID_TEXTURE_NATIVE_MODULE_NAME = "MLRNAndroidTextureMapView";
|
|
44
|
-
|
|
45
|
-
const styles = StyleSheet.create({
|
|
46
|
-
matchParent: { flex: 1 },
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export interface RegionPayload {
|
|
50
|
-
zoomLevel: number;
|
|
51
|
-
heading: number;
|
|
52
|
-
animated: boolean;
|
|
53
|
-
isUserInteraction: boolean;
|
|
54
|
-
visibleBounds: VisibleBounds;
|
|
55
|
-
pitch: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type RegionPayloadFeature = GeoJSON.Feature<GeoJSON.Point, RegionPayload>;
|
|
59
|
-
|
|
60
|
-
type VisibleBounds = [northEast: GeoJSON.Position, southWest: GeoJSON.Position];
|
|
61
|
-
|
|
62
|
-
interface MapViewProps extends BaseProps {
|
|
63
|
-
/**
|
|
64
|
-
* The distance from the edges of the map view’s frame to the edges of the map view’s logical viewport.
|
|
65
|
-
*/
|
|
66
|
-
contentInset?: number[] | number;
|
|
67
|
-
/**
|
|
68
|
-
* Style for wrapping React Native View
|
|
69
|
-
*/
|
|
70
|
-
style?: ViewProps["style"];
|
|
71
|
-
/**
|
|
72
|
-
* Style for map - either a URL or a Style JSON (https://maplibre.org/maplibre-style-spec/). Default: `StyleURL.Default`
|
|
73
|
-
*/
|
|
74
|
-
mapStyle?: string | object;
|
|
75
|
-
/**
|
|
76
|
-
* iOS: The preferred frame rate at which the map view is rendered.
|
|
77
|
-
* The default value for this property is MLNMapViewPreferredFramesPerSecondDefault,
|
|
78
|
-
* which will adaptively set the preferred frame rate based on the capability of
|
|
79
|
-
* the user’s device to maintain a smooth experience. This property can be set to arbitrary integer values.
|
|
80
|
-
*
|
|
81
|
-
* Android: The maximum frame rate at which the map view is rendered, but it can't excess the ability of device hardware.
|
|
82
|
-
* This property can be set to arbitrary integer values.
|
|
83
|
-
*/
|
|
84
|
-
preferredFramesPerSecond?: number;
|
|
85
|
-
/**
|
|
86
|
-
* Automatically change the language of the map labels to the system’s preferred language,
|
|
87
|
-
* this is not something that can be toggled on/off
|
|
88
|
-
*/
|
|
89
|
-
localizeLabels?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Enable/Disable zoom on the map
|
|
92
|
-
*/
|
|
93
|
-
zoomEnabled?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Enable/Disable scroll on the map
|
|
96
|
-
*/
|
|
97
|
-
scrollEnabled?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Enable/Disable pitch on map
|
|
100
|
-
*/
|
|
101
|
-
pitchEnabled?: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Enable/Disable rotation on map
|
|
104
|
-
*/
|
|
105
|
-
rotateEnabled?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Enable/Disable attribution on map
|
|
108
|
-
*/
|
|
109
|
-
attributionEnabled?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Adds attribution offset, e.g. `{top: 8, left: 8}` will put attribution button in top-left corner of the map
|
|
112
|
-
*/
|
|
113
|
-
attributionPosition?:
|
|
114
|
-
| { top?: number; left?: number }
|
|
115
|
-
| { top?: number; right?: number }
|
|
116
|
-
| { bottom?: number; left?: number }
|
|
117
|
-
| { bottom?: number; right?: number };
|
|
118
|
-
/**
|
|
119
|
-
* MapView's tintColor
|
|
120
|
-
*/
|
|
121
|
-
tintColor?: string | unknown[];
|
|
122
|
-
/**
|
|
123
|
-
* Enable/Disable the logo on the map.
|
|
124
|
-
*/
|
|
125
|
-
logoEnabled?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Adds logo offset, e.g. `{top: 8, left: 8}` will put the logo in top-left corner of the map
|
|
128
|
-
*/
|
|
129
|
-
logoPosition?:
|
|
130
|
-
| { top?: number; left?: number }
|
|
131
|
-
| { top?: number; right?: number }
|
|
132
|
-
| { bottom?: number; left?: number }
|
|
133
|
-
| { bottom?: number; right?: number };
|
|
134
|
-
/**
|
|
135
|
-
* Enable/Disable the compass from appearing on the map
|
|
136
|
-
*/
|
|
137
|
-
compassEnabled?: boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Change corner of map the compass starts at. 0: TopLeft, 1: TopRight, 2: BottomLeft, 3: BottomRight
|
|
140
|
-
*/
|
|
141
|
-
compassViewPosition?: number;
|
|
142
|
-
/**
|
|
143
|
-
* Add margins to the compass with x and y values
|
|
144
|
-
*/
|
|
145
|
-
compassViewMargins?: object;
|
|
146
|
-
/**
|
|
147
|
-
* [Android only] Enable/Disable use of GLSurfaceView instead of TextureView
|
|
148
|
-
*/
|
|
149
|
-
surfaceView?: boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Map press listener, gets called when a user presses the map
|
|
152
|
-
*/
|
|
153
|
-
onPress?: (feature: GeoJSON.Feature) => void;
|
|
154
|
-
/**
|
|
155
|
-
* Map long press listener, gets called when a user long presses the map
|
|
156
|
-
*/
|
|
157
|
-
onLongPress?: (feature: GeoJSON.Feature) => void;
|
|
158
|
-
/**
|
|
159
|
-
* Triggered when the currently displayed map region is about to change
|
|
160
|
-
*/
|
|
161
|
-
onRegionWillChange?: (feature: RegionPayloadFeature) => void;
|
|
162
|
-
/**
|
|
163
|
-
* Triggered when the currently displayed map region is changing
|
|
164
|
-
*/
|
|
165
|
-
onRegionIsChanging?: (feature: RegionPayloadFeature) => void;
|
|
166
|
-
/**
|
|
167
|
-
* Triggered when the currently displayed map region finished changing
|
|
168
|
-
*/
|
|
169
|
-
onRegionDidChange?: (feature: RegionPayloadFeature) => void;
|
|
170
|
-
/**
|
|
171
|
-
* Triggered when the map is about to start loading a new map style
|
|
172
|
-
*/
|
|
173
|
-
onWillStartLoadingMap?: () => void;
|
|
174
|
-
/**
|
|
175
|
-
* This is triggered when the map has successfully loaded a new map style
|
|
176
|
-
*/
|
|
177
|
-
onDidFinishLoadingMap?: () => void;
|
|
178
|
-
/**
|
|
179
|
-
* Triggered when the map has failed to load a new map style
|
|
180
|
-
*/
|
|
181
|
-
onDidFailLoadingMap?: () => void;
|
|
182
|
-
/**
|
|
183
|
-
* Triggered when the map will start rendering a frame
|
|
184
|
-
*/
|
|
185
|
-
onWillStartRenderingFrame?: () => void;
|
|
186
|
-
/**
|
|
187
|
-
* Triggered when the map finished rendering a frame
|
|
188
|
-
*/
|
|
189
|
-
onDidFinishRenderingFrame?: () => void;
|
|
190
|
-
/**
|
|
191
|
-
* Triggered when the map fully finished rendering a frame
|
|
192
|
-
*/
|
|
193
|
-
onDidFinishRenderingFrameFully?: () => void;
|
|
194
|
-
/**
|
|
195
|
-
* Triggered when the map will start rendering the map
|
|
196
|
-
*/
|
|
197
|
-
onWillStartRenderingMap?: () => void;
|
|
198
|
-
/**
|
|
199
|
-
* Triggered when the map finished rendering the map
|
|
200
|
-
*/
|
|
201
|
-
onDidFinishRenderingMap?: () => void;
|
|
202
|
-
/**
|
|
203
|
-
* Triggered when the map fully finished rendering the map
|
|
204
|
-
*/
|
|
205
|
-
onDidFinishRenderingMapFully?: () => void;
|
|
206
|
-
/**
|
|
207
|
-
* Triggered when the user location is updated
|
|
208
|
-
*/
|
|
209
|
-
onUserLocationUpdate?: (location: Location) => void;
|
|
210
|
-
/**
|
|
211
|
-
* Triggered when a style has finished loading
|
|
212
|
-
*/
|
|
213
|
-
onDidFinishLoadingStyle?: () => void;
|
|
214
|
-
/**
|
|
215
|
-
* Emitted frequency of regionWillChange events
|
|
216
|
-
*/
|
|
217
|
-
regionWillChangeDebounceTime?: number;
|
|
218
|
-
/**
|
|
219
|
-
* Emitted frequency of regionDidChange events
|
|
220
|
-
*/
|
|
221
|
-
regionDidChangeDebounceTime?: number;
|
|
222
|
-
|
|
223
|
-
children?: ReactNode;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
type Fn = (...args: any) => any;
|
|
227
|
-
type CallableProps = {
|
|
228
|
-
[Prop in keyof MapViewProps]-?: MapViewProps[Prop] extends Fn | undefined
|
|
229
|
-
? Prop
|
|
230
|
-
: never;
|
|
231
|
-
}[keyof MapViewProps];
|
|
232
|
-
|
|
233
|
-
interface NativeProps extends Omit<MapViewProps, "onPress" | "onLongPress"> {
|
|
234
|
-
mapStyle?: string;
|
|
235
|
-
onPress(event: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>): void;
|
|
236
|
-
onLongPress(event: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>): void;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export interface MapViewRef {
|
|
240
|
-
getPointInView: (
|
|
241
|
-
coordinate: GeoJSON.Position,
|
|
242
|
-
) => Promise<[x: number, y: number]>;
|
|
243
|
-
getCoordinateFromView: (
|
|
244
|
-
point: [x: number, y: number],
|
|
245
|
-
) => Promise<GeoJSON.Position>;
|
|
246
|
-
getVisibleBounds: () => Promise<VisibleBounds>;
|
|
247
|
-
queryRenderedFeaturesAtPoint: (
|
|
248
|
-
point: [screenPointX: number, screenPointY: number],
|
|
249
|
-
filter: FilterExpression | undefined,
|
|
250
|
-
layerIDs: string[],
|
|
251
|
-
) => Promise<GeoJSON.FeatureCollection>;
|
|
252
|
-
queryRenderedFeaturesInRect: (
|
|
253
|
-
bbox: GeoJSON.BBox,
|
|
254
|
-
filter: FilterExpression | undefined,
|
|
255
|
-
layerIDs: string[],
|
|
256
|
-
) => Promise<GeoJSON.FeatureCollection>;
|
|
257
|
-
takeSnap: (writeToDisk?: boolean) => Promise<string>;
|
|
258
|
-
getZoom: () => Promise<number>;
|
|
259
|
-
getCenter: () => Promise<GeoJSON.Position>;
|
|
260
|
-
setSourceVisibility: (
|
|
261
|
-
visible: boolean,
|
|
262
|
-
sourceId: string,
|
|
263
|
-
sourceLayerId?: string | null,
|
|
264
|
-
) => void;
|
|
265
|
-
showAttribution: () => Promise<void>;
|
|
266
|
-
setNativeProps: (props: NativeProps) => void;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* MapView backed by MapLibre Native
|
|
271
|
-
*/
|
|
272
|
-
export const MapView = memo(
|
|
273
|
-
forwardRef<MapViewRef, MapViewProps>(
|
|
274
|
-
(
|
|
275
|
-
{
|
|
276
|
-
localizeLabels = false,
|
|
277
|
-
scrollEnabled = true,
|
|
278
|
-
pitchEnabled = true,
|
|
279
|
-
rotateEnabled = true,
|
|
280
|
-
attributionEnabled = true,
|
|
281
|
-
logoEnabled = false,
|
|
282
|
-
surfaceView = false,
|
|
283
|
-
regionWillChangeDebounceTime = 10,
|
|
284
|
-
regionDidChangeDebounceTime = 500,
|
|
285
|
-
...props
|
|
286
|
-
}: MapViewProps,
|
|
287
|
-
ref,
|
|
288
|
-
) => {
|
|
289
|
-
// * exposes the methods of the function component so we don't break projects that depend on calling this methods
|
|
290
|
-
useImperativeHandle(
|
|
291
|
-
ref,
|
|
292
|
-
(): MapViewRef => ({
|
|
293
|
-
/**
|
|
294
|
-
* Converts a geographic coordinate to a pixel point of the view.
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* const pointInView = await mapViewRef.current?.getPointInView([-37.817070, 144.949901]);
|
|
298
|
-
*
|
|
299
|
-
* @param {GeoJSON.Position} coordinate Geographic coordinate
|
|
300
|
-
* @return {[x: number, y: number]} Pixel point
|
|
301
|
-
*/
|
|
302
|
-
getPointInView,
|
|
303
|
-
/**
|
|
304
|
-
* Converts a pixel point of the view to a geographic coordinate.
|
|
305
|
-
*
|
|
306
|
-
* @example
|
|
307
|
-
* const coordinate = await mapViewRef.current?.getCoordinateFromView([100, 100]);
|
|
308
|
-
*
|
|
309
|
-
* @param {[x: number, y: number]} point Pixel point
|
|
310
|
-
* @return {GeoJSON.Position} Geographic coordinate
|
|
311
|
-
*/
|
|
312
|
-
getCoordinateFromView,
|
|
313
|
-
/**
|
|
314
|
-
* The coordinate bounds(ne, sw) visible in the users’s viewport.
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* const visibleBounds = await this._map.getVisibleBounds();
|
|
318
|
-
*
|
|
319
|
-
* @return {Array}
|
|
320
|
-
*/
|
|
321
|
-
getVisibleBounds,
|
|
322
|
-
/**
|
|
323
|
-
* Returns an array of rendered map features that intersect with a given point.
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* this._map.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])
|
|
327
|
-
*
|
|
328
|
-
* @param {number[]} coordinate - A point expressed in the map view’s coordinate system.
|
|
329
|
-
* @param {Array=} 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.
|
|
330
|
-
* @param {Array=} layerIDs - A array of layer id's to filter the features by
|
|
331
|
-
* @return {GeoJSON.FeatureCollection}
|
|
332
|
-
*/
|
|
333
|
-
queryRenderedFeaturesAtPoint,
|
|
334
|
-
/**
|
|
335
|
-
* Returns an array of rendered map features that intersect with the given rectangle,
|
|
336
|
-
* restricted to the given style layers and filtered by the given predicate.
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
|
|
340
|
-
*
|
|
341
|
-
* @param {number[]} bbox - A rectangle expressed in the map view’s coordinate system.
|
|
342
|
-
* @param {Array=} 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.
|
|
343
|
-
* @param {Array=} layerIDs - A array of layer id's to filter the features by
|
|
344
|
-
* @return {GeoJSON.FeatureCollection}
|
|
345
|
-
*/
|
|
346
|
-
queryRenderedFeaturesInRect,
|
|
347
|
-
/**
|
|
348
|
-
* Takes snapshot of map with current tiles and returns a URI to the image
|
|
349
|
-
* @param {boolean} writeToDisk If true will create a temp file, otherwise it is in base64
|
|
350
|
-
* @return {string}
|
|
351
|
-
*/
|
|
352
|
-
takeSnap,
|
|
353
|
-
/**
|
|
354
|
-
* Returns the current zoom of the map view.
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* const zoom = await this._map.getZoom();
|
|
358
|
-
*
|
|
359
|
-
* @return {number}
|
|
360
|
-
*/
|
|
361
|
-
getZoom,
|
|
362
|
-
/**
|
|
363
|
-
* Returns the map's geographical centerpoint
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* const center = await this._map.getCenter();
|
|
367
|
-
*
|
|
368
|
-
* @return {number[]} Coordinates
|
|
369
|
-
*/
|
|
370
|
-
getCenter,
|
|
371
|
-
/**
|
|
372
|
-
* Sets the visibility of all the layers referencing the specified `sourceLayerId` and/or `sourceId`
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* await this._map.setSourceVisibility(false, 'composite', 'building')
|
|
376
|
-
*
|
|
377
|
-
* @param {boolean} visible - Visibility of the layers
|
|
378
|
-
* @param {string} sourceId - Identifier of the target source (e.g. 'composite')
|
|
379
|
-
* @param {string=} sourceLayerId - Identifier of the target source-layer (e.g. 'building')
|
|
380
|
-
*/
|
|
381
|
-
setSourceVisibility,
|
|
382
|
-
/**
|
|
383
|
-
* Show the attribution and telemetry action sheet.
|
|
384
|
-
* If you implement a custom attribution button, you should add this action to the button.
|
|
385
|
-
*/
|
|
386
|
-
showAttribution,
|
|
387
|
-
setNativeProps,
|
|
388
|
-
}),
|
|
389
|
-
);
|
|
390
|
-
|
|
391
|
-
const {
|
|
392
|
-
_runNativeCommand,
|
|
393
|
-
_runPendingNativeCommands,
|
|
394
|
-
_onAndroidCallback,
|
|
395
|
-
} = useNativeBridge(NATIVE_MODULE_NAME);
|
|
396
|
-
const logger = useRef<Logger>(Logger.sharedInstance());
|
|
397
|
-
// * start the logger before anyuseEffect
|
|
398
|
-
useOnce(() => {
|
|
399
|
-
logger.current.start();
|
|
400
|
-
});
|
|
401
|
-
const _nativeRef = useRef<MLRNMapViewRefType>(null);
|
|
402
|
-
const [isReady, setIsReady] = useState(false);
|
|
403
|
-
|
|
404
|
-
// Cleanups on unmount
|
|
405
|
-
useEffect(() => {
|
|
406
|
-
const currentLogger = logger.current;
|
|
407
|
-
|
|
408
|
-
return (): void => {
|
|
409
|
-
_onDebouncedRegionWillChange.clear();
|
|
410
|
-
_onDebouncedRegionDidChange.clear();
|
|
411
|
-
currentLogger.stop();
|
|
412
|
-
};
|
|
413
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
414
|
-
}, []);
|
|
415
|
-
|
|
416
|
-
// This will run on every render
|
|
417
|
-
// so similar to componentDidMount and UNSAFE_componentWillReceiveProps
|
|
418
|
-
useEffect(() => {
|
|
419
|
-
_setHandledMapChangedEvents(props);
|
|
420
|
-
}, [props]);
|
|
421
|
-
|
|
422
|
-
const _setHandledMapChangedEvents = (props: MapViewProps): void => {
|
|
423
|
-
if (isAndroid()) {
|
|
424
|
-
const events = [];
|
|
425
|
-
|
|
426
|
-
if (props.onRegionWillChange) {
|
|
427
|
-
events.push(MLRNModule.EventTypes.RegionWillChange);
|
|
428
|
-
}
|
|
429
|
-
if (props.onRegionIsChanging) {
|
|
430
|
-
events.push(MLRNModule.EventTypes.RegionIsChanging);
|
|
431
|
-
}
|
|
432
|
-
if (props.onRegionDidChange) {
|
|
433
|
-
events.push(MLRNModule.EventTypes.RegionDidChange);
|
|
434
|
-
}
|
|
435
|
-
if (props.onUserLocationUpdate) {
|
|
436
|
-
events.push(MLRNModule.EventTypes.UserLocationUpdated);
|
|
437
|
-
}
|
|
438
|
-
if (props.onWillStartLoadingMap) {
|
|
439
|
-
events.push(MLRNModule.EventTypes.WillStartLoadingMap);
|
|
440
|
-
}
|
|
441
|
-
if (props.onDidFinishLoadingMap) {
|
|
442
|
-
events.push(MLRNModule.EventTypes.DidFinishLoadingMap);
|
|
443
|
-
}
|
|
444
|
-
if (props.onDidFailLoadingMap) {
|
|
445
|
-
events.push(MLRNModule.EventTypes.DidFailLoadingMap);
|
|
446
|
-
}
|
|
447
|
-
if (props.onWillStartRenderingFrame) {
|
|
448
|
-
events.push(MLRNModule.EventTypes.WillStartRenderingFrame);
|
|
449
|
-
}
|
|
450
|
-
if (props.onDidFinishRenderingFrame) {
|
|
451
|
-
events.push(MLRNModule.EventTypes.DidFinishRenderingFrame);
|
|
452
|
-
}
|
|
453
|
-
if (props.onDidFinishRenderingFrameFully) {
|
|
454
|
-
events.push(MLRNModule.EventTypes.DidFinishRenderingFrameFully);
|
|
455
|
-
}
|
|
456
|
-
if (props.onWillStartRenderingMap) {
|
|
457
|
-
events.push(MLRNModule.EventTypes.WillStartRenderingMap);
|
|
458
|
-
}
|
|
459
|
-
if (props.onDidFinishRenderingMap) {
|
|
460
|
-
events.push(MLRNModule.EventTypes.DidFinishRenderingMap);
|
|
461
|
-
}
|
|
462
|
-
if (props.onDidFinishRenderingMapFully) {
|
|
463
|
-
events.push(MLRNModule.EventTypes.DidFinishRenderingMapFully);
|
|
464
|
-
}
|
|
465
|
-
if (props.onDidFinishLoadingStyle) {
|
|
466
|
-
events.push(MLRNModule.EventTypes.DidFinishLoadingStyle);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
_runNativeCommand(
|
|
470
|
-
"setHandledMapChangedEvents",
|
|
471
|
-
_nativeRef.current,
|
|
472
|
-
events,
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
const getPointInView = async (
|
|
478
|
-
coordinate: GeoJSON.Position,
|
|
479
|
-
): Promise<[x: number, y: number]> => {
|
|
480
|
-
const res: { pointInView: [x: number, y: number] } =
|
|
481
|
-
await _runNativeCommand("getPointInView", _nativeRef.current, [
|
|
482
|
-
coordinate,
|
|
483
|
-
]);
|
|
484
|
-
|
|
485
|
-
return res.pointInView;
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
const getCoordinateFromView = async (
|
|
489
|
-
point: [x: number, y: number],
|
|
490
|
-
): Promise<GeoJSON.Position> => {
|
|
491
|
-
const res: { coordinateFromView: GeoJSON.Position } =
|
|
492
|
-
await _runNativeCommand("getCoordinateFromView", _nativeRef.current, [
|
|
493
|
-
point,
|
|
494
|
-
]);
|
|
495
|
-
|
|
496
|
-
return res.coordinateFromView;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
const getVisibleBounds = async (): Promise<VisibleBounds> => {
|
|
500
|
-
const res: { visibleBounds: VisibleBounds } = await _runNativeCommand(
|
|
501
|
-
"getVisibleBounds",
|
|
502
|
-
_nativeRef.current,
|
|
503
|
-
);
|
|
504
|
-
return res.visibleBounds;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
const queryRenderedFeaturesAtPoint = async (
|
|
508
|
-
point: [screenPointX: number, screenPointY: number],
|
|
509
|
-
filter?: FilterExpression,
|
|
510
|
-
layerIDs: string[] = [],
|
|
511
|
-
): Promise<GeoJSON.FeatureCollection> => {
|
|
512
|
-
if (!point || point.length < 2) {
|
|
513
|
-
throw new Error(
|
|
514
|
-
"Must pass in valid point in the map view's cooridnate system[x, y]",
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
519
|
-
await _runNativeCommand(
|
|
520
|
-
"queryRenderedFeaturesAtPoint",
|
|
521
|
-
_nativeRef.current,
|
|
522
|
-
[point, getFilter(filter), layerIDs],
|
|
523
|
-
);
|
|
524
|
-
|
|
525
|
-
if (isAndroid()) {
|
|
526
|
-
return JSON.parse(res.data as string);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
return res.data as GeoJSON.FeatureCollection;
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
const queryRenderedFeaturesInRect = async (
|
|
533
|
-
bbox: GeoJSON.BBox,
|
|
534
|
-
filter?: FilterExpression,
|
|
535
|
-
layerIDs: string[] = [],
|
|
536
|
-
): Promise<GeoJSON.FeatureCollection> => {
|
|
537
|
-
if (!bbox || bbox.length !== 4) {
|
|
538
|
-
throw new Error(
|
|
539
|
-
"Must pass in a valid bounding box[top, right, bottom, left]",
|
|
540
|
-
);
|
|
541
|
-
}
|
|
542
|
-
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
543
|
-
await _runNativeCommand(
|
|
544
|
-
"queryRenderedFeaturesInRect",
|
|
545
|
-
_nativeRef.current,
|
|
546
|
-
[bbox, getFilter(filter), layerIDs],
|
|
547
|
-
);
|
|
548
|
-
|
|
549
|
-
if (isAndroid()) {
|
|
550
|
-
return JSON.parse(res.data as string);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
return res.data as GeoJSON.FeatureCollection;
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
const takeSnap = async (writeToDisk = false): Promise<string> => {
|
|
557
|
-
const res: { uri: string } = await _runNativeCommand(
|
|
558
|
-
"takeSnap",
|
|
559
|
-
_nativeRef.current,
|
|
560
|
-
[writeToDisk],
|
|
561
|
-
);
|
|
562
|
-
return res.uri;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
const getZoom = async (): Promise<number> => {
|
|
566
|
-
const res: { zoom: number } = await _runNativeCommand(
|
|
567
|
-
"getZoom",
|
|
568
|
-
_nativeRef.current,
|
|
569
|
-
);
|
|
570
|
-
return res.zoom;
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
const getCenter = async (): Promise<GeoJSON.Position> => {
|
|
574
|
-
const res: { center: GeoJSON.Position } = await _runNativeCommand(
|
|
575
|
-
"getCenter",
|
|
576
|
-
_nativeRef.current,
|
|
577
|
-
);
|
|
578
|
-
return res.center;
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
const setSourceVisibility = (
|
|
582
|
-
visible: boolean,
|
|
583
|
-
sourceId: string,
|
|
584
|
-
sourceLayerId: string | null = null,
|
|
585
|
-
): void => {
|
|
586
|
-
_runNativeCommand("setSourceVisibility", _nativeRef.current, [
|
|
587
|
-
visible,
|
|
588
|
-
sourceId,
|
|
589
|
-
sourceLayerId,
|
|
590
|
-
]);
|
|
591
|
-
};
|
|
592
|
-
|
|
593
|
-
const showAttribution = async (): Promise<void> => {
|
|
594
|
-
_runNativeCommand("showAttribution", _nativeRef.current);
|
|
595
|
-
};
|
|
596
|
-
|
|
597
|
-
const _onPress = (
|
|
598
|
-
e: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>,
|
|
599
|
-
): void => {
|
|
600
|
-
if (isFunction(props.onPress)) {
|
|
601
|
-
props.onPress(e.nativeEvent.payload);
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
const _onLongPress = (
|
|
606
|
-
e: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>,
|
|
607
|
-
): void => {
|
|
608
|
-
if (isFunction(props.onLongPress)) {
|
|
609
|
-
props.onLongPress(e.nativeEvent.payload);
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
const _onRegionWillChange = (payload: RegionPayloadFeature): void => {
|
|
614
|
-
if (isFunction(props.onRegionWillChange)) {
|
|
615
|
-
props.onRegionWillChange(payload);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
const _onRegionDidChange = (payload: RegionPayloadFeature): void => {
|
|
620
|
-
if (isFunction(props.onRegionDidChange)) {
|
|
621
|
-
props.onRegionDidChange(payload);
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
const _onDebouncedRegionWillChange = useCallback(
|
|
626
|
-
debounce(_onRegionWillChange, regionWillChangeDebounceTime, {
|
|
627
|
-
immediate: true,
|
|
628
|
-
}),
|
|
629
|
-
[_onRegionWillChange],
|
|
630
|
-
);
|
|
631
|
-
|
|
632
|
-
const _onDebouncedRegionDidChange = useCallback(
|
|
633
|
-
debounce(_onRegionDidChange, regionDidChangeDebounceTime),
|
|
634
|
-
[_onRegionDidChange],
|
|
635
|
-
);
|
|
636
|
-
|
|
637
|
-
const _onChange = (
|
|
638
|
-
e: NativeSyntheticEvent<{
|
|
639
|
-
type: string;
|
|
640
|
-
payload?: GeoJSON.Feature | Location;
|
|
641
|
-
}>,
|
|
642
|
-
): void => {
|
|
643
|
-
const { type, payload } = e.nativeEvent;
|
|
644
|
-
let propName: CallableProps | undefined;
|
|
645
|
-
|
|
646
|
-
switch (type) {
|
|
647
|
-
case MLRNModule.EventTypes.RegionWillChange:
|
|
648
|
-
if (
|
|
649
|
-
regionWillChangeDebounceTime &&
|
|
650
|
-
regionWillChangeDebounceTime > 0
|
|
651
|
-
) {
|
|
652
|
-
if (payload) {
|
|
653
|
-
_onDebouncedRegionWillChange(payload as RegionPayloadFeature);
|
|
654
|
-
}
|
|
655
|
-
} else {
|
|
656
|
-
propName = "onRegionWillChange";
|
|
657
|
-
}
|
|
658
|
-
break;
|
|
659
|
-
case MLRNModule.EventTypes.RegionIsChanging:
|
|
660
|
-
propName = "onRegionIsChanging";
|
|
661
|
-
break;
|
|
662
|
-
case MLRNModule.EventTypes.RegionDidChange:
|
|
663
|
-
if (
|
|
664
|
-
regionDidChangeDebounceTime &&
|
|
665
|
-
regionDidChangeDebounceTime > 0
|
|
666
|
-
) {
|
|
667
|
-
if (payload) {
|
|
668
|
-
_onDebouncedRegionDidChange(payload as RegionPayloadFeature);
|
|
669
|
-
}
|
|
670
|
-
} else {
|
|
671
|
-
propName = "onRegionDidChange";
|
|
672
|
-
}
|
|
673
|
-
break;
|
|
674
|
-
case MLRNModule.EventTypes.UserLocationUpdated:
|
|
675
|
-
propName = "onUserLocationUpdate";
|
|
676
|
-
break;
|
|
677
|
-
case MLRNModule.EventTypes.WillStartLoadingMap:
|
|
678
|
-
propName = "onWillStartLoadingMap";
|
|
679
|
-
break;
|
|
680
|
-
case MLRNModule.EventTypes.DidFinishLoadingMap:
|
|
681
|
-
propName = "onDidFinishLoadingMap";
|
|
682
|
-
break;
|
|
683
|
-
case MLRNModule.EventTypes.DidFailLoadingMap:
|
|
684
|
-
propName = "onDidFailLoadingMap";
|
|
685
|
-
break;
|
|
686
|
-
case MLRNModule.EventTypes.WillStartRenderingFrame:
|
|
687
|
-
propName = "onWillStartRenderingFrame";
|
|
688
|
-
break;
|
|
689
|
-
case MLRNModule.EventTypes.DidFinishRenderingFrame:
|
|
690
|
-
propName = "onDidFinishRenderingFrame";
|
|
691
|
-
break;
|
|
692
|
-
case MLRNModule.EventTypes.DidFinishRenderingFrameFully:
|
|
693
|
-
propName = "onDidFinishRenderingFrameFully";
|
|
694
|
-
break;
|
|
695
|
-
case MLRNModule.EventTypes.WillStartRenderingMap:
|
|
696
|
-
propName = "onWillStartRenderingMap";
|
|
697
|
-
break;
|
|
698
|
-
case MLRNModule.EventTypes.DidFinishRenderingMap:
|
|
699
|
-
propName = "onDidFinishRenderingMap";
|
|
700
|
-
break;
|
|
701
|
-
case MLRNModule.EventTypes.DidFinishRenderingMapFully:
|
|
702
|
-
propName = "onDidFinishRenderingMapFully";
|
|
703
|
-
break;
|
|
704
|
-
case MLRNModule.EventTypes.DidFinishLoadingStyle:
|
|
705
|
-
propName = "onDidFinishLoadingStyle";
|
|
706
|
-
break;
|
|
707
|
-
default:
|
|
708
|
-
console.warn("Unhandled event callback type", type);
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if (propName) {
|
|
712
|
-
_handleOnChange(propName, payload);
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
const _onLayout = (): void => {
|
|
717
|
-
setIsReady(true);
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
const _handleOnChange = <T extends CallableProps>(
|
|
721
|
-
propName: T,
|
|
722
|
-
payload?: object,
|
|
723
|
-
): void => {
|
|
724
|
-
const callable = props[propName] as (payload?: object) => void;
|
|
725
|
-
if (callable && isFunction(callable)) {
|
|
726
|
-
callable(payload);
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
const contentInsetValue = useMemo(() => {
|
|
731
|
-
if (props.contentInset === undefined) {
|
|
732
|
-
return undefined;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
if (!Array.isArray(props.contentInset)) {
|
|
736
|
-
return [props.contentInset];
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
return props.contentInset;
|
|
740
|
-
}, [props.contentInset]);
|
|
741
|
-
|
|
742
|
-
const _setNativeRef = (nativeRef: MLRNMapViewRefType): void => {
|
|
743
|
-
_nativeRef.current = nativeRef;
|
|
744
|
-
_runPendingNativeCommands(nativeRef);
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
const setNativeProps = (props: NativeProps): void => {
|
|
748
|
-
if (_nativeRef.current) {
|
|
749
|
-
_nativeRef.current.setNativeProps(props);
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
|
|
753
|
-
const nativeProps = useMemo(() => {
|
|
754
|
-
const { mapStyle, ...otherProps } = props;
|
|
755
|
-
|
|
756
|
-
let nativeMapStyle = undefined;
|
|
757
|
-
if (mapStyle) {
|
|
758
|
-
if (typeof mapStyle === "string") {
|
|
759
|
-
nativeMapStyle = mapStyle;
|
|
760
|
-
} else if (typeof mapStyle === "object") {
|
|
761
|
-
nativeMapStyle = JSON.stringify(mapStyle);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
return {
|
|
766
|
-
...otherProps,
|
|
767
|
-
localizeLabels,
|
|
768
|
-
scrollEnabled,
|
|
769
|
-
pitchEnabled,
|
|
770
|
-
rotateEnabled,
|
|
771
|
-
attributionEnabled,
|
|
772
|
-
logoEnabled,
|
|
773
|
-
surfaceView,
|
|
774
|
-
regionWillChangeDebounceTime,
|
|
775
|
-
regionDidChangeDebounceTime,
|
|
776
|
-
mapStyle: nativeMapStyle,
|
|
777
|
-
contentInset: contentInsetValue,
|
|
778
|
-
style: styles.matchParent,
|
|
779
|
-
};
|
|
780
|
-
}, [
|
|
781
|
-
props,
|
|
782
|
-
localizeLabels,
|
|
783
|
-
scrollEnabled,
|
|
784
|
-
pitchEnabled,
|
|
785
|
-
rotateEnabled,
|
|
786
|
-
attributionEnabled,
|
|
787
|
-
logoEnabled,
|
|
788
|
-
surfaceView,
|
|
789
|
-
regionWillChangeDebounceTime,
|
|
790
|
-
regionDidChangeDebounceTime,
|
|
791
|
-
contentInsetValue,
|
|
792
|
-
]);
|
|
793
|
-
|
|
794
|
-
const callbacks = {
|
|
795
|
-
ref: (ref: MLRNMapViewRefType): void => _setNativeRef(ref),
|
|
796
|
-
onPress: _onPress,
|
|
797
|
-
onLongPress: _onLongPress,
|
|
798
|
-
onMapChange: _onChange,
|
|
799
|
-
onAndroidCallback: isAndroid() ? _onAndroidCallback : undefined,
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
let mapView: ReactElement | null = null;
|
|
803
|
-
if (isAndroid() && !surfaceView && isReady) {
|
|
804
|
-
mapView = (
|
|
805
|
-
<MLRNAndroidTextureMapView {...nativeProps} {...callbacks}>
|
|
806
|
-
{props.children}
|
|
807
|
-
</MLRNAndroidTextureMapView>
|
|
808
|
-
);
|
|
809
|
-
} else if (isReady) {
|
|
810
|
-
mapView = (
|
|
811
|
-
<MLRNMapView {...nativeProps} {...callbacks}>
|
|
812
|
-
{props.children}
|
|
813
|
-
</MLRNMapView>
|
|
814
|
-
);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
return (
|
|
818
|
-
<View
|
|
819
|
-
onLayout={_onLayout}
|
|
820
|
-
style={props.style}
|
|
821
|
-
testID={mapView ? undefined : props.testID}
|
|
822
|
-
>
|
|
823
|
-
{mapView}
|
|
824
|
-
</View>
|
|
825
|
-
);
|
|
826
|
-
},
|
|
827
|
-
),
|
|
828
|
-
);
|
|
829
|
-
|
|
830
|
-
type MLRNMapViewRefType = Component<NativeProps> & Readonly<NativeMethods>;
|
|
831
|
-
const MLRNMapView = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
832
|
-
|
|
833
|
-
let MLRNAndroidTextureMapView: typeof MLRNMapView;
|
|
834
|
-
if (isAndroid()) {
|
|
835
|
-
MLRNAndroidTextureMapView = requireNativeComponent<NativeProps>(
|
|
836
|
-
ANDROID_TEXTURE_NATIVE_MODULE_NAME,
|
|
837
|
-
);
|
|
838
|
-
}
|