@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,809 @@
|
|
|
1
|
+
#import "MLRNMapView.h"
|
|
2
|
+
|
|
3
|
+
#import "CameraUpdateQueue.h"
|
|
4
|
+
#import "MLRNEventTypes.h"
|
|
5
|
+
#import "MLRNImageUtils.h"
|
|
6
|
+
#import "MLRNImages.h"
|
|
7
|
+
#import "MLRNLogging.h"
|
|
8
|
+
#import "MLRNMapTouchEvent.h"
|
|
9
|
+
#import "MLRNNativeUserLocation.h"
|
|
10
|
+
#import "MLRNShapeSource.h"
|
|
11
|
+
#import "MLRNUserLocation.h"
|
|
12
|
+
#import "MLRNUtils.h"
|
|
13
|
+
|
|
14
|
+
@implementation MLRNMapView {
|
|
15
|
+
BOOL _pendingInitialLayout;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static double const DEG2RAD = M_PI / 180;
|
|
19
|
+
static double const LAT_MAX = 85.051128779806604;
|
|
20
|
+
static double const TILE_SIZE = 256;
|
|
21
|
+
static double const EARTH_RADIUS_M = 6378137;
|
|
22
|
+
static double const M2PI = M_PI * 2;
|
|
23
|
+
|
|
24
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
25
|
+
if (self = [super initWithFrame:frame]) {
|
|
26
|
+
self.delegate = self;
|
|
27
|
+
|
|
28
|
+
_pendingInitialLayout = YES;
|
|
29
|
+
_cameraUpdateQueue = [[CameraUpdateQueue alloc] init];
|
|
30
|
+
_sources = [[NSMutableArray alloc] init];
|
|
31
|
+
_images = [[NSMutableArray alloc] init];
|
|
32
|
+
_layers = [[NSMutableArray alloc] init];
|
|
33
|
+
_pointAnnotations = [[NSMutableArray alloc] init];
|
|
34
|
+
_reactSubviews = [[NSMutableArray alloc] init];
|
|
35
|
+
_layerWaiters = [[NSMutableDictionary alloc] init];
|
|
36
|
+
_styleWaiters = [[NSMutableArray alloc] init];
|
|
37
|
+
_logging = [[MLRNLogging alloc] init];
|
|
38
|
+
|
|
39
|
+
// Setup map gesture recognizers
|
|
40
|
+
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self
|
|
41
|
+
action:nil];
|
|
42
|
+
doubleTap.numberOfTapsRequired = 2;
|
|
43
|
+
|
|
44
|
+
UITapGestureRecognizer *tap =
|
|
45
|
+
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMap:)];
|
|
46
|
+
[tap requireGestureRecognizerToFail:doubleTap];
|
|
47
|
+
|
|
48
|
+
UILongPressGestureRecognizer *longPress =
|
|
49
|
+
[[UILongPressGestureRecognizer alloc] initWithTarget:self
|
|
50
|
+
action:@selector(didLongPressMap:)];
|
|
51
|
+
|
|
52
|
+
// This allows the internal annotation gestures to take precedence over the map tap gesture
|
|
53
|
+
for (int i = 0; i < self.gestureRecognizers.count; i++) {
|
|
54
|
+
UIGestureRecognizer *gestureRecognizer = self.gestureRecognizers[i];
|
|
55
|
+
|
|
56
|
+
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
|
|
57
|
+
[tap requireGestureRecognizerToFail:gestureRecognizer];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[self addGestureRecognizer:doubleTap];
|
|
62
|
+
[self addGestureRecognizer:tap];
|
|
63
|
+
[self addGestureRecognizer:longPress];
|
|
64
|
+
}
|
|
65
|
+
return self;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)layoutSubviews {
|
|
69
|
+
[super layoutSubviews];
|
|
70
|
+
if (_pendingInitialLayout) {
|
|
71
|
+
_pendingInitialLayout = NO;
|
|
72
|
+
|
|
73
|
+
[_reactCamera initialLayout];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
- (void)invalidate {
|
|
78
|
+
if (_reactSubviews.count == 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
for (int i = 0; i < _reactSubviews.count; i++) {
|
|
82
|
+
[self removeFromMap:_reactSubviews[i]];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (void)layerAdded:(MLNStyleLayer *)layer {
|
|
87
|
+
NSString *layerId = layer.identifier;
|
|
88
|
+
NSMutableArray *waiters = [_layerWaiters valueForKey:layerId];
|
|
89
|
+
if (waiters) {
|
|
90
|
+
for (FoundLayerBlock foundLayerBlock in waiters) {
|
|
91
|
+
foundLayerBlock(layer);
|
|
92
|
+
}
|
|
93
|
+
[_layerWaiters removeObjectForKey:layerId];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
- (void)waitForLayerWithId:(nonnull NSString *)layerId
|
|
98
|
+
then:(void (^)(MLNStyleLayer *layer))foundLayer {
|
|
99
|
+
if (self.style) {
|
|
100
|
+
MLNStyleLayer *layer = [self.style layerWithIdentifier:layerId];
|
|
101
|
+
if (layer) {
|
|
102
|
+
foundLayer(layer);
|
|
103
|
+
} else {
|
|
104
|
+
NSMutableArray *existingWaiters = [_layerWaiters valueForKey:layerId];
|
|
105
|
+
|
|
106
|
+
NSMutableArray *waiters = existingWaiters;
|
|
107
|
+
if (waiters == nil) {
|
|
108
|
+
waiters = [[NSMutableArray alloc] init];
|
|
109
|
+
}
|
|
110
|
+
[waiters addObject:foundLayer];
|
|
111
|
+
if (!existingWaiters) {
|
|
112
|
+
[_layerWaiters setObject:waiters forKey:layerId];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (void)getStyle:(void (^)(MLNStyle *style))onStyleLoaded {
|
|
119
|
+
if (self.style) {
|
|
120
|
+
onStyleLoaded(self.style);
|
|
121
|
+
} else {
|
|
122
|
+
[_styleWaiters addObject:onStyleLoaded];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (void)notifyStyleLoaded {
|
|
127
|
+
if (!self.style) return;
|
|
128
|
+
for (StyleLoadedBlock styleLoadedBlock in self.styleWaiters) {
|
|
129
|
+
styleLoadedBlock(self.style);
|
|
130
|
+
}
|
|
131
|
+
[self.styleWaiters removeAllObjects];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
- (void)addToMap:(UIView *)subview {
|
|
135
|
+
if ([subview isKindOfClass:[MLRNSource class]]) {
|
|
136
|
+
MLRNSource *source = (MLRNSource *)subview;
|
|
137
|
+
source.map = self;
|
|
138
|
+
[_sources addObject:(MLRNSource *)subview];
|
|
139
|
+
} else if ([subview isKindOfClass:[MLRNLight class]]) {
|
|
140
|
+
MLRNLight *light = (MLRNLight *)subview;
|
|
141
|
+
_light = light;
|
|
142
|
+
_light.map = self;
|
|
143
|
+
} else if ([subview isKindOfClass:[MLRNNativeUserLocation class]]) {
|
|
144
|
+
MLRNNativeUserLocation *nativeUserLocation = (MLRNNativeUserLocation *)subview;
|
|
145
|
+
nativeUserLocation.map = self;
|
|
146
|
+
} else if ([subview isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
147
|
+
MLRNPointAnnotation *pointAnnotation = (MLRNPointAnnotation *)subview;
|
|
148
|
+
pointAnnotation.map = self;
|
|
149
|
+
[_pointAnnotations addObject:pointAnnotation];
|
|
150
|
+
} else if ([subview isKindOfClass:[MLRNCamera class]]) {
|
|
151
|
+
MLRNCamera *camera = (MLRNCamera *)subview;
|
|
152
|
+
camera.map = self;
|
|
153
|
+
} else if ([subview isKindOfClass:[MLRNImages class]]) {
|
|
154
|
+
MLRNImages *images = (MLRNImages *)subview;
|
|
155
|
+
images.map = self;
|
|
156
|
+
[_images addObject:images];
|
|
157
|
+
} else if ([subview isKindOfClass:[MLRNLayer class]]) {
|
|
158
|
+
MLRNLayer *layer = (MLRNLayer *)subview;
|
|
159
|
+
layer.map = self;
|
|
160
|
+
[_layers addObject:layer];
|
|
161
|
+
} else {
|
|
162
|
+
NSArray<UIView *> *childSubviews = [subview subviews];
|
|
163
|
+
|
|
164
|
+
for (int i = 0; i < childSubviews.count; i++) {
|
|
165
|
+
[self addToMap:childSubviews[i]];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
- (void)removeFromMap:(UIView *)subview {
|
|
171
|
+
if ([subview isKindOfClass:[MLRNSource class]]) {
|
|
172
|
+
MLRNSource *source = (MLRNSource *)subview;
|
|
173
|
+
source.map = nil;
|
|
174
|
+
[_sources removeObject:source];
|
|
175
|
+
} else if ([subview isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
176
|
+
MLRNPointAnnotation *pointAnnotation = (MLRNPointAnnotation *)subview;
|
|
177
|
+
pointAnnotation.map = nil;
|
|
178
|
+
[_pointAnnotations removeObject:pointAnnotation];
|
|
179
|
+
} else if ([subview isKindOfClass:[MLRNCamera class]]) {
|
|
180
|
+
MLRNCamera *camera = (MLRNCamera *)subview;
|
|
181
|
+
camera.map = nil;
|
|
182
|
+
} else if ([subview isKindOfClass:[MLRNImages class]]) {
|
|
183
|
+
MLRNImages *images = (MLRNImages *)subview;
|
|
184
|
+
images.map = nil;
|
|
185
|
+
[_images removeObject:images];
|
|
186
|
+
} else if ([subview isKindOfClass:[MLRNLayer class]]) {
|
|
187
|
+
MLRNLayer *layer = (MLRNLayer *)subview;
|
|
188
|
+
layer.map = nil;
|
|
189
|
+
[_layers removeObject:layer];
|
|
190
|
+
} else if ([subview isKindOfClass:[MLRNNativeUserLocation class]]) {
|
|
191
|
+
MLRNNativeUserLocation *nativeUserLocation = (MLRNNativeUserLocation *)subview;
|
|
192
|
+
nativeUserLocation.map = nil;
|
|
193
|
+
} else if ([subview isKindOfClass:[MLRNLight class]]) {
|
|
194
|
+
MLRNLight *light = (MLRNLight *)subview;
|
|
195
|
+
light.map = nil;
|
|
196
|
+
} else {
|
|
197
|
+
NSArray<UIView *> *childSubViews = [subview subviews];
|
|
198
|
+
|
|
199
|
+
for (int i = 0; i < childSubViews.count; i++) {
|
|
200
|
+
[self removeFromMap:childSubViews[i]];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if ([_layerWaiters count] > 0) {
|
|
204
|
+
RCTLogWarn(@"The following layers were waited on but never added to the map: %@",
|
|
205
|
+
[_layerWaiters allKeys]);
|
|
206
|
+
[_layerWaiters removeAllObjects];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
- (void)setSourceVisibility:(BOOL)visible
|
|
211
|
+
sourceId:(NSString *)sourceId
|
|
212
|
+
sourceLayerId:(NSString *)sourceLayerId {
|
|
213
|
+
__weak __typeof__(self) weakSelf = self;
|
|
214
|
+
[self getStyle:^(MLNStyle *style) {
|
|
215
|
+
__strong __typeof__(self) strongSelf = weakSelf;
|
|
216
|
+
for (MLNStyleLayer *layer in strongSelf.style.layers) {
|
|
217
|
+
if ([layer isKindOfClass:[MLNForegroundStyleLayer class]]) {
|
|
218
|
+
MLNForegroundStyleLayer *foregroundLayer = (MLNForegroundStyleLayer *)layer;
|
|
219
|
+
if (![foregroundLayer.sourceIdentifier isEqualToString:sourceId]) continue;
|
|
220
|
+
if (sourceLayerId == nil || sourceLayerId.length == 0) {
|
|
221
|
+
layer.visible = visible;
|
|
222
|
+
} else if ([layer isKindOfClass:[MLNVectorStyleLayer class]]) {
|
|
223
|
+
MLNVectorStyleLayer *vectorLayer = (MLNVectorStyleLayer *)layer;
|
|
224
|
+
if ([vectorLayer.sourceLayerIdentifier isEqualToString:sourceLayerId]) {
|
|
225
|
+
layer.visible = visible;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#pragma clang diagnostic push
|
|
234
|
+
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
235
|
+
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex {
|
|
236
|
+
[self addToMap:subview];
|
|
237
|
+
[_reactSubviews insertObject:(UIView *)subview atIndex:(NSUInteger)atIndex];
|
|
238
|
+
}
|
|
239
|
+
#pragma clang diagnostic pop
|
|
240
|
+
|
|
241
|
+
#pragma clang diagnostic push
|
|
242
|
+
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
243
|
+
- (void)removeReactSubview:(UIView *)subview {
|
|
244
|
+
// similarly, when the children are being removed we have to do the appropriate
|
|
245
|
+
// underlying mapview action here.
|
|
246
|
+
[self removeFromMap:subview];
|
|
247
|
+
[_reactSubviews removeObject:(UIView *)subview];
|
|
248
|
+
[(UIView *)subview removeFromSuperview];
|
|
249
|
+
}
|
|
250
|
+
#pragma clang diagnostic pop
|
|
251
|
+
|
|
252
|
+
#pragma clang diagnostic push
|
|
253
|
+
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
254
|
+
- (NSArray<UIView *> *)reactSubviews {
|
|
255
|
+
return _reactSubviews;
|
|
256
|
+
}
|
|
257
|
+
#pragma clang diagnostic pop
|
|
258
|
+
|
|
259
|
+
// MARK: - UIGestureRecognizers
|
|
260
|
+
|
|
261
|
+
- (void)didTapMap:(UITapGestureRecognizer *)recognizer {
|
|
262
|
+
MLRNMapView *mapView = (MLRNMapView *)recognizer.view;
|
|
263
|
+
CGPoint screenPoint = [recognizer locationInView:mapView];
|
|
264
|
+
NSArray<MLRNSource *> *touchableSources = [mapView getAllTouchableSources];
|
|
265
|
+
|
|
266
|
+
NSMutableDictionary<NSString *, NSArray<id<MLNFeature>> *> *hits =
|
|
267
|
+
[[NSMutableDictionary alloc] init];
|
|
268
|
+
NSMutableArray<MLRNSource *> *hitTouchableSources = [[NSMutableArray alloc] init];
|
|
269
|
+
for (MLRNSource *touchableSource in touchableSources) {
|
|
270
|
+
NSDictionary<NSString *, NSNumber *> *hitbox = touchableSource.hitbox;
|
|
271
|
+
float halfWidth = [hitbox[@"width"] floatValue] / 2.f;
|
|
272
|
+
float halfHeight = [hitbox[@"height"] floatValue] / 2.f;
|
|
273
|
+
|
|
274
|
+
CGFloat top = screenPoint.y - halfHeight;
|
|
275
|
+
CGFloat left = screenPoint.x - halfWidth;
|
|
276
|
+
CGRect hitboxRect =
|
|
277
|
+
CGRectMake(left, top, [hitbox[@"width"] floatValue], [hitbox[@"height"] floatValue]);
|
|
278
|
+
|
|
279
|
+
NSArray<id<MLNFeature>> *features =
|
|
280
|
+
[mapView visibleFeaturesInRect:hitboxRect
|
|
281
|
+
inStyleLayersWithIdentifiers:[NSSet setWithArray:[touchableSource getLayerIDs]]
|
|
282
|
+
predicate:nil];
|
|
283
|
+
|
|
284
|
+
if (features.count > 0) {
|
|
285
|
+
hits[touchableSource.id] = features;
|
|
286
|
+
[hitTouchableSources addObject:touchableSource];
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (hits.count > 0) {
|
|
291
|
+
MLRNSource *source = [mapView getTouchableSourceWithHighestZIndex:hitTouchableSources];
|
|
292
|
+
if (source != nil && source.hasPressListener) {
|
|
293
|
+
NSArray *geoJSONDicts = [MLRNUtils featuresToJSON:hits[source.id]];
|
|
294
|
+
|
|
295
|
+
NSString *eventType = RCT_MLRN_VECTOR_SOURCE_LAYER_PRESS;
|
|
296
|
+
if ([source isKindOfClass:[MLRNShapeSource class]]) {
|
|
297
|
+
eventType = RCT_MLRN_SHAPE_SOURCE_LAYER_PRESS;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
CLLocationCoordinate2D coordinate = [mapView convertPoint:screenPoint
|
|
301
|
+
toCoordinateFromView:mapView];
|
|
302
|
+
|
|
303
|
+
MLRNEvent *event = [MLRNEvent makeEvent:eventType
|
|
304
|
+
withPayload:@{
|
|
305
|
+
@"longitude" : [NSNumber numberWithDouble:coordinate.longitude],
|
|
306
|
+
@"latitude" : [NSNumber numberWithDouble:coordinate.latitude],
|
|
307
|
+
@"locationX" : [NSNumber numberWithDouble:screenPoint.x],
|
|
308
|
+
@"locationY" : [NSNumber numberWithDouble:screenPoint.y],
|
|
309
|
+
@"features" : geoJSONDicts,
|
|
310
|
+
}];
|
|
311
|
+
|
|
312
|
+
source.onPress([event toJSON]);
|
|
313
|
+
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (mapView.reactOnPress != nil) {
|
|
319
|
+
MLRNMapTouchEvent *event = [MLRNMapTouchEvent makeTapEvent:mapView withPoint:screenPoint];
|
|
320
|
+
|
|
321
|
+
self.reactOnPress(event.toJSON);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
- (void)didLongPressMap:(UILongPressGestureRecognizer *)recognizer {
|
|
326
|
+
MLRNMapView *mapView = (MLRNMapView *)recognizer.view;
|
|
327
|
+
|
|
328
|
+
if (mapView == nil || mapView.reactOnPress == nil ||
|
|
329
|
+
recognizer.state != UIGestureRecognizerStateBegan) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
MLRNMapTouchEvent *event =
|
|
334
|
+
[MLRNMapTouchEvent makeLongPressEvent:mapView withPoint:[recognizer locationInView:mapView]];
|
|
335
|
+
self.reactOnLongPress(event.toJSON);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// MARK: - Prop Setters
|
|
339
|
+
|
|
340
|
+
- (void)setReactMapStyle:(NSString *)reactMapStyle {
|
|
341
|
+
_reactMapStyle = reactMapStyle;
|
|
342
|
+
[self _removeAllSourcesFromMap];
|
|
343
|
+
self.styleURL = [self _getStyleURLFromKey:_reactMapStyle];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
- (void)setReactContentInset:(NSArray<NSNumber *> *)reactContentInset {
|
|
347
|
+
NSNumber *top = [reactContentInset valueForKey:@"top"];
|
|
348
|
+
NSNumber *right = [reactContentInset valueForKey:@"right"];
|
|
349
|
+
NSNumber *bottom = [reactContentInset valueForKey:@"bottom"];
|
|
350
|
+
NSNumber *left = [reactContentInset valueForKey:@"left"];
|
|
351
|
+
|
|
352
|
+
self.contentInset =
|
|
353
|
+
UIEdgeInsetsMake(top.floatValue, left.floatValue, bottom.floatValue, right.floatValue);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
- (void)setReactPreferredFramesPerSecond:(NSInteger)reactPreferredFramesPerSecond {
|
|
357
|
+
if (reactPreferredFramesPerSecond == -1) {
|
|
358
|
+
self.preferredFramesPerSecond = MLNMapViewPreferredFramesPerSecondDefault;
|
|
359
|
+
} else {
|
|
360
|
+
self.preferredFramesPerSecond = reactPreferredFramesPerSecond;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
- (void)setReactScrollEnabled:(BOOL)reactScrollEnabled {
|
|
365
|
+
_reactScrollEnabled = reactScrollEnabled;
|
|
366
|
+
self.scrollEnabled = _reactScrollEnabled;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
- (void)setReactZoomEnabled:(BOOL)reactZoomEnabled {
|
|
370
|
+
_reactZoomEnabled = reactZoomEnabled;
|
|
371
|
+
self.zoomEnabled = _reactZoomEnabled;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
- (void)setReactRotateEnabled:(BOOL)reactRotateEnabled {
|
|
375
|
+
_reactRotateEnabled = reactRotateEnabled;
|
|
376
|
+
self.rotateEnabled = _reactRotateEnabled;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
- (void)setReactPitchEnabled:(BOOL)reactPitchEnabled {
|
|
380
|
+
_reactPitchEnabled = reactPitchEnabled;
|
|
381
|
+
self.pitchEnabled = _reactPitchEnabled;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
- (void)setReactAttributionEnabled:(BOOL)reactAttributionEnabled {
|
|
385
|
+
_reactAttributionEnabled = reactAttributionEnabled;
|
|
386
|
+
self.attributionButton.hidden = !_reactAttributionEnabled;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
- (void)setReactAttributionPosition:(NSDictionary<NSString *, NSNumber *> *)position {
|
|
390
|
+
__weak typeof(self) weakSelf = self;
|
|
391
|
+
[self setOrnamentPosition:position
|
|
392
|
+
defaultPosition:MLNOrnamentPositionBottomRight
|
|
393
|
+
setPosition:^(MLNOrnamentPosition ornamentPosition) {
|
|
394
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
395
|
+
if (!strongSelf) return;
|
|
396
|
+
[strongSelf setAttributionButtonPosition:ornamentPosition];
|
|
397
|
+
}
|
|
398
|
+
setMargins:^(CGPoint point) {
|
|
399
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
400
|
+
if (!strongSelf) return;
|
|
401
|
+
[strongSelf setAttributionButtonMargins:point];
|
|
402
|
+
}];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
- (void)setReactLogoEnabled:(BOOL)reactLogoEnabled {
|
|
406
|
+
_reactLogoEnabled = reactLogoEnabled;
|
|
407
|
+
self.logoView.hidden = !_reactLogoEnabled;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
- (void)setReactLogoPosition:(NSDictionary<NSString *, NSNumber *> *)position {
|
|
411
|
+
__weak typeof(self) weakSelf = self;
|
|
412
|
+
[self setOrnamentPosition:position
|
|
413
|
+
defaultPosition:MLNOrnamentPositionBottomLeft
|
|
414
|
+
setPosition:^(MLNOrnamentPosition ornamentPosition) {
|
|
415
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
416
|
+
if (!strongSelf) return;
|
|
417
|
+
[strongSelf setLogoViewPosition:ornamentPosition];
|
|
418
|
+
}
|
|
419
|
+
setMargins:^(CGPoint point) {
|
|
420
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
421
|
+
if (!strongSelf) return;
|
|
422
|
+
[strongSelf setLogoViewMargins:point];
|
|
423
|
+
}];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
- (void)setReactCompassEnabled:(BOOL)reactCompassEnabled {
|
|
427
|
+
_reactCompassEnabled = reactCompassEnabled;
|
|
428
|
+
self.compassView.hidden = !_reactCompassEnabled;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
- (void)setReactCompassPosition:(NSDictionary<NSString *, NSNumber *> *)position {
|
|
432
|
+
__weak typeof(self) weakSelf = self;
|
|
433
|
+
[self setOrnamentPosition:position
|
|
434
|
+
defaultPosition:MLNOrnamentPositionTopRight
|
|
435
|
+
setPosition:^(MLNOrnamentPosition ornamentPosition) {
|
|
436
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
437
|
+
if (!strongSelf) return;
|
|
438
|
+
[strongSelf setCompassViewPosition:ornamentPosition];
|
|
439
|
+
}
|
|
440
|
+
setMargins:^(CGPoint point) {
|
|
441
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
442
|
+
if (!strongSelf) return;
|
|
443
|
+
[strongSelf setCompassViewMargins:point];
|
|
444
|
+
}];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
- (void)setReactShowUserLocation:(BOOL)reactShowUserLocation {
|
|
448
|
+
self.showsUserLocation = reactShowUserLocation;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// MARK: - Methods
|
|
452
|
+
|
|
453
|
+
- (NSString *)takeSnap:(BOOL)writeToDisk {
|
|
454
|
+
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0);
|
|
455
|
+
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
|
|
456
|
+
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
|
|
457
|
+
UIGraphicsEndImageContext();
|
|
458
|
+
return writeToDisk ? [MLRNImageUtils createTempFile:snapshot]
|
|
459
|
+
: [MLRNImageUtils createBase64:snapshot];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
- (CLLocationDistance)getMetersPerPixelAtLatitude:(double)latitude withZoom:(double)zoomLevel {
|
|
463
|
+
double constrainedZoom =
|
|
464
|
+
[[MLRNUtils clamp:[NSNumber numberWithDouble:zoomLevel]
|
|
465
|
+
min:[NSNumber numberWithDouble:self.minimumZoomLevel]
|
|
466
|
+
max:[NSNumber numberWithDouble:self.maximumZoomLevel]] doubleValue];
|
|
467
|
+
|
|
468
|
+
double constrainedLatitude = [[MLRNUtils clamp:[NSNumber numberWithDouble:latitude]
|
|
469
|
+
min:[NSNumber numberWithDouble:-LAT_MAX]
|
|
470
|
+
max:[NSNumber numberWithDouble:LAT_MAX]] doubleValue];
|
|
471
|
+
|
|
472
|
+
double constrainedScale = pow(2.0, constrainedZoom);
|
|
473
|
+
return cos(constrainedLatitude * DEG2RAD) * M2PI * EARTH_RADIUS_M /
|
|
474
|
+
(constrainedScale * TILE_SIZE);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
- (CLLocationDistance)altitudeFromZoom:(double)zoomLevel {
|
|
478
|
+
return [self altitudeFromZoom:zoomLevel atLatitude:self.camera.centerCoordinate.latitude];
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
- (CLLocationDistance)altitudeFromZoom:(double)zoomLevel atLatitude:(CLLocationDegrees)latitude {
|
|
482
|
+
return [self altitudeFromZoom:zoomLevel atLatitude:latitude atPitch:self.camera.pitch];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
- (CLLocationDistance)altitudeFromZoom:(double)zoomLevel
|
|
486
|
+
atLatitude:(CLLocationDegrees)latitude
|
|
487
|
+
atPitch:(CGFloat)pitch {
|
|
488
|
+
return MLNAltitudeForZoomLevel(zoomLevel, pitch, latitude, self.frame.size);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
- (MLRNPointAnnotation *)getRCTPointAnnotation:(MLNPointAnnotation *)mlnAnnotation {
|
|
492
|
+
for (int i = 0; i < _pointAnnotations.count; i++) {
|
|
493
|
+
MLRNPointAnnotation *rctAnnotation = _pointAnnotations[i];
|
|
494
|
+
if (rctAnnotation.annotation == mlnAnnotation) {
|
|
495
|
+
return rctAnnotation;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return nil;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
- (NSArray<MLRNSource *> *)getAllTouchableSources {
|
|
502
|
+
NSMutableArray<MLRNSource *> *touchableSources = [[NSMutableArray alloc] init];
|
|
503
|
+
|
|
504
|
+
for (MLRNSource *source in _sources) {
|
|
505
|
+
if (source.hasPressListener) {
|
|
506
|
+
[touchableSources addObject:source];
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return touchableSources;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
- (NSArray<MLRNImages *> *)getAllImages {
|
|
514
|
+
return [_images copy];
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
- (NSArray<MLRNShapeSource *> *)getAllShapeSources {
|
|
518
|
+
NSMutableArray<MLRNSource *> *shapeSources = [[NSMutableArray alloc] init];
|
|
519
|
+
|
|
520
|
+
for (MLRNSource *source in _sources) {
|
|
521
|
+
if ([source isKindOfClass:[MLRNShapeSource class]]) {
|
|
522
|
+
[shapeSources addObject:(MLRNShapeSource *)source];
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return [shapeSources copy];
|
|
527
|
+
}
|
|
528
|
+
- (MLRNSource *)getTouchableSourceWithHighestZIndex:(NSArray<MLRNSource *> *)touchableSources {
|
|
529
|
+
if (touchableSources == nil || touchableSources.count == 0) {
|
|
530
|
+
return nil;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (touchableSources.count == 1) {
|
|
534
|
+
return touchableSources[0];
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
NSMutableDictionary<NSString *, MLRNSource *> *layerToSourceDict =
|
|
538
|
+
[[NSMutableDictionary alloc] init];
|
|
539
|
+
for (MLRNSource *touchableSource in touchableSources) {
|
|
540
|
+
NSArray<NSString *> *layerIds = [touchableSource getLayerIDs];
|
|
541
|
+
|
|
542
|
+
for (NSString *layerId in layerIds) {
|
|
543
|
+
layerToSourceDict[layerId] = touchableSource;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
NSArray<MLNStyleLayer *> *layers = self.style.layers;
|
|
548
|
+
for (int i = (int)layers.count - 1; i >= 0; i--) {
|
|
549
|
+
MLNStyleLayer *layer = layers[i];
|
|
550
|
+
|
|
551
|
+
MLRNSource *source = layerToSourceDict[layer.identifier];
|
|
552
|
+
if (source != nil) {
|
|
553
|
+
return source;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return nil;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
- (NSURL *)_getStyleURLFromKey:(NSString *)mapStyle {
|
|
561
|
+
NSURL *url = [NSURL URLWithString:mapStyle];
|
|
562
|
+
if (url) {
|
|
563
|
+
return url;
|
|
564
|
+
} else if (RCTJSONParse(mapStyle, nil)) {
|
|
565
|
+
return [MLRNUtils styleURLFromStyleJSON:mapStyle];
|
|
566
|
+
}
|
|
567
|
+
return url;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
- (void)_removeAllSourcesFromMap {
|
|
571
|
+
if (self.style == nil || _sources.count == 0) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
for (MLRNSource *source in _sources) {
|
|
575
|
+
source.map = nil;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
- (void)didChangeUserTrackingMode:(MLNUserTrackingMode)mode animated:(BOOL)animated {
|
|
580
|
+
[_reactCamera didChangeUserTrackingMode:mode animated:animated];
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
#pragma mark - MLNMapViewDelegate
|
|
584
|
+
|
|
585
|
+
- (MLNAnnotationView *)mapView:(MLNMapView *)mapView
|
|
586
|
+
viewForAnnotation:(id<MLNAnnotation>)annotation {
|
|
587
|
+
if ([annotation isKindOfClass:[MLNUserLocation class]] && mapView.userLocation != nil) {
|
|
588
|
+
MLRNMapView *reactMapView = ((MLRNMapView *)mapView);
|
|
589
|
+
if (reactMapView.useNativeUserLocationAnnotationView) {
|
|
590
|
+
return nil;
|
|
591
|
+
}
|
|
592
|
+
return [[MLRNUserLocation sharedInstance] hiddenUserAnnotation];
|
|
593
|
+
} else if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
594
|
+
MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
|
|
595
|
+
return [rctAnnotation getAnnotationView];
|
|
596
|
+
}
|
|
597
|
+
return nil;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
- (void)mapView:(MLNMapView *)mapView
|
|
601
|
+
didChangeUserTrackingMode:(MLNUserTrackingMode)mode
|
|
602
|
+
animated:(BOOL)animated {
|
|
603
|
+
MLRNMapView *reactMapView = ((MLRNMapView *)mapView);
|
|
604
|
+
[reactMapView didChangeUserTrackingMode:mode animated:animated];
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
- (void)mapView:(MLNMapView *)mapView didSelectAnnotation:(nonnull id<MLNAnnotation>)annotation {
|
|
608
|
+
if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
609
|
+
MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
|
|
610
|
+
|
|
611
|
+
if (rctAnnotation.onSelected != nil) {
|
|
612
|
+
MLRNMapTouchEvent *event = [MLRNMapTouchEvent makeAnnotationTapEvent:rctAnnotation];
|
|
613
|
+
rctAnnotation.onSelected([event toJSON]);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
- (void)mapView:(MLNMapView *)mapView didDeselectAnnotation:(nonnull id<MLNAnnotation>)annotation {
|
|
619
|
+
if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
620
|
+
MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
|
|
621
|
+
|
|
622
|
+
if (rctAnnotation.onDeselected != nil) {
|
|
623
|
+
rctAnnotation.onDeselected(nil);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
- (BOOL)mapView:(MLNMapView *)mapView annotationCanShowCallout:(id<MLNAnnotation>)annotation {
|
|
629
|
+
if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
630
|
+
MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
|
|
631
|
+
return rctAnnotation.calloutView != nil;
|
|
632
|
+
}
|
|
633
|
+
return NO;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
- (UIView<MLNCalloutView> *)mapView:(MLNMapView *)mapView
|
|
637
|
+
calloutViewForAnnotation:(id<MLNAnnotation>)annotation {
|
|
638
|
+
if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
639
|
+
MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
|
|
640
|
+
return rctAnnotation.calloutView;
|
|
641
|
+
}
|
|
642
|
+
return nil;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
- (BOOL)mapView:(MLNMapView *)mapView
|
|
646
|
+
shouldChangeFromCamera:(MLNMapCamera *)oldCamera
|
|
647
|
+
toCamera:(MLNMapCamera *)newCamera {
|
|
648
|
+
MLRNMapView *reactMapView = ((MLRNMapView *)mapView);
|
|
649
|
+
return MLNCoordinateBoundsIsEmpty(reactMapView.maxBounds) ||
|
|
650
|
+
MLNCoordinateInCoordinateBounds(newCamera.centerCoordinate, reactMapView.maxBounds);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
- (void)mapView:(MLNMapView *)mapView
|
|
654
|
+
regionWillChangeWithReason:(MLNCameraChangeReason)reason
|
|
655
|
+
animated:(BOOL)animated {
|
|
656
|
+
((MLRNMapView *)mapView).isUserInteraction = (BOOL)(reason & ~MLNCameraChangeReasonProgrammatic);
|
|
657
|
+
NSDictionary *viewState = [self makeViewState:mapView animated:animated];
|
|
658
|
+
|
|
659
|
+
self.reactOnRegionWillChange(viewState);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
- (void)mapViewRegionIsChanging:(MLNMapView *)mapView {
|
|
663
|
+
NSDictionary *viewState = [self makeViewState:mapView animated:false];
|
|
664
|
+
|
|
665
|
+
self.reactOnRegionIsChanging(viewState);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
- (void)mapView:(MLNMapView *)mapView
|
|
669
|
+
regionDidChangeWithReason:(MLNCameraChangeReason)reason
|
|
670
|
+
animated:(BOOL)animated {
|
|
671
|
+
if (((reason & MLNCameraChangeReasonTransitionCancelled) ==
|
|
672
|
+
MLNCameraChangeReasonTransitionCancelled) &&
|
|
673
|
+
((reason & MLNCameraChangeReasonGesturePan) != MLNCameraChangeReasonGesturePan))
|
|
674
|
+
return;
|
|
675
|
+
|
|
676
|
+
((MLRNMapView *)mapView).isUserInteraction = (BOOL)(reason & ~MLNCameraChangeReasonProgrammatic);
|
|
677
|
+
|
|
678
|
+
NSDictionary *viewState = [self makeViewState:mapView animated:animated];
|
|
679
|
+
|
|
680
|
+
self.reactOnRegionDidChange(viewState);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
- (void)mapViewWillStartLoadingMap:(MLNMapView *)mapView {
|
|
684
|
+
self.reactOnWillStartLoadingMap(nil);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
- (void)mapViewDidFinishLoadingMap:(MLNMapView *)mapView {
|
|
688
|
+
self.reactOnDidFinishLoadingMap(nil);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
- (void)mapViewDidFailLoadingMap:(MLNMapView *)mapView withError:(NSError *)error {
|
|
692
|
+
NSLog(@"Failed loading map %@", error);
|
|
693
|
+
self.reactOnDidFailLoadingMap(nil);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
- (void)mapViewWillStartRenderingFrame:(MLNMapView *)mapView {
|
|
697
|
+
self.reactOnWillStartRenderingFrame(nil);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
- (void)mapViewDidFinishRenderingFrame:(MLNMapView *)mapView fullyRendered:(BOOL)fullyRendered {
|
|
701
|
+
if (fullyRendered) {
|
|
702
|
+
self.reactOnDidFinishRenderingFrameFully(nil);
|
|
703
|
+
} else {
|
|
704
|
+
self.reactOnDidFinishRenderingFrame(nil);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
- (void)mapViewWillStartRenderingMap:(MLNMapView *)mapView {
|
|
709
|
+
self.reactOnWillStartRenderingMap(nil);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
- (void)mapViewDidFinishRenderingMap:(MLNMapView *)mapView fullyRendered:(BOOL)fullyRendered {
|
|
713
|
+
if (fullyRendered) {
|
|
714
|
+
self.reactOnDidFinishRenderingMapFully(nil);
|
|
715
|
+
} else {
|
|
716
|
+
self.reactOnDidFinishRenderingMap(nil);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
- (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style {
|
|
721
|
+
MLRNMapView *reactMapView = (MLRNMapView *)mapView;
|
|
722
|
+
|
|
723
|
+
for (int i = 0; i < reactMapView.sources.count; i++) {
|
|
724
|
+
MLRNSource *source = reactMapView.sources[i];
|
|
725
|
+
source.map = reactMapView;
|
|
726
|
+
}
|
|
727
|
+
for (int i = 0; i < reactMapView.layers.count; i++) {
|
|
728
|
+
MLRNLayer *layer = reactMapView.layers[i];
|
|
729
|
+
layer.map = reactMapView;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
if (reactMapView.light != nil) {
|
|
733
|
+
reactMapView.light.map = reactMapView;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
[reactMapView notifyStyleLoaded];
|
|
737
|
+
|
|
738
|
+
self.reactOnDidFinishLoadingStyle(nil);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
- (UIImage *)mapView:(MLNMapView *)mapView didFailToLoadImage:(NSString *)imageName {
|
|
742
|
+
MLRNMapView *reactMapView = ((MLRNMapView *)mapView);
|
|
743
|
+
NSArray<MLRNImages *> *allImages = [reactMapView getAllImages];
|
|
744
|
+
for (MLRNImages *images in allImages) {
|
|
745
|
+
if ([images addMissingImageToStyle:imageName]) {
|
|
746
|
+
// The image was added inside addMissingImageToStyle so we can return nil
|
|
747
|
+
return nil;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
for (MLRNImages *images in allImages) {
|
|
752
|
+
[images sendImageMissingEvent:imageName];
|
|
753
|
+
}
|
|
754
|
+
return nil;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// MARK: - Helper Functions
|
|
758
|
+
|
|
759
|
+
- (void)setOrnamentPosition:(NSDictionary<NSString *, NSNumber *> *)position
|
|
760
|
+
defaultPosition:(MLNOrnamentPosition)defaultPosition
|
|
761
|
+
setPosition:(void (^)(MLNOrnamentPosition))setViewPosition
|
|
762
|
+
setMargins:(void (^)(CGPoint))setViewMargins {
|
|
763
|
+
NSNumber *topNumber = [position valueForKey:@"top"];
|
|
764
|
+
NSNumber *rightNumber = [position valueForKey:@"right"];
|
|
765
|
+
NSNumber *bottomNumber = [position valueForKey:@"bottom"];
|
|
766
|
+
NSNumber *leftNumber = [position valueForKey:@"left"];
|
|
767
|
+
|
|
768
|
+
NSInteger top = [topNumber integerValue];
|
|
769
|
+
NSInteger right = [rightNumber integerValue];
|
|
770
|
+
NSInteger bottom = [bottomNumber integerValue];
|
|
771
|
+
NSInteger left = [leftNumber integerValue];
|
|
772
|
+
|
|
773
|
+
if (left != -1 && top != -1) {
|
|
774
|
+
setViewPosition(MLNOrnamentPositionTopLeft);
|
|
775
|
+
setViewMargins(CGPointMake(left, top));
|
|
776
|
+
} else if (right != -1 && top != -1) {
|
|
777
|
+
setViewPosition(MLNOrnamentPositionTopRight);
|
|
778
|
+
setViewMargins(CGPointMake(right, top));
|
|
779
|
+
} else if (bottom != -1 && right != -1) {
|
|
780
|
+
setViewPosition(MLNOrnamentPositionBottomRight);
|
|
781
|
+
setViewMargins(CGPointMake(right, bottom));
|
|
782
|
+
} else if (bottom != -1 && left != -1) {
|
|
783
|
+
setViewPosition(MLNOrnamentPositionBottomLeft);
|
|
784
|
+
setViewMargins(CGPointMake(left, bottom));
|
|
785
|
+
} else {
|
|
786
|
+
setViewPosition(defaultPosition);
|
|
787
|
+
// Equals MLNOrnamentDefaultPositionOffset in MLNMapView.mm
|
|
788
|
+
setViewMargins(CGPointMake(8, 8));
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
- (NSDictionary *)makeViewState:(MLNMapView *)mapView animated:(BOOL)animated {
|
|
793
|
+
MLRNMapView *rctMapView = (MLRNMapView *)mapView;
|
|
794
|
+
|
|
795
|
+
NSDictionary *viewState = @{
|
|
796
|
+
@"longitude" : [NSNumber numberWithDouble:mapView.centerCoordinate.longitude],
|
|
797
|
+
@"latitude" : [NSNumber numberWithDouble:mapView.centerCoordinate.latitude],
|
|
798
|
+
@"zoom" : [NSNumber numberWithDouble:mapView.zoomLevel],
|
|
799
|
+
@"pitch" : [NSNumber numberWithDouble:mapView.camera.pitch],
|
|
800
|
+
@"bearing" : [NSNumber numberWithDouble:mapView.camera.heading],
|
|
801
|
+
@"bounds" : [MLRNUtils fromCoordinateBounds:mapView.visibleCoordinateBounds],
|
|
802
|
+
@"animated" : [NSNumber numberWithBool:animated],
|
|
803
|
+
@"userInteraction" : @(rctMapView.isUserInteraction),
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
return viewState;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
@end
|