@maplibre/maplibre-react-native 8.6.0-beta.0
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/.eslintignore +3 -0
- package/.eslintrc.js +158 -0
- package/.gitattributes +1 -0
- package/.nvmrc +1 -0
- package/.prettierrc.js +7 -0
- package/.sonarcloud.properties +15 -0
- package/CHANGELOG.md +367 -0
- package/CODE_OF_CONDUCT.md +2 -0
- package/CONTRIBUTING.md +34 -0
- package/LICENSE.md +9 -0
- package/README.md +224 -0
- package/RELEASE.md +30 -0
- package/android/build.gradle +34 -0
- package/android/install.md +16 -0
- package/android/rctmgl/.settings/org.eclipse.buildship.core.prefs +2 -0
- package/android/rctmgl/build.gradle +61 -0
- package/android/rctmgl/proguard-rules.pro +25 -0
- package/android/rctmgl/src/main/AndroidManifest.xml +4 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/RCTMGLPackage.java +99 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEvent.java +35 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java +80 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractMapFeature.java +19 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/MarkerView.java +23 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/MarkerViewManager.java +67 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLCallout.java +15 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLCalloutManager.java +22 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.java +112 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewManager.java +45 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.java +360 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationManager.java +88 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraStop.java +249 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateItem.java +125 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java +73 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCamera.java +530 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.java +101 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/constants/CameraMode.java +22 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/images/RCTMGLImages.java +234 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/images/RCTMGLImagesManager.java +103 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/location/LocationComponentManager.java +149 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/location/RCTMGLNativeUserLocation.java +66 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/location/RCTMGLNativeUserLocationManager.java +35 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/LayerSourceInfo.java +59 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLAndroidTextureMapView.java +16 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLAndroidTextureMapViewManager.java +31 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java +1527 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.java +353 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/helpers/CameraChangeTracker.java +41 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyle.java +83 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +2242 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleFunctionParser.java +108 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleValue.java +212 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTLayer.java +287 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayer.java +27 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayerManager.java +64 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayer.java +55 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayerManager.java +77 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayer.java +55 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayerManager.java +80 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.java +55 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayerManager.java +80 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayer.java +55 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayerManager.java +77 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayer.java +55 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayerManager.java +79 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayer.java +27 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayerManager.java +64 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.java +55 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayerManager.java +75 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/light/RCTMGLLight.java +65 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/light/RCTMGLLightManager.java +29 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSource.java +81 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSourceManager.java +72 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSource.java +45 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSourceManager.java +44 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.java +302 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.java +227 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSource.java +97 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSourceManager.java +80 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.java +64 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSourceManager.java +84 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTSource.java +244 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/AbstractEvent.java +66 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/AndroidCallbackEvent.java +38 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/EventEmitter.java +45 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/FeatureClickEvent.java +79 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/IEvent.java +18 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/ImageMissingEvent.java +42 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/LocationEvent.java +100 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/MapChangeEvent.java +47 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/MapClickEvent.java +51 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/MapUserTrackingModeEvent.java +36 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/OfflineEvent.java +29 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/PointAnnotationClickEvent.java +46 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/PointAnnotationDragEvent.java +51 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/constants/EventKeys.java +39 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/constants/EventTypes.java +51 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/http/CustomHeadersInterceptor.java +38 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java +168 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserLocation.java +63 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserLocationVerticalAlignment.java +11 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserTrackingMode.java +63 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserTrackingState.java +19 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLLocationModule.java +158 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLLogging.java +140 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLModule.java +348 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java +597 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +139 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/BitmapUtils.java +129 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ConvertUtils.java +257 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/DownloadMapImageTask.java +159 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ExpressionParser.java +74 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/GeoJSONUtils.java +209 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/GeoViewport.java +38 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ImageEntry.java +25 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ResourceUtils.java +30 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/SimpleEventCallback.java +30 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/SphericalMercator.java +69 -0
- package/android/rctmgl/src/main/res/drawable/empty.xml +5 -0
- package/android/rctmgl/src/main/res/drawable/empty_drawable.png +0 -0
- package/android/rctmgl/src/main/res/drawable-xxhdpi/red_marker.png +0 -0
- package/android/rctmgl/src/main/res/layout/annotation.xml +17 -0
- package/android/rctmgl/src/main/res/values/strings.xml +3 -0
- package/android/settings.gradle +1 -0
- package/app.plugin.js +1 -0
- package/assets/heading.png +0 -0
- package/assets/heading@2x.png +0 -0
- package/assets/heading@3x.png +0 -0
- package/assets/indoor_building_map_android.png +0 -0
- package/assets/indoor_building_map_ios.png +0 -0
- package/assets/mapbox_logo.png +0 -0
- package/babel.config.js +9 -0
- package/docs/Annotation.md +39 -0
- package/docs/Annotations.md +17 -0
- package/docs/BackgroundLayer.md +166 -0
- package/docs/Callout.md +15 -0
- package/docs/Camera.md +162 -0
- package/docs/CircleLayer.md +453 -0
- package/docs/CustomHttpHeaders.md +87 -0
- package/docs/FillExtrusionLayer.md +327 -0
- package/docs/FillLayer.md +293 -0
- package/docs/GettingStarted.md +72 -0
- package/docs/HeadingIndicator.md +10 -0
- package/docs/HeatmapLayer.md +215 -0
- package/docs/ImageSource.md +12 -0
- package/docs/Images.md +12 -0
- package/docs/Light.md +159 -0
- package/docs/LineLayer.md +567 -0
- package/docs/Logger.md +23 -0
- package/docs/MapView.md +211 -0
- package/docs/MapboxGL.md +65 -0
- package/docs/MarkerView.md +14 -0
- package/docs/NativeUserLocation.md +11 -0
- package/docs/OfflineManager.md +246 -0
- package/docs/PointAnnotation.md +34 -0
- package/docs/RasterLayer.md +357 -0
- package/docs/RasterSource.md +17 -0
- package/docs/ShapeSource.md +100 -0
- package/docs/Style.md +10 -0
- package/docs/StyleSheet.md +430 -0
- package/docs/SymbolLayer.md +1658 -0
- package/docs/UserLocation.md +39 -0
- package/docs/VectorSource.md +48 -0
- package/docs/docs.json +6093 -0
- package/docs/snapshotManager.md +53 -0
- package/index.d.ts +953 -0
- package/ios/RCTMGL/CameraMode.h +18 -0
- package/ios/RCTMGL/CameraMode.m +18 -0
- package/ios/RCTMGL/CameraStop.h +26 -0
- package/ios/RCTMGL/CameraStop.m +83 -0
- package/ios/RCTMGL/CameraUpdateItem.h +18 -0
- package/ios/RCTMGL/CameraUpdateItem.m +178 -0
- package/ios/RCTMGL/CameraUpdateQueue.h +21 -0
- package/ios/RCTMGL/CameraUpdateQueue.m +74 -0
- package/ios/RCTMGL/FilterParser.h +14 -0
- package/ios/RCTMGL/FilterParser.m +22 -0
- package/ios/RCTMGL/MGLCustomHeaders.h +20 -0
- package/ios/RCTMGL/MGLCustomHeaders.m +98 -0
- package/ios/RCTMGL/MGLFaux3DUserLocationAnnotationView.h +23 -0
- package/ios/RCTMGL/MGLFaux3DUserLocationAnnotationView.m +474 -0
- package/ios/RCTMGL/MGLModule.h +13 -0
- package/ios/RCTMGL/MGLModule.m +269 -0
- package/ios/RCTMGL/MGLOfflineModule.h +19 -0
- package/ios/RCTMGL/MGLOfflineModule.m +516 -0
- package/ios/RCTMGL/MGLSnapshotModule.h +13 -0
- package/ios/RCTMGL/MGLSnapshotModule.m +80 -0
- package/ios/RCTMGL/MGLUserLocationHeadingArrowLayer.h +11 -0
- package/ios/RCTMGL/MGLUserLocationHeadingArrowLayer.m +57 -0
- package/ios/RCTMGL/MGLUserLocationHeadingBeamLayer.h +11 -0
- package/ios/RCTMGL/MGLUserLocationHeadingBeamLayer.m +102 -0
- package/ios/RCTMGL/MGLUserLocationHeadingIndicator.h +10 -0
- package/ios/RCTMGL/RCTConvert+Mapbox.h +16 -0
- package/ios/RCTMGL/RCTConvert+Mapbox.m +32 -0
- package/ios/RCTMGL/RCTMGL.h +13 -0
- package/ios/RCTMGL/RCTMGL.m +13 -0
- package/ios/RCTMGL/RCTMGLBackgroundLayer.h +14 -0
- package/ios/RCTMGL/RCTMGLBackgroundLayer.m +27 -0
- package/ios/RCTMGL/RCTMGLBackgroundLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLBackgroundLayerManager.m +35 -0
- package/ios/RCTMGL/RCTMGLCallout.h +15 -0
- package/ios/RCTMGL/RCTMGLCallout.m +74 -0
- package/ios/RCTMGL/RCTMGLCalloutManager.h +13 -0
- package/ios/RCTMGL/RCTMGLCalloutManager.m +21 -0
- package/ios/RCTMGL/RCTMGLCamera.h +39 -0
- package/ios/RCTMGL/RCTMGLCamera.m +258 -0
- package/ios/RCTMGL/RCTMGLCameraManager.h +13 -0
- package/ios/RCTMGL/RCTMGLCameraManager.m +52 -0
- package/ios/RCTMGL/RCTMGLCircleLayer.h +13 -0
- package/ios/RCTMGL/RCTMGLCircleLayer.m +34 -0
- package/ios/RCTMGL/RCTMGLCircleLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLCircleLayerManager.m +39 -0
- package/ios/RCTMGL/RCTMGLEvent.h +21 -0
- package/ios/RCTMGL/RCTMGLEvent.m +47 -0
- package/ios/RCTMGL/RCTMGLEventProtocol.h +16 -0
- package/ios/RCTMGL/RCTMGLEventTypes.h +50 -0
- package/ios/RCTMGL/RCTMGLEventTypes.m +49 -0
- package/ios/RCTMGL/RCTMGLFillExtrusionLayer.h +14 -0
- package/ios/RCTMGL/RCTMGLFillExtrusionLayer.m +32 -0
- package/ios/RCTMGL/RCTMGLFillExtrusionLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLFillExtrusionLayerManager.m +39 -0
- package/ios/RCTMGL/RCTMGLFillLayer.h +14 -0
- package/ios/RCTMGL/RCTMGLFillLayer.m +33 -0
- package/ios/RCTMGL/RCTMGLFillLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLFillLayerManager.m +37 -0
- package/ios/RCTMGL/RCTMGLHeatmapLayer.h +12 -0
- package/ios/RCTMGL/RCTMGLHeatmapLayer.m +30 -0
- package/ios/RCTMGL/RCTMGLHeatmapLayerManager.h +12 -0
- package/ios/RCTMGL/RCTMGLHeatmapLayerManager.m +38 -0
- package/ios/RCTMGL/RCTMGLImageQueue.h +19 -0
- package/ios/RCTMGL/RCTMGLImageQueue.m +57 -0
- package/ios/RCTMGL/RCTMGLImageQueueOperation.h +17 -0
- package/ios/RCTMGL/RCTMGLImageQueueOperation.m +138 -0
- package/ios/RCTMGL/RCTMGLImageSource.h +16 -0
- package/ios/RCTMGL/RCTMGLImageSource.m +60 -0
- package/ios/RCTMGL/RCTMGLImageSourceManager.h +13 -0
- package/ios/RCTMGL/RCTMGLImageSourceManager.m +25 -0
- package/ios/RCTMGL/RCTMGLImages.h +25 -0
- package/ios/RCTMGL/RCTMGLImages.m +126 -0
- package/ios/RCTMGL/RCTMGLImagesManager.h +5 -0
- package/ios/RCTMGL/RCTMGLImagesManager.m +21 -0
- package/ios/RCTMGL/RCTMGLLayer.h +52 -0
- package/ios/RCTMGL/RCTMGLLayer.m +236 -0
- package/ios/RCTMGL/RCTMGLLight.h +17 -0
- package/ios/RCTMGL/RCTMGLLight.m +46 -0
- package/ios/RCTMGL/RCTMGLLightManager.h +13 -0
- package/ios/RCTMGL/RCTMGLLightManager.m +23 -0
- package/ios/RCTMGL/RCTMGLLineLayer.h +14 -0
- package/ios/RCTMGL/RCTMGLLineLayer.m +33 -0
- package/ios/RCTMGL/RCTMGLLineLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLLineLayerManager.m +40 -0
- package/ios/RCTMGL/RCTMGLLocation.h +19 -0
- package/ios/RCTMGL/RCTMGLLocation.m +32 -0
- package/ios/RCTMGL/RCTMGLLocationManager.h +30 -0
- package/ios/RCTMGL/RCTMGLLocationManager.m +180 -0
- package/ios/RCTMGL/RCTMGLLocationManagerDelegate.h +20 -0
- package/ios/RCTMGL/RCTMGLLocationModule.h +15 -0
- package/ios/RCTMGL/RCTMGLLocationModule.m +99 -0
- package/ios/RCTMGL/RCTMGLLogging.h +18 -0
- package/ios/RCTMGL/RCTMGLLogging.m +132 -0
- package/ios/RCTMGL/RCTMGLMapTouchEvent.h +25 -0
- package/ios/RCTMGL/RCTMGLMapTouchEvent.m +77 -0
- package/ios/RCTMGL/RCTMGLMapView.h +91 -0
- package/ios/RCTMGL/RCTMGLMapView.m +536 -0
- package/ios/RCTMGL/RCTMGLMapViewManager.h +17 -0
- package/ios/RCTMGL/RCTMGLMapViewManager.m +625 -0
- package/ios/RCTMGL/RCTMGLNativeUserLocation.h +18 -0
- package/ios/RCTMGL/RCTMGLNativeUserLocation.m +49 -0
- package/ios/RCTMGL/RCTMGLNativeUserLocationManager.h +5 -0
- package/ios/RCTMGL/RCTMGLNativeUserLocationManager.m +25 -0
- package/ios/RCTMGL/RCTMGLPointAnnotation.h +41 -0
- package/ios/RCTMGL/RCTMGLPointAnnotation.m +251 -0
- package/ios/RCTMGL/RCTMGLPointAnnotationManager.h +13 -0
- package/ios/RCTMGL/RCTMGLPointAnnotationManager.m +36 -0
- package/ios/RCTMGL/RCTMGLRasterLayer.h +14 -0
- package/ios/RCTMGL/RCTMGLRasterLayer.m +30 -0
- package/ios/RCTMGL/RCTMGLRasterLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLRasterLayerManager.m +35 -0
- package/ios/RCTMGL/RCTMGLRasterSource.h +16 -0
- package/ios/RCTMGL/RCTMGLRasterSource.m +35 -0
- package/ios/RCTMGL/RCTMGLRasterSourceManager.h +13 -0
- package/ios/RCTMGL/RCTMGLRasterSourceManager.m +32 -0
- package/ios/RCTMGL/RCTMGLShapeSource.h +52 -0
- package/ios/RCTMGL/RCTMGLShapeSource.m +180 -0
- package/ios/RCTMGL/RCTMGLShapeSourceManager.h +14 -0
- package/ios/RCTMGL/RCTMGLShapeSourceManager.m +205 -0
- package/ios/RCTMGL/RCTMGLSource.h +35 -0
- package/ios/RCTMGL/RCTMGLSource.m +143 -0
- package/ios/RCTMGL/RCTMGLStyle.h +219 -0
- package/ios/RCTMGL/RCTMGLStyle.m +1654 -0
- package/ios/RCTMGL/RCTMGLStyleValue.h +27 -0
- package/ios/RCTMGL/RCTMGLStyleValue.m +167 -0
- package/ios/RCTMGL/RCTMGLSymbolLayer.h +19 -0
- package/ios/RCTMGL/RCTMGLSymbolLayer.m +121 -0
- package/ios/RCTMGL/RCTMGLSymbolLayerManager.h +13 -0
- package/ios/RCTMGL/RCTMGLSymbolLayerManager.m +40 -0
- package/ios/RCTMGL/RCTMGLTileSource.h +22 -0
- package/ios/RCTMGL/RCTMGLTileSource.m +31 -0
- package/ios/RCTMGL/RCTMGLUserLocation.h +15 -0
- package/ios/RCTMGL/RCTMGLUserLocation.m +38 -0
- package/ios/RCTMGL/RCTMGLUtils.h +31 -0
- package/ios/RCTMGL/RCTMGLUtils.m +218 -0
- package/ios/RCTMGL/RCTMGLVectorLayer.h +15 -0
- package/ios/RCTMGL/RCTMGLVectorLayer.m +59 -0
- package/ios/RCTMGL/RCTMGLVectorSource.h +16 -0
- package/ios/RCTMGL/RCTMGLVectorSource.m +28 -0
- package/ios/RCTMGL/RCTMGLVectorSourceManager.h +14 -0
- package/ios/RCTMGL/RCTMGLVectorSourceManager.m +79 -0
- package/ios/RCTMGL/RNMBImageUtils.h +17 -0
- package/ios/RCTMGL/RNMBImageUtils.m +31 -0
- package/ios/RCTMGL/ViewManager.h +16 -0
- package/ios/RCTMGL/ViewManager.m +63 -0
- package/ios/RCTMGL/index.d.ts +1164 -0
- package/ios/RCTMGL.xcodeproj/project.pbxproj +774 -0
- package/ios/install.md +44 -0
- package/javascript/components/AbstractLayer.js +75 -0
- package/javascript/components/AbstractSource.js +15 -0
- package/javascript/components/BackgroundLayer.js +97 -0
- package/javascript/components/Callout.js +139 -0
- package/javascript/components/Camera.js +665 -0
- package/javascript/components/CircleLayer.js +101 -0
- package/javascript/components/FillExtrusionLayer.js +98 -0
- package/javascript/components/FillLayer.js +94 -0
- package/javascript/components/HeadingIndicator.js +31 -0
- package/javascript/components/HeatmapLayer.js +99 -0
- package/javascript/components/ImageSource.js +82 -0
- package/javascript/components/Images.js +119 -0
- package/javascript/components/Light.js +47 -0
- package/javascript/components/LineLayer.js +94 -0
- package/javascript/components/MapView.js +817 -0
- package/javascript/components/MarkerView.js +87 -0
- package/javascript/components/NativeBridgeComponent.js +86 -0
- package/javascript/components/NativeUserLocation.js +41 -0
- package/javascript/components/PointAnnotation.js +216 -0
- package/javascript/components/RasterLayer.js +95 -0
- package/javascript/components/RasterSource.js +124 -0
- package/javascript/components/ShapeSource.js +357 -0
- package/javascript/components/Style.js +264 -0
- package/javascript/components/SymbolLayer.js +120 -0
- package/javascript/components/UserLocation.js +273 -0
- package/javascript/components/VectorSource.js +200 -0
- package/javascript/components/annotations/Annotation.js +122 -0
- package/javascript/index.js +153 -0
- package/javascript/modules/location/locationManager.js +101 -0
- package/javascript/modules/offline/OfflineCreatePackOptions.js +46 -0
- package/javascript/modules/offline/OfflinePack.js +40 -0
- package/javascript/modules/offline/offlineManager.js +378 -0
- package/javascript/modules/snapshot/SnapshotOptions.js +67 -0
- package/javascript/modules/snapshot/snapshotManager.js +62 -0
- package/javascript/utils/BridgeValue.js +81 -0
- package/javascript/utils/Logger.js +114 -0
- package/javascript/utils/animated/Animated.js +39 -0
- package/javascript/utils/animated/AnimatedCoordinatesArray.js +191 -0
- package/javascript/utils/animated/AnimatedExtractCoordinateFromArray.js +43 -0
- package/javascript/utils/animated/AnimatedPoint.js +126 -0
- package/javascript/utils/animated/AnimatedRouteCoordinatesArray.js +124 -0
- package/javascript/utils/animated/AnimatedShape.js +72 -0
- package/javascript/utils/deprecation.js +25 -0
- package/javascript/utils/filterUtils.js +7 -0
- package/javascript/utils/geoUtils.js +73 -0
- package/javascript/utils/index.js +113 -0
- package/javascript/utils/styleMap.js +1901 -0
- package/maplibre-react-native.podspec +79 -0
- package/package.json +120 -0
- package/plugin/build/withMapbox.d.ts +12 -0
- package/plugin/build/withMapbox.js +119 -0
- package/plugin/install.md +32 -0
- package/react-native.config.js +10 -0
- package/scripts/autogenHelpers/DocJSONBuilder.js +458 -0
- package/scripts/autogenHelpers/JSDocNodeTree.js +131 -0
- package/scripts/autogenHelpers/MarkdownBuilder.js +29 -0
- package/scripts/autogenHelpers/globals.js +507 -0
- package/scripts/autogenerate.js +374 -0
- package/scripts/download-style-spec.sh +15 -0
- package/scripts/templates/RCTMGLStyle.h.ejs +33 -0
- package/scripts/templates/RCTMGLStyle.m.ejs +97 -0
- package/scripts/templates/RCTMGLStyleFactory.java.ejs +107 -0
- package/scripts/templates/component.md.ejs +122 -0
- package/scripts/templates/index.d.ts.ejs +56 -0
- package/scripts/templates/styleMap.js.ejs +115 -0
- package/setup-jest.js +121 -0
- package/style-spec/v8.json +5798 -0
- package/tsconfig.json +65 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import {isUndefined, isFunction, isAndroid} from '../../utils';
|
|
2
|
+
|
|
3
|
+
import OfflineCreatePackOptions from './OfflineCreatePackOptions';
|
|
4
|
+
import OfflinePack from './OfflinePack';
|
|
5
|
+
|
|
6
|
+
import {NativeModules, NativeEventEmitter} from 'react-native';
|
|
7
|
+
|
|
8
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
9
|
+
const MapboxGLOfflineManager = NativeModules.MGLOfflineModule;
|
|
10
|
+
export const OfflineModuleEventEmitter = new NativeEventEmitter(
|
|
11
|
+
MapboxGLOfflineManager,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* OfflineManager implements a singleton (shared object) that manages offline packs.
|
|
16
|
+
* All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.
|
|
17
|
+
* The shared object maintains a canonical collection of offline packs.
|
|
18
|
+
*/
|
|
19
|
+
class OfflineManager {
|
|
20
|
+
constructor() {
|
|
21
|
+
this._hasInitialized = false;
|
|
22
|
+
this._offlinePacks = {};
|
|
23
|
+
|
|
24
|
+
this._progressListeners = {};
|
|
25
|
+
this._errorListeners = {};
|
|
26
|
+
|
|
27
|
+
this._onProgress = this._onProgress.bind(this);
|
|
28
|
+
this._onError = this._onError.bind(this);
|
|
29
|
+
|
|
30
|
+
this.subscriptionProgress = null;
|
|
31
|
+
this.subscriptionError = null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates and registers an offline pack that downloads the resources needed to use the given region offline.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
*
|
|
39
|
+
* const progressListener = (offlineRegion, status) => console.log(offlineRegion, status);
|
|
40
|
+
* const errorListener = (offlineRegion, err) => console.log(offlineRegion, err);
|
|
41
|
+
*
|
|
42
|
+
* await MapboxGL.offlineManager.createPack({
|
|
43
|
+
* name: 'offlinePack',
|
|
44
|
+
* styleURL: 'mapbox://...',
|
|
45
|
+
* minZoom: 14,
|
|
46
|
+
* maxZoom: 20,
|
|
47
|
+
* bounds: [[neLng, neLat], [swLng, swLat]]
|
|
48
|
+
* }, progressListener, errorListener)
|
|
49
|
+
*
|
|
50
|
+
* @param {OfflineCreatePackOptions} options Create options for a offline pack that specifices zoom levels, style url, and the region to download.
|
|
51
|
+
* @param {Callback=} progressListener Callback that listens for status events while downloading the offline resource.
|
|
52
|
+
* @param {Callback=} errorListener Callback that listens for status events while downloading the offline resource.
|
|
53
|
+
* @return {void}
|
|
54
|
+
*/
|
|
55
|
+
async createPack(options, progressListener, errorListener) {
|
|
56
|
+
await this._initialize();
|
|
57
|
+
|
|
58
|
+
const packOptions = new OfflineCreatePackOptions(options);
|
|
59
|
+
|
|
60
|
+
if (this._offlinePacks[packOptions.name]) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Offline pack with name ${packOptions.name} already exists.`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.subscribe(packOptions.name, progressListener, errorListener);
|
|
67
|
+
const nativeOfflinePack = await MapboxGLOfflineManager.createPack(
|
|
68
|
+
packOptions,
|
|
69
|
+
);
|
|
70
|
+
this._offlinePacks[packOptions.name] = new OfflinePack(nativeOfflinePack);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated.
|
|
75
|
+
*
|
|
76
|
+
* This is more efficient than deleting the offline pack and downloading it again. If the data stored locally matches that on the server, new data will not be downloaded.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* await MapboxGL.offlineManager.invalidatePack('packName')
|
|
80
|
+
*
|
|
81
|
+
* @param {String} name Name of the offline pack.
|
|
82
|
+
* @return {void}
|
|
83
|
+
*/
|
|
84
|
+
async invalidatePack(name) {
|
|
85
|
+
if (!name) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await this._initialize();
|
|
90
|
+
|
|
91
|
+
const offlinePack = this._offlinePacks[name];
|
|
92
|
+
if (offlinePack) {
|
|
93
|
+
await MapboxGLOfflineManager.invalidatePack(name);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* await MapboxGL.offlineManager.deletePack('packName')
|
|
102
|
+
*
|
|
103
|
+
* @param {String} name Name of the offline pack.
|
|
104
|
+
* @return {void}
|
|
105
|
+
*/
|
|
106
|
+
async deletePack(name) {
|
|
107
|
+
if (!name) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
await this._initialize();
|
|
112
|
+
|
|
113
|
+
const offlinePack = this._offlinePacks[name];
|
|
114
|
+
if (offlinePack) {
|
|
115
|
+
await MapboxGLOfflineManager.deletePack(name);
|
|
116
|
+
delete this._offlinePacks[name];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.
|
|
122
|
+
* This is the recommend method for clearing the cache.
|
|
123
|
+
* This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.
|
|
124
|
+
* It does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* await MapboxGL.offlineManager.invalidateAmbientCache();
|
|
128
|
+
*
|
|
129
|
+
* @return {void}
|
|
130
|
+
*/
|
|
131
|
+
async invalidateAmbientCache() {
|
|
132
|
+
await this._initialize();
|
|
133
|
+
await MapboxGLOfflineManager.invalidateAmbientCache();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Erases resources from the ambient cache.
|
|
138
|
+
* This method clears the cache and decreases the amount of space that map resources take up on the device.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* await MapboxGL.offlineManager.clearAmbientCache();
|
|
142
|
+
*
|
|
143
|
+
* @return {void}
|
|
144
|
+
*/
|
|
145
|
+
async clearAmbientCache() {
|
|
146
|
+
await this._initialize();
|
|
147
|
+
await MapboxGLOfflineManager.clearAmbientCache();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Sets the maximum size of the ambient cache in bytes. Disables the ambient cache if set to 0.
|
|
152
|
+
* This method may be computationally expensive because it will erase resources from the ambient cache if its size is decreased.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* await MapboxGL.offlineManager.setMaximumAmbientCacheSize(5000000);
|
|
156
|
+
*
|
|
157
|
+
* @param {Number} size Size of ambient cache.
|
|
158
|
+
* @return {void}
|
|
159
|
+
*/
|
|
160
|
+
async setMaximumAmbientCacheSize(size) {
|
|
161
|
+
await this._initialize();
|
|
162
|
+
await MapboxGLOfflineManager.setMaximumAmbientCacheSize(size);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* await MapboxGL.offlineManager.resetDatabase();
|
|
170
|
+
*
|
|
171
|
+
* @return {void}
|
|
172
|
+
*/
|
|
173
|
+
async resetDatabase() {
|
|
174
|
+
await this._initialize();
|
|
175
|
+
await MapboxGLOfflineManager.resetDatabase();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Retrieves all the current offline packs that are stored in the database.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* const offlinePacks = await MapboxGL.offlineManager.getPacks();
|
|
183
|
+
*
|
|
184
|
+
* @return {Array<OfflinePack>}
|
|
185
|
+
*/
|
|
186
|
+
async getPacks() {
|
|
187
|
+
await this._initialize();
|
|
188
|
+
return Object.keys(this._offlinePacks).map(
|
|
189
|
+
name => this._offlinePacks[name],
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Retrieves an offline pack that is stored in the database by name.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* const offlinePack = await MapboxGL.offlineManager.getPack();
|
|
198
|
+
*
|
|
199
|
+
* @param {String} name Name of the offline pack.
|
|
200
|
+
* @return {OfflinePack}
|
|
201
|
+
*/
|
|
202
|
+
async getPack(name) {
|
|
203
|
+
await this._initialize();
|
|
204
|
+
return this._offlinePacks[name];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Sideloads offline db
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* await MapboxGL.offlineManager.mergeOfflineRegions(path);
|
|
212
|
+
*
|
|
213
|
+
* @param {String} path Path to offline tile db on file system.
|
|
214
|
+
* @return {void}
|
|
215
|
+
*/
|
|
216
|
+
async mergeOfflineRegions(path) {
|
|
217
|
+
await this._initialize();
|
|
218
|
+
return MapboxGLOfflineManager.mergeOfflineRegions(path);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Sets the maximum number of Mapbox-hosted tiles that may be downloaded and stored on the current device.
|
|
223
|
+
* The Mapbox Terms of Service prohibit changing or bypassing this limit without permission from Mapbox.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* MapboxGL.offlineManager.setTileCountLimit(1000);
|
|
227
|
+
*
|
|
228
|
+
* @param {Number} limit Map tile limit count.
|
|
229
|
+
* @return {void}
|
|
230
|
+
*/
|
|
231
|
+
setTileCountLimit(limit) {
|
|
232
|
+
MapboxGLOfflineManager.setTileCountLimit(limit);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Sets the period at which download status events will be sent over the React Native bridge.
|
|
237
|
+
* The default is 500ms.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* MapboxGL.offlineManager.setProgressEventThrottle(500);
|
|
241
|
+
*
|
|
242
|
+
* @param {Number} throttleValue event throttle value in ms.
|
|
243
|
+
* @return {void}
|
|
244
|
+
*/
|
|
245
|
+
setProgressEventThrottle(throttleValue) {
|
|
246
|
+
MapboxGLOfflineManager.setProgressEventThrottle(throttleValue);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Subscribe to download status/error events for the requested offline pack.
|
|
251
|
+
* Note that createPack calls this internally if listeners are provided.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* const progressListener = (offlinePack, status) => console.log(offlinePack, status)
|
|
255
|
+
* const errorListener = (offlinePack, err) => console.log(offlinePack, err)
|
|
256
|
+
* MapboxGL.offlineManager.subscribe('packName', progressListener, errorListener)
|
|
257
|
+
*
|
|
258
|
+
* @param {String} packName Name of the offline pack.
|
|
259
|
+
* @param {Callback} progressListener Callback that listens for status events while downloading the offline resource.
|
|
260
|
+
* @param {Callback} errorListener Callback that listens for status events while downloading the offline resource.
|
|
261
|
+
* @return {void}
|
|
262
|
+
*/
|
|
263
|
+
async subscribe(packName, progressListener, errorListener) {
|
|
264
|
+
const totalProgressListeners = Object.keys(this._progressListeners).length;
|
|
265
|
+
if (isFunction(progressListener)) {
|
|
266
|
+
if (totalProgressListeners === 0) {
|
|
267
|
+
this.subscriptionProgress = OfflineModuleEventEmitter.addListener(
|
|
268
|
+
MapboxGL.OfflineCallbackName.Progress,
|
|
269
|
+
this._onProgress,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
this._progressListeners[packName] = progressListener;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const totalErrorListeners = Object.keys(this._errorListeners).length;
|
|
276
|
+
if (isFunction(errorListener)) {
|
|
277
|
+
if (totalErrorListeners === 0) {
|
|
278
|
+
this.subscriptionError = OfflineModuleEventEmitter.addListener(
|
|
279
|
+
MapboxGL.OfflineCallbackName.Error,
|
|
280
|
+
this._onError,
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
this._errorListeners[packName] = errorListener;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// we need to manually set the pack observer on Android
|
|
287
|
+
// if we're resuming a pack download instead of going thru the create flow
|
|
288
|
+
if (isAndroid() && this._offlinePacks[packName]) {
|
|
289
|
+
try {
|
|
290
|
+
// manually set a listener, since listeners are only set on create flow
|
|
291
|
+
await MapboxGLOfflineManager.setPackObserver(packName);
|
|
292
|
+
} catch (e) {
|
|
293
|
+
console.log('Unable to set pack observer', e);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Unsubscribes any listeners associated with the offline pack.
|
|
300
|
+
* It's a good idea to call this on componentWillUnmount.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* MapboxGL.offlineManager.unsubscribe('packName')
|
|
304
|
+
*
|
|
305
|
+
* @param {String} packName Name of the offline pack.
|
|
306
|
+
* @return {void}
|
|
307
|
+
*/
|
|
308
|
+
unsubscribe(packName) {
|
|
309
|
+
delete this._progressListeners[packName];
|
|
310
|
+
delete this._errorListeners[packName];
|
|
311
|
+
|
|
312
|
+
if (
|
|
313
|
+
Object.keys(this._progressListeners).length === 0 &&
|
|
314
|
+
this.subscriptionProgress
|
|
315
|
+
) {
|
|
316
|
+
this.subscriptionProgress.remove();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (
|
|
320
|
+
Object.keys(this._errorListeners).length === 0 &&
|
|
321
|
+
this.subscriptionError
|
|
322
|
+
) {
|
|
323
|
+
this.subscriptionError.remove();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async _initialize() {
|
|
328
|
+
if (this._hasInitialized) {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const nativeOfflinePacks = await MapboxGLOfflineManager.getPacks();
|
|
333
|
+
|
|
334
|
+
for (const nativeOfflinePack of nativeOfflinePacks) {
|
|
335
|
+
const offlinePack = new OfflinePack(nativeOfflinePack);
|
|
336
|
+
this._offlinePacks[offlinePack.name] = offlinePack;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
this._hasInitialized = true;
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
_onProgress(e) {
|
|
344
|
+
const {name, state} = e.payload;
|
|
345
|
+
|
|
346
|
+
if (!this._hasListeners(name, this._progressListeners)) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const pack = this._offlinePacks[name];
|
|
351
|
+
this._progressListeners[name](pack, e.payload);
|
|
352
|
+
|
|
353
|
+
// cleanup listeners now that they are no longer needed
|
|
354
|
+
if (state === MapboxGL.OfflinePackDownloadState.Complete) {
|
|
355
|
+
this.unsubscribe(name);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
_onError(e) {
|
|
360
|
+
const {name} = e.payload;
|
|
361
|
+
|
|
362
|
+
if (!this._hasListeners(name, this._errorListeners)) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const pack = this._offlinePacks[name];
|
|
367
|
+
this._errorListeners[name](pack, e.payload);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
_hasListeners(name, listenerMap) {
|
|
371
|
+
return (
|
|
372
|
+
!isUndefined(this._offlinePacks[name]) && isFunction(listenerMap[name])
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const offlineManager = new OfflineManager();
|
|
378
|
+
export default offlineManager;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {toJSONString} from '../../utils';
|
|
2
|
+
import {makePoint, makeFeatureCollection} from '../../utils/geoUtils';
|
|
3
|
+
|
|
4
|
+
import {NativeModules} from 'react-native';
|
|
5
|
+
|
|
6
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
7
|
+
|
|
8
|
+
class SnapshotOptions {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
if (!options.centerCoordinate && !options.bounds) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
'Center coordinate or bounds must be supplied in order to take a snapshot',
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.styleURL = options.styleURL || MapboxGL.StyleURL.Street;
|
|
17
|
+
this.heading = options.heading || 0.0;
|
|
18
|
+
this.pitch = options.pitch || 0.0;
|
|
19
|
+
this.zoomLevel = options.zoomLevel || 16.0;
|
|
20
|
+
this.width = options.width || 50.0;
|
|
21
|
+
this.height = options.height || 50.0;
|
|
22
|
+
this.writeToDisk = options.writeToDisk || false;
|
|
23
|
+
this.withLogo = options.withLogo === undefined ? true : options.withLogo;
|
|
24
|
+
|
|
25
|
+
if (options.centerCoordinate) {
|
|
26
|
+
this.centerCoordinate = this._createCenterCoordPoint(
|
|
27
|
+
options.centerCoordinate,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (options.bounds) {
|
|
32
|
+
this.bounds = this._createBoundsCollection(options.bounds);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toJSON() {
|
|
37
|
+
return {
|
|
38
|
+
styleURL: this.styleURL,
|
|
39
|
+
heading: this.heading,
|
|
40
|
+
pitch: this.pitch,
|
|
41
|
+
zoomLevel: this.zoomLevel,
|
|
42
|
+
width: this.width,
|
|
43
|
+
height: this.height,
|
|
44
|
+
writeToDisk: this.writeToDisk,
|
|
45
|
+
centerCoordinate: this.centerCoordinate,
|
|
46
|
+
bounds: this.bounds,
|
|
47
|
+
withLogo: this.withLogo,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_createCenterCoordPoint(centerCoordinate) {
|
|
52
|
+
const point = makePoint(centerCoordinate);
|
|
53
|
+
return toJSONString(point);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_createBoundsCollection(bounds) {
|
|
57
|
+
const features = [];
|
|
58
|
+
|
|
59
|
+
for (const bound of bounds) {
|
|
60
|
+
features.push(makePoint(bound));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return toJSONString(makeFeatureCollection(features));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default SnapshotOptions;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import SnapshotOptions from './SnapshotOptions';
|
|
2
|
+
|
|
3
|
+
import {NativeModules} from 'react-native';
|
|
4
|
+
|
|
5
|
+
const MapboxGLSnapshotManger = NativeModules.MGLSnapshotModule;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The snapshotManager generates static raster images of the map.
|
|
9
|
+
* Each snapshot image depicts a portion of a map defined by an SnapshotOptions object you provide.
|
|
10
|
+
* The snapshotter generates the snapshot asynchronous.
|
|
11
|
+
*/
|
|
12
|
+
class SnapshotManager {
|
|
13
|
+
/**
|
|
14
|
+
* Takes a snapshot of the base map using the provided Snapshot options. NOTE pitch, heading, zoomLevel only works when centerCoordinate is set!
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* // creates a temp file png of base map
|
|
19
|
+
* const uri = await MapboxGL.snapshotManager.takeSnap({
|
|
20
|
+
* centerCoordinate: [-74.126410, 40.797968],
|
|
21
|
+
* width: width,
|
|
22
|
+
* height: height,
|
|
23
|
+
* zoomLevel: 12,
|
|
24
|
+
* pitch: 30,
|
|
25
|
+
* heading: 20,
|
|
26
|
+
* styleURL: MapboxGL.StyleURL.Dark,
|
|
27
|
+
* writeToDisk: true, // Create a temporary file
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // creates base64 png of base map without logo
|
|
31
|
+
* const uri = await MapboxGL.snapshotManager.takeSnap({
|
|
32
|
+
* centerCoordinate: [-74.126410, 40.797968],
|
|
33
|
+
* width: width,
|
|
34
|
+
* height: height,
|
|
35
|
+
* zoomLevel: 12,
|
|
36
|
+
* pitch: 30,
|
|
37
|
+
* heading: 20,
|
|
38
|
+
* styleURL: MapboxGL.StyleURL.Dark,
|
|
39
|
+
* withLogo: false, // Disable Mapbox logo (Android only)
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // creates snapshot with bounds
|
|
43
|
+
* const uri = await MapboxGL.snapshotManager.takeSnap({
|
|
44
|
+
* bounds: [[-74.126410, 40.797968], [-74.143727, 40.772177]],
|
|
45
|
+
* width: width,
|
|
46
|
+
* height: height,
|
|
47
|
+
* styleURL: MapboxGL.StyleURL.Dark,
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* @param {SnapshotOptions} options Snapshot options for create a static image of the base map
|
|
51
|
+
* @return {Promise}
|
|
52
|
+
*/
|
|
53
|
+
async takeSnap(options = {}) {
|
|
54
|
+
const snapshotOptions = new SnapshotOptions(options);
|
|
55
|
+
|
|
56
|
+
const uri = await MapboxGLSnapshotManger.takeSnap(snapshotOptions);
|
|
57
|
+
return uri;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const snapshotManager = new SnapshotManager();
|
|
62
|
+
export default snapshotManager;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {isBoolean, isNumber, isString} from './index';
|
|
2
|
+
|
|
3
|
+
const Types = {
|
|
4
|
+
Array: 'array',
|
|
5
|
+
Bool: 'boolean',
|
|
6
|
+
Number: 'number',
|
|
7
|
+
String: 'string',
|
|
8
|
+
HashMap: 'hashmap',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default class BridgeValue {
|
|
12
|
+
constructor(rawValue) {
|
|
13
|
+
this.rawValue = rawValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get type() {
|
|
17
|
+
if (Array.isArray(this.rawValue)) {
|
|
18
|
+
return Types.Array;
|
|
19
|
+
}
|
|
20
|
+
if (isBoolean(this.rawValue)) {
|
|
21
|
+
return Types.Bool;
|
|
22
|
+
}
|
|
23
|
+
if (isNumber(this.rawValue)) {
|
|
24
|
+
return Types.Number;
|
|
25
|
+
}
|
|
26
|
+
if (isString(this.rawValue)) {
|
|
27
|
+
return Types.String;
|
|
28
|
+
}
|
|
29
|
+
if (this.rawValue && typeof this.rawValue === 'object') {
|
|
30
|
+
return Types.HashMap;
|
|
31
|
+
}
|
|
32
|
+
throw new Error(
|
|
33
|
+
`[type - ${this.rawValue}] BridgeValue must be a primitive/array/object`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get value() {
|
|
38
|
+
const {type} = this;
|
|
39
|
+
|
|
40
|
+
let value;
|
|
41
|
+
|
|
42
|
+
if (type === Types.Array) {
|
|
43
|
+
value = [];
|
|
44
|
+
|
|
45
|
+
for (const innerRawValue of this.rawValue) {
|
|
46
|
+
const bridgeValue = new BridgeValue(innerRawValue);
|
|
47
|
+
value.push(bridgeValue.toJSON());
|
|
48
|
+
}
|
|
49
|
+
} else if (type === Types.HashMap) {
|
|
50
|
+
value = [];
|
|
51
|
+
|
|
52
|
+
const stringKeys = Object.keys(this.rawValue);
|
|
53
|
+
for (const stringKey of stringKeys) {
|
|
54
|
+
value.push([
|
|
55
|
+
new BridgeValue(stringKey).toJSON(),
|
|
56
|
+
new BridgeValue(this.rawValue[stringKey]).toJSON(),
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
} else if (
|
|
60
|
+
type === Types.Bool ||
|
|
61
|
+
type === Types.Number ||
|
|
62
|
+
type === Types.String
|
|
63
|
+
) {
|
|
64
|
+
value = this.rawValue;
|
|
65
|
+
} else {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`[value - ${this.rawValue}] BridgeValue must be a primitive/array/object`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
toJSON(formatter) {
|
|
75
|
+
return {
|
|
76
|
+
type: this.type,
|
|
77
|
+
value:
|
|
78
|
+
typeof formatter === 'function' ? formatter(this.value) : this.value,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {NativeEventEmitter, NativeModules} from 'react-native';
|
|
2
|
+
const {MGLLogging} = NativeModules;
|
|
3
|
+
|
|
4
|
+
class Logger {
|
|
5
|
+
static instance = null;
|
|
6
|
+
|
|
7
|
+
static sharedInstance() {
|
|
8
|
+
if (this.instance === null) {
|
|
9
|
+
this.instance = new Logger();
|
|
10
|
+
}
|
|
11
|
+
return this.instance;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this.loggerEmitter = new NativeEventEmitter(MGLLogging);
|
|
16
|
+
this.startedCount = 0;
|
|
17
|
+
this.logCallback = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Set custom logger function.
|
|
22
|
+
* @param {Logger~logCallback} logCallback - callback taking a log object as param. If callback return falsy value then
|
|
23
|
+
* default logging will take place.
|
|
24
|
+
*/
|
|
25
|
+
static setLogCallback(logCallback) {
|
|
26
|
+
this.sharedInstance().setLogCallback(logCallback);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Set custom logger function.
|
|
31
|
+
* @param {Logger~logCallback} logCallback - callback taking a log object as param. If callback return falsy value then
|
|
32
|
+
* default logging will take place.
|
|
33
|
+
*/
|
|
34
|
+
setLogCallback(logCallback) {
|
|
35
|
+
this.logCallback = logCallback;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This callback is displayed as part of the Requester class.
|
|
40
|
+
* @callback Logger~logCallback
|
|
41
|
+
* @param {object} log
|
|
42
|
+
* @param {string} log.message - the message of the log
|
|
43
|
+
* @param {string} log.level - log level
|
|
44
|
+
* @param {string} log.tag - optional tag used on android
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* setLogLevel
|
|
49
|
+
* @param {LogLevel} level
|
|
50
|
+
*/
|
|
51
|
+
static setLogLevel(level) {
|
|
52
|
+
MGLLogging.setLogLevel(level);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @type {('error'|'warning'|'info'|'debug'|'verbose')} LogLevel - Supported log levels
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
start() {
|
|
60
|
+
if (this.startedCount === 0) {
|
|
61
|
+
this.subscribe();
|
|
62
|
+
}
|
|
63
|
+
this.startedCount += 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
stop() {
|
|
67
|
+
this.startedCount -= 1;
|
|
68
|
+
if (this.startedCount === 0) {
|
|
69
|
+
this.unsubscribe();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
subscribe() {
|
|
74
|
+
this.subscription = this.loggerEmitter.addListener('LogEvent', log => {
|
|
75
|
+
this.onLog(log);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
unsubscribe() {
|
|
80
|
+
this.subscription.remove();
|
|
81
|
+
this.subscription = null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
effectiveLevel(log) {
|
|
85
|
+
let {level, message, tag} = log;
|
|
86
|
+
|
|
87
|
+
if (level === 'warning') {
|
|
88
|
+
if (
|
|
89
|
+
tag === 'Mbgl-HttpRequest' &&
|
|
90
|
+
message.startsWith('Request failed due to a permanent error: Canceled')
|
|
91
|
+
) {
|
|
92
|
+
// this seems to happening too much to show a warning every time
|
|
93
|
+
return 'info';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return level;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
onLog(log) {
|
|
100
|
+
if (!this.logCallback || !this.logCallback(log)) {
|
|
101
|
+
let {message} = log;
|
|
102
|
+
let level = this.effectiveLevel(log);
|
|
103
|
+
if (level === 'error') {
|
|
104
|
+
console.error('Mapbox error', message, log);
|
|
105
|
+
} else if (level === 'warning') {
|
|
106
|
+
console.warn('Mapbox warning', message, log);
|
|
107
|
+
} else {
|
|
108
|
+
console.log(`Mapbox [${level}]`, message, log);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default Logger;
|