@rnmapbox/maps 10.0.0-beta.73 → 10.0.0-beta.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +61 -46
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/LocationComponentManager.kt +4 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +7 -2
- package/index.d.ts +46 -328
- package/javascript/components/AbstractLayer.tsx +2 -1
- package/javascript/components/AbstractSource.tsx +3 -1
- package/javascript/components/Atmosphere.tsx +2 -1
- package/javascript/components/Camera.tsx +6 -4
- package/javascript/components/ImageSource.tsx +81 -0
- package/javascript/components/Images.tsx +1 -1
- package/javascript/components/Light.tsx +60 -0
- package/javascript/components/{MapView.js → MapView.tsx} +456 -383
- package/javascript/components/NativeBridgeComponent.tsx +1 -1
- package/javascript/components/PointAnnotation.tsx +2 -1
- package/javascript/components/RasterDemSource.tsx +105 -0
- package/javascript/components/RasterSource.tsx +124 -0
- package/javascript/components/ShapeSource.tsx +1 -11
- package/javascript/components/Terrain.tsx +2 -1
- package/javascript/components/VectorSource.tsx +209 -0
- package/javascript/modules/location/locationManager.ts +1 -1
- package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +21 -6
- package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +19 -4
- package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +77 -21
- package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +27 -3
- package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +1 -1
- package/javascript/types/BaseProps.ts +3 -0
- package/javascript/types/OnPressEvent.ts +11 -0
- package/javascript/utils/{Logger.js → Logger.ts} +32 -14
- package/javascript/utils/MapboxStyles.d.ts +1 -1
- package/javascript/utils/deprecation.ts +3 -3
- package/javascript/utils/geoUtils.ts +91 -0
- package/javascript/utils/{index.js → index.ts} +41 -19
- package/javascript/utils/nativeRef.ts +28 -0
- package/lib/commonjs/components/AbstractLayer.js.map +1 -1
- package/lib/commonjs/components/AbstractSource.js.map +1 -1
- package/lib/commonjs/components/Atmosphere.js.map +1 -1
- package/lib/commonjs/components/Camera.js +4 -4
- package/lib/commonjs/components/Camera.js.map +1 -1
- package/lib/commonjs/components/ImageSource.js +8 -25
- package/lib/commonjs/components/ImageSource.js.map +1 -1
- package/lib/commonjs/components/Images.js +1 -1
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/commonjs/components/Light.js +32 -33
- package/lib/commonjs/components/Light.js.map +1 -1
- package/lib/commonjs/components/MapView.js +30 -289
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/commonjs/components/NativeBridgeComponent.js.map +1 -1
- package/lib/commonjs/components/PointAnnotation.js.map +1 -1
- package/lib/commonjs/components/RasterDemSource.js +3 -37
- package/lib/commonjs/components/RasterDemSource.js.map +1 -1
- package/lib/commonjs/components/RasterSource.js +2 -46
- package/lib/commonjs/components/RasterSource.js.map +1 -1
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/Terrain.js.map +1 -1
- package/lib/commonjs/components/VectorSource.js +15 -74
- package/lib/commonjs/components/VectorSource.js.map +1 -1
- package/lib/commonjs/modules/location/locationManager.js +2 -1
- package/lib/commonjs/modules/location/locationManager.js.map +1 -1
- package/lib/commonjs/modules/offline/OfflineCreatePackOptions.js +2 -4
- package/lib/commonjs/modules/offline/OfflineCreatePackOptions.js.map +1 -1
- package/lib/commonjs/modules/offline/OfflinePack.js.map +1 -1
- package/lib/commonjs/modules/offline/offlineManager.js +1 -2
- package/lib/commonjs/modules/offline/offlineManager.js.map +1 -1
- package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
- package/lib/commonjs/modules/snapshot/snapshotManager.js.map +1 -1
- package/lib/commonjs/types/BaseProps.js +2 -0
- package/lib/commonjs/{utils/index.d.js.map → types/BaseProps.js.map} +1 -1
- package/lib/commonjs/types/OnPressEvent.js +2 -0
- package/lib/commonjs/{utils/geoUtils.d.js.map → types/OnPressEvent.js.map} +1 -1
- package/lib/commonjs/utils/Logger.js +7 -7
- package/lib/commonjs/utils/Logger.js.map +1 -1
- package/lib/commonjs/utils/deprecation.js +2 -2
- package/lib/commonjs/utils/geoUtils.js +15 -23
- package/lib/commonjs/utils/geoUtils.js.map +1 -1
- package/lib/commonjs/utils/index.js +3 -6
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/nativeRef.js +27 -0
- package/lib/commonjs/utils/nativeRef.js.map +1 -0
- package/lib/module/components/AbstractLayer.js.map +1 -1
- package/lib/module/components/AbstractSource.js.map +1 -1
- package/lib/module/components/Atmosphere.js.map +1 -1
- package/lib/module/components/Camera.js +4 -4
- package/lib/module/components/Camera.js.map +1 -1
- package/lib/module/components/ImageSource.js +8 -25
- package/lib/module/components/ImageSource.js.map +1 -1
- package/lib/module/components/Images.js +1 -1
- package/lib/module/components/Images.js.map +1 -1
- package/lib/module/components/Light.js +29 -32
- package/lib/module/components/Light.js.map +1 -1
- package/lib/module/components/MapView.js +31 -290
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/NativeBridgeComponent.js.map +1 -1
- package/lib/module/components/PointAnnotation.js.map +1 -1
- package/lib/module/components/RasterDemSource.js +4 -38
- package/lib/module/components/RasterDemSource.js.map +1 -1
- package/lib/module/components/RasterSource.js +3 -47
- package/lib/module/components/RasterSource.js.map +1 -1
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/Terrain.js.map +1 -1
- package/lib/module/components/VectorSource.js +15 -74
- package/lib/module/components/VectorSource.js.map +1 -1
- package/lib/module/modules/location/locationManager.js +1 -1
- package/lib/module/modules/location/locationManager.js.map +1 -1
- package/lib/module/modules/offline/OfflineCreatePackOptions.js +2 -4
- package/lib/module/modules/offline/OfflineCreatePackOptions.js.map +1 -1
- package/lib/module/modules/offline/OfflinePack.js.map +1 -1
- package/lib/module/modules/offline/offlineManager.js +0 -1
- package/lib/module/modules/offline/offlineManager.js.map +1 -1
- package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
- package/lib/module/modules/snapshot/snapshotManager.js.map +1 -1
- package/lib/module/types/BaseProps.js +2 -0
- package/lib/module/{utils/index.d.js.map → types/BaseProps.js.map} +1 -1
- package/lib/module/types/OnPressEvent.js +2 -0
- package/lib/module/{utils/geoUtils.d.js.map → types/OnPressEvent.js.map} +1 -1
- package/lib/module/utils/Logger.js +7 -7
- package/lib/module/utils/Logger.js.map +1 -1
- package/lib/module/utils/deprecation.js +2 -2
- package/lib/module/utils/geoUtils.js +7 -18
- package/lib/module/utils/geoUtils.js.map +1 -1
- package/lib/module/utils/index.js +3 -5
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/nativeRef.js +21 -0
- package/lib/module/utils/nativeRef.js.map +1 -0
- package/lib/typescript/components/AbstractLayer.d.ts +2 -1
- package/lib/typescript/components/AbstractLayer.d.ts.map +1 -1
- package/lib/typescript/components/AbstractSource.d.ts +2 -1
- package/lib/typescript/components/AbstractSource.d.ts.map +1 -1
- package/lib/typescript/components/Atmosphere.d.ts +2 -1
- package/lib/typescript/components/Atmosphere.d.ts.map +1 -1
- package/lib/typescript/components/Camera.d.ts.map +1 -1
- package/lib/typescript/components/ImageSource.d.ts +32 -0
- package/lib/typescript/components/ImageSource.d.ts.map +1 -0
- package/lib/typescript/components/Images.d.ts +1 -1
- package/lib/typescript/components/Images.d.ts.map +1 -1
- package/lib/typescript/components/Light.d.ts +17 -0
- package/lib/typescript/components/Light.d.ts.map +1 -0
- package/lib/typescript/components/MapView.d.ts +472 -0
- package/lib/typescript/components/MapView.d.ts.map +1 -0
- package/lib/typescript/components/NativeBridgeComponent.d.ts +1 -1
- package/lib/typescript/components/NativeBridgeComponent.d.ts.map +1 -1
- package/lib/typescript/components/PointAnnotation.d.ts +3 -2
- package/lib/typescript/components/PointAnnotation.d.ts.map +1 -1
- package/lib/typescript/components/RasterDemSource.d.ts +46 -0
- package/lib/typescript/components/RasterDemSource.d.ts.map +1 -0
- package/lib/typescript/components/RasterSource.d.ts +59 -0
- package/lib/typescript/components/RasterSource.d.ts.map +1 -0
- package/lib/typescript/components/ShapeSource.d.ts +4 -14
- package/lib/typescript/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/components/Terrain.d.ts +2 -1
- package/lib/typescript/components/Terrain.d.ts.map +1 -1
- package/lib/typescript/components/VectorSource.d.ts +144 -0
- package/lib/typescript/components/VectorSource.d.ts.map +1 -0
- package/lib/typescript/modules/location/locationManager.d.ts +1 -1
- package/lib/typescript/modules/location/locationManager.d.ts.map +1 -1
- package/lib/typescript/modules/offline/OfflineCreatePackOptions.d.ts +22 -0
- package/lib/typescript/modules/offline/OfflineCreatePackOptions.d.ts.map +1 -0
- package/lib/typescript/modules/offline/OfflinePack.d.ts +24 -0
- package/lib/typescript/modules/offline/OfflinePack.d.ts.map +1 -0
- package/lib/typescript/modules/offline/offlineManager.d.ts +219 -0
- package/lib/typescript/modules/offline/offlineManager.d.ts.map +1 -0
- package/lib/typescript/modules/snapshot/SnapshotOptions.d.ts +41 -0
- package/lib/typescript/modules/snapshot/SnapshotOptions.d.ts.map +1 -0
- package/lib/typescript/modules/snapshot/snapshotManager.d.ts +51 -0
- package/lib/typescript/modules/snapshot/snapshotManager.d.ts.map +1 -0
- package/lib/typescript/types/BaseProps.d.ts +4 -0
- package/lib/typescript/types/BaseProps.d.ts.map +1 -0
- package/lib/typescript/types/OnPressEvent.d.ts +12 -0
- package/lib/typescript/types/OnPressEvent.d.ts.map +1 -0
- package/lib/typescript/utils/Logger.d.ts +53 -0
- package/lib/typescript/utils/Logger.d.ts.map +1 -0
- package/lib/typescript/utils/deprecation.d.ts +4 -3
- package/lib/typescript/utils/deprecation.d.ts.map +1 -1
- package/lib/typescript/utils/geoUtils.d.ts +23 -0
- package/lib/typescript/utils/geoUtils.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +48 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/nativeRef.d.ts +21 -0
- package/lib/typescript/utils/nativeRef.d.ts.map +1 -0
- package/package.json +3 -1
- package/javascript/components/ImageSource.js +0 -82
- package/javascript/components/Light.js +0 -47
- package/javascript/components/RasterDemSource.js +0 -106
- package/javascript/components/RasterSource.js +0 -124
- package/javascript/components/VectorSource.js +0 -203
- package/javascript/utils/geoUtils.d.ts +0 -10
- package/javascript/utils/geoUtils.js +0 -73
- package/javascript/utils/index.d.ts +0 -27
- package/lib/commonjs/utils/geoUtils.d.js +0 -2
- package/lib/commonjs/utils/index.d.js +0 -2
- package/lib/module/utils/geoUtils.d.js +0 -2
- package/lib/module/utils/index.d.js +0 -2
|
@@ -9,6 +9,7 @@ import { type Feature } from 'geojson';
|
|
|
9
9
|
|
|
10
10
|
import { toJSONString, isFunction } from '../utils';
|
|
11
11
|
import { makePoint } from '../utils/geoUtils';
|
|
12
|
+
import { type BaseProps } from '../types/BaseProps';
|
|
12
13
|
|
|
13
14
|
import NativeBridgeComponent, { type RNMBEvent } from './NativeBridgeComponent';
|
|
14
15
|
|
|
@@ -26,7 +27,7 @@ type FeaturePayload = {
|
|
|
26
27
|
feature: Feature;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
type Props = {
|
|
30
|
+
type Props = BaseProps & {
|
|
30
31
|
/**
|
|
31
32
|
* A string that uniquely identifies the annotation
|
|
32
33
|
*/
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { cloneReactChildrenWithProps } from '../utils';
|
|
5
|
+
|
|
6
|
+
import AbstractSource from './AbstractSource';
|
|
7
|
+
|
|
8
|
+
const isTileTemplateUrl = (url?: string): url is string =>
|
|
9
|
+
!!url &&
|
|
10
|
+
(url.includes('{z}') || url.includes('{bbox-') || url.includes('{quadkey}'));
|
|
11
|
+
|
|
12
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
13
|
+
|
|
14
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLRasterDemSource';
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* A string that uniquely identifies the source.
|
|
19
|
+
*/
|
|
20
|
+
id: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A URL to a TileJSON configuration file describing the source’s contents and other metadata.
|
|
24
|
+
*/
|
|
25
|
+
url?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.
|
|
29
|
+
* Example: https://example.com/raster-tiles/{z}/{x}/{y}.png
|
|
30
|
+
*/
|
|
31
|
+
tileUrlTemplates?: string[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
|
|
35
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
36
|
+
* maxZoomLevel, if specified. The default value for this option is 0.
|
|
37
|
+
*/
|
|
38
|
+
minZoomLevel?: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
|
|
42
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
43
|
+
* minZoomLevel, if specified. The default value for this option is 22.
|
|
44
|
+
*/
|
|
45
|
+
maxZoomLevel?: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Size of the map tiles.
|
|
49
|
+
* Mapbox urls default to 256, all others default to 512.
|
|
50
|
+
*/
|
|
51
|
+
tileSize?: number;
|
|
52
|
+
|
|
53
|
+
children?: React.ReactElement | React.ReactElement[];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
type NativeProps = Props;
|
|
57
|
+
|
|
58
|
+
class RasterDemSource extends AbstractSource<Props, NativeProps> {
|
|
59
|
+
static defaultProps = {
|
|
60
|
+
id: MapboxGL.StyleSource.DefaultSourceID,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
constructor(props: Props) {
|
|
64
|
+
super(props);
|
|
65
|
+
if (isTileTemplateUrl(props.url)) {
|
|
66
|
+
console.warn(
|
|
67
|
+
`RasterDemSource 'url' property contains a Tile URL Template, but is intended for a StyleJSON URL. Please migrate your VectorSource to use: \`tileUrlTemplates=["${props.url}"]\` instead.`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
let { url } = this.props;
|
|
74
|
+
let { tileUrlTemplates } = this.props;
|
|
75
|
+
|
|
76
|
+
// Swapping url for tileUrlTemplates to provide backward compatibility
|
|
77
|
+
// when RasterSource supported only tile url as url prop
|
|
78
|
+
if (isTileTemplateUrl(url)) {
|
|
79
|
+
tileUrlTemplates = [url];
|
|
80
|
+
url = undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const props = {
|
|
84
|
+
...this.props,
|
|
85
|
+
id: this.props.id,
|
|
86
|
+
url,
|
|
87
|
+
tileUrlTemplates,
|
|
88
|
+
minZoomLevel: this.props.minZoomLevel,
|
|
89
|
+
maxZoomLevel: this.props.maxZoomLevel,
|
|
90
|
+
tileSize: this.props.tileSize,
|
|
91
|
+
};
|
|
92
|
+
return (
|
|
93
|
+
<RCTMGLRasterDemSource ref={this.setNativeRef} {...props}>
|
|
94
|
+
{cloneReactChildrenWithProps(this.props.children, {
|
|
95
|
+
sourceID: this.props.id,
|
|
96
|
+
})}
|
|
97
|
+
</RCTMGLRasterDemSource>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const RCTMGLRasterDemSource =
|
|
103
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
104
|
+
|
|
105
|
+
export default RasterDemSource;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { cloneReactChildrenWithProps } from '../utils';
|
|
5
|
+
import { BaseProps } from '../types/BaseProps';
|
|
6
|
+
|
|
7
|
+
import AbstractSource from './AbstractSource';
|
|
8
|
+
|
|
9
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
10
|
+
|
|
11
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLRasterSource';
|
|
12
|
+
|
|
13
|
+
const isTileTemplateUrl = (url?: string): url is string =>
|
|
14
|
+
!!url &&
|
|
15
|
+
(url.includes('{z}') || url.includes('{bbox-') || url.includes('{quadkey}'));
|
|
16
|
+
|
|
17
|
+
type Props = BaseProps & {
|
|
18
|
+
/**
|
|
19
|
+
* A string that uniquely identifies the source.
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A URL to a TileJSON configuration file describing the source’s contents and other metadata.
|
|
25
|
+
*/
|
|
26
|
+
url?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.
|
|
30
|
+
* Example: https://example.com/raster-tiles/{z}/{x}/{y}.png
|
|
31
|
+
*/
|
|
32
|
+
tileUrlTemplates?: string[];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
|
|
36
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
37
|
+
* maxZoomLevel, if specified. The default value for this option is 0.
|
|
38
|
+
*/
|
|
39
|
+
minZoomLevel?: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
|
|
43
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
44
|
+
* minZoomLevel, if specified. The default value for this option is 22.
|
|
45
|
+
*/
|
|
46
|
+
maxZoomLevel?: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Size of the map tiles.
|
|
50
|
+
* Mapbox urls default to 256, all others default to 512.
|
|
51
|
+
*/
|
|
52
|
+
tileSize?: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Influences the y direction of the tile coordinates. (tms inverts y axis)
|
|
56
|
+
*/
|
|
57
|
+
tms?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* An HTML or literal text string defining the buttons to be displayed in an action sheet when the
|
|
61
|
+
* source is part of a map view’s style and the map view’s attribution button is pressed.
|
|
62
|
+
*/
|
|
63
|
+
attribution?: string;
|
|
64
|
+
|
|
65
|
+
children?: React.ReactElement | React.ReactElement[];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type NativeProps = Props;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* RasterSource is a map content source that supplies raster image tiles to be shown on the map.
|
|
72
|
+
* The location of and metadata about the tiles are defined either by an option dictionary
|
|
73
|
+
* or by an external file that conforms to the TileJSON specification.
|
|
74
|
+
*/
|
|
75
|
+
class RasterSource extends AbstractSource<Props, NativeProps> {
|
|
76
|
+
static defaultProps: Props = {
|
|
77
|
+
id: MapboxGL.StyleSource.DefaultSourceID,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
constructor(props: Props) {
|
|
81
|
+
super(props);
|
|
82
|
+
if (isTileTemplateUrl(props.url)) {
|
|
83
|
+
console.warn(
|
|
84
|
+
`RasterSource 'url' property contains a Tile URL Template, but is intended for a StyleJSON URL. Please migrate your VectorSource to use: \`tileUrlTemplates=["${props.url}"]\` instead.`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
render() {
|
|
90
|
+
let { url } = this.props;
|
|
91
|
+
let { tileUrlTemplates } = this.props;
|
|
92
|
+
|
|
93
|
+
// Swapping url for tileUrlTemplates to provide backward compatibility
|
|
94
|
+
// when RasterSource supported only tile url as url prop
|
|
95
|
+
if (isTileTemplateUrl(url)) {
|
|
96
|
+
tileUrlTemplates = [url];
|
|
97
|
+
url = undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const props = {
|
|
101
|
+
...this.props,
|
|
102
|
+
id: this.props.id,
|
|
103
|
+
url,
|
|
104
|
+
tileUrlTemplates,
|
|
105
|
+
minZoomLevel: this.props.minZoomLevel,
|
|
106
|
+
maxZoomLevel: this.props.maxZoomLevel,
|
|
107
|
+
tileSize: this.props.tileSize,
|
|
108
|
+
tms: this.props.tms,
|
|
109
|
+
attribution: this.props.attribution,
|
|
110
|
+
};
|
|
111
|
+
return (
|
|
112
|
+
<RCTMGLRasterSource ref={this.setNativeRef} {...props}>
|
|
113
|
+
{cloneReactChildrenWithProps(this.props.children, {
|
|
114
|
+
sourceID: this.props.id,
|
|
115
|
+
})}
|
|
116
|
+
</RCTMGLRasterSource>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const RCTMGLRasterSource =
|
|
122
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
123
|
+
|
|
124
|
+
export default RasterSource;
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isAndroid,
|
|
15
15
|
} from '../utils';
|
|
16
16
|
import { copyPropertiesAsDeprecated } from '../utils/deprecation';
|
|
17
|
+
import { OnPressEvent } from '../types/OnPressEvent';
|
|
17
18
|
|
|
18
19
|
import AbstractSource from './AbstractSource';
|
|
19
20
|
import NativeBridgeComponent from './NativeBridgeComponent';
|
|
@@ -22,17 +23,6 @@ const MapboxGL = NativeModules.MGLModule;
|
|
|
22
23
|
|
|
23
24
|
export const NATIVE_MODULE_NAME = 'RCTMGLShapeSource';
|
|
24
25
|
|
|
25
|
-
export type OnPressEvent = {
|
|
26
|
-
features: Array<GeoJSON.Feature>;
|
|
27
|
-
coordinates: {
|
|
28
|
-
latitude: number;
|
|
29
|
-
longitude: number;
|
|
30
|
-
};
|
|
31
|
-
point: {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
26
|
type OnPressEventDeprecated = OnPressEvent & {
|
|
37
27
|
nativeEvent?: OnPressEvent;
|
|
38
28
|
};
|
|
@@ -3,10 +3,11 @@ import { HostComponent, requireNativeComponent } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import type { TerrainLayerStyleProps, Value } from '../utils/MapboxStyles';
|
|
5
5
|
import { StyleValue, transformStyle } from '../utils/StyleValue';
|
|
6
|
+
import type { BaseProps } from '../types/BaseProps';
|
|
6
7
|
|
|
7
8
|
export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';
|
|
8
9
|
|
|
9
|
-
type Props = {
|
|
10
|
+
type Props = BaseProps & {
|
|
10
11
|
/**
|
|
11
12
|
* Name of a source of raster_dem type to be used for terrain elevation.
|
|
12
13
|
*/
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
NativeMethods,
|
|
4
|
+
NativeModules,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
requireNativeComponent,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { cloneReactChildrenWithProps, isFunction, isAndroid } from '../utils';
|
|
10
|
+
import { getFilter } from '../utils/filterUtils';
|
|
11
|
+
import { copyPropertiesAsDeprecated } from '../utils/deprecation';
|
|
12
|
+
import { OnPressEvent } from '../types/OnPressEvent';
|
|
13
|
+
|
|
14
|
+
import AbstractSource from './AbstractSource';
|
|
15
|
+
import NativeBridgeComponent from './NativeBridgeComponent';
|
|
16
|
+
|
|
17
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
18
|
+
|
|
19
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
/**
|
|
23
|
+
* A string that uniquely identifies the source.
|
|
24
|
+
*/
|
|
25
|
+
id: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A URL to a TileJSON configuration file describing the source’s contents and other metadata.
|
|
29
|
+
*/
|
|
30
|
+
url?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.
|
|
34
|
+
* Example: https://example.com/vector-tiles/{z}/{x}/{y}.pbf
|
|
35
|
+
*/
|
|
36
|
+
tileUrlTemplates?: string[];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
|
|
40
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
41
|
+
* maxZoomLevel, if specified. The default value for this option is 0.
|
|
42
|
+
*/
|
|
43
|
+
minZoomLevel?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
|
|
47
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
48
|
+
* minZoomLevel, if specified. The default value for this option is 22.
|
|
49
|
+
*/
|
|
50
|
+
maxZoomLevel?: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Influences the y direction of the tile coordinates. (tms inverts y axis)
|
|
54
|
+
*/
|
|
55
|
+
tms?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* An HTML or literal text string defining the buttons to be displayed in an action sheet when the
|
|
59
|
+
* source is part of a map view’s style and the map view’s attribution button is pressed.
|
|
60
|
+
*/
|
|
61
|
+
attribution?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Source press listener, gets called when a user presses one of the children layers only
|
|
65
|
+
* if that layer has a higher z-index than another source layers
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} event
|
|
68
|
+
* @param {Object[]} event.features - the geojson features that have hit by the press (might be multiple)
|
|
69
|
+
* @param {Object} event.coordinates - the coordinates of the click
|
|
70
|
+
* @param {Object} event.point - the point of the click
|
|
71
|
+
*/
|
|
72
|
+
onPress?: (event: OnPressEvent) => void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Overrides the default touch hitbox(44x44 pixels) for the source layers
|
|
76
|
+
*/
|
|
77
|
+
hitbox?: {
|
|
78
|
+
/**
|
|
79
|
+
* `width` of hitbox
|
|
80
|
+
*/
|
|
81
|
+
width: number;
|
|
82
|
+
/**
|
|
83
|
+
* `height` of hitbox
|
|
84
|
+
*/
|
|
85
|
+
height: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
children: React.ReactElement | React.ReactElement[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//interface NativeProps extends Omit<Props, 'children'> {}
|
|
92
|
+
type NativeProps = Props; // Omit<Props, 'children'>;
|
|
93
|
+
/**
|
|
94
|
+
* VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
|
|
95
|
+
* The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification.
|
|
96
|
+
*/
|
|
97
|
+
class VectorSource extends NativeBridgeComponent(
|
|
98
|
+
AbstractSource<Props, NativeProps>,
|
|
99
|
+
NATIVE_MODULE_NAME,
|
|
100
|
+
) {
|
|
101
|
+
static defaultProps = {
|
|
102
|
+
id: MapboxGL.StyleSource.DefaultSourceID,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
constructor(props: Props) {
|
|
106
|
+
super(props);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_setNativeRef(
|
|
110
|
+
nativeRef: (React.Component<NativeProps> & Readonly<NativeMethods>) | null,
|
|
111
|
+
) {
|
|
112
|
+
if (nativeRef) {
|
|
113
|
+
this.setNativeRef(nativeRef);
|
|
114
|
+
// this._nativeRef = nativeRef;
|
|
115
|
+
super._runPendingNativeCommands(nativeRef);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns all features that match the query parameters regardless of whether or not the feature is
|
|
121
|
+
* currently rendered on the map. The domain of the query includes all currently-loaded vector tiles
|
|
122
|
+
* and GeoJSON source tiles. This function does not check tiles outside of the visible viewport.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* vectorSource.features(['id1', 'id2'])
|
|
126
|
+
*
|
|
127
|
+
* @param {Array=} layerIDs - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
|
|
128
|
+
* @param {Array=} filter - an optional filter statement to filter the returned Features.
|
|
129
|
+
* @return {FeatureCollection}
|
|
130
|
+
*/
|
|
131
|
+
async features(layerIDs = [], filter = []) {
|
|
132
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
133
|
+
'features',
|
|
134
|
+
this._nativeRef,
|
|
135
|
+
[layerIDs, getFilter(filter)],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
if (isAndroid()) {
|
|
139
|
+
return JSON.parse(res.data);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return res.data;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
onPress(
|
|
146
|
+
event: NativeSyntheticEvent<{
|
|
147
|
+
payload: OnPressEvent;
|
|
148
|
+
}>,
|
|
149
|
+
) {
|
|
150
|
+
const {
|
|
151
|
+
nativeEvent: {
|
|
152
|
+
payload: { features, coordinates, point },
|
|
153
|
+
},
|
|
154
|
+
} = event;
|
|
155
|
+
let newEvent = {
|
|
156
|
+
features,
|
|
157
|
+
coordinates,
|
|
158
|
+
point,
|
|
159
|
+
};
|
|
160
|
+
newEvent = copyPropertiesAsDeprecated(
|
|
161
|
+
event,
|
|
162
|
+
newEvent,
|
|
163
|
+
(key) => {
|
|
164
|
+
console.warn(
|
|
165
|
+
`event.${key} is deprecated on VectorSource#onPress, please use event.features`,
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
nativeEvent: (origNativeEvent: unknown) => ({
|
|
170
|
+
...(origNativeEvent as OnPressEvent),
|
|
171
|
+
payload: features[0],
|
|
172
|
+
}),
|
|
173
|
+
},
|
|
174
|
+
);
|
|
175
|
+
const { onPress } = this.props;
|
|
176
|
+
if (onPress) {
|
|
177
|
+
onPress(newEvent);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
render() {
|
|
182
|
+
const props = {
|
|
183
|
+
id: this.props.id,
|
|
184
|
+
url: this.props.url,
|
|
185
|
+
tileUrlTemplates: this.props.tileUrlTemplates,
|
|
186
|
+
minZoomLevel: this.props.minZoomLevel,
|
|
187
|
+
maxZoomLevel: this.props.maxZoomLevel,
|
|
188
|
+
tms: this.props.tms,
|
|
189
|
+
attribution: this.props.attribution,
|
|
190
|
+
hitbox: this.props.hitbox,
|
|
191
|
+
hasPressListener: isFunction(this.props.onPress),
|
|
192
|
+
onMapboxVectorSourcePress: this.onPress.bind(this),
|
|
193
|
+
onPress: undefined,
|
|
194
|
+
onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
|
|
195
|
+
};
|
|
196
|
+
return (
|
|
197
|
+
<RCTMGLVectorSource ref={(r) => this._setNativeRef(r)} {...props}>
|
|
198
|
+
{cloneReactChildrenWithProps(this.props.children, {
|
|
199
|
+
sourceID: this.props.id,
|
|
200
|
+
})}
|
|
201
|
+
</RCTMGLVectorSource>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const RCTMGLVectorSource =
|
|
207
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
208
|
+
|
|
209
|
+
export default VectorSource;
|
|
@@ -69,7 +69,7 @@ interface Coordinates {
|
|
|
69
69
|
/**
|
|
70
70
|
* LocationManager is a singleton, see `locationManager`
|
|
71
71
|
*/
|
|
72
|
-
class LocationManager {
|
|
72
|
+
export class LocationManager {
|
|
73
73
|
_listeners: ((location: Location) => void)[];
|
|
74
74
|
_lastKnownLocation: Location | null;
|
|
75
75
|
_isListening: boolean;
|
package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts}
RENAMED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { makeLatLngBounds } from '../../utils/geoUtils';
|
|
2
2
|
import { toJSONString } from '../../utils';
|
|
3
3
|
|
|
4
|
+
export type OfflineCreatePackOptionsArgs = {
|
|
5
|
+
name: string;
|
|
6
|
+
styleURL: string;
|
|
7
|
+
bounds: [GeoJSON.Position, GeoJSON.Position];
|
|
8
|
+
minZoom?: number;
|
|
9
|
+
maxZoom?: number;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
|
|
4
13
|
class OfflineCreatePackOptions {
|
|
5
|
-
|
|
14
|
+
public readonly name: string;
|
|
15
|
+
public readonly styleURL: string;
|
|
16
|
+
public readonly bounds: string;
|
|
17
|
+
public readonly minZoom: number | undefined;
|
|
18
|
+
public readonly maxZoom: number | undefined;
|
|
19
|
+
public readonly metadata: string | undefined;
|
|
20
|
+
|
|
21
|
+
constructor(options: OfflineCreatePackOptionsArgs) {
|
|
6
22
|
this._assert(options);
|
|
7
23
|
|
|
8
24
|
this.name = options.name;
|
|
@@ -13,7 +29,7 @@ class OfflineCreatePackOptions {
|
|
|
13
29
|
this.metadata = this._makeMetadata(options.metadata);
|
|
14
30
|
}
|
|
15
31
|
|
|
16
|
-
_assert(options) {
|
|
32
|
+
_assert(options: OfflineCreatePackOptionsArgs) {
|
|
17
33
|
if (!options.styleURL) {
|
|
18
34
|
throw new Error(
|
|
19
35
|
'Style URL must be provided for creating an offline pack',
|
|
@@ -29,13 +45,12 @@ class OfflineCreatePackOptions {
|
|
|
29
45
|
}
|
|
30
46
|
}
|
|
31
47
|
|
|
32
|
-
_makeLatLngBounds(bounds) {
|
|
33
|
-
const ne = bounds
|
|
34
|
-
const sw = bounds[1];
|
|
48
|
+
_makeLatLngBounds(bounds: [GeoJSON.Position, GeoJSON.Position]): string {
|
|
49
|
+
const [ne, sw] = bounds;
|
|
35
50
|
return toJSONString(makeLatLngBounds(ne, sw));
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
_makeMetadata(metadata) {
|
|
53
|
+
_makeMetadata(metadata: Record<string, unknown> | undefined) {
|
|
39
54
|
return JSON.stringify({
|
|
40
55
|
...metadata,
|
|
41
56
|
name: this.name,
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
2
|
|
|
3
|
+
import OfflineCreatePackOptions from './OfflineCreatePackOptions';
|
|
4
|
+
|
|
3
5
|
const MapboxGLOfflineManager = NativeModules.MGLOfflineModule;
|
|
4
6
|
|
|
7
|
+
type OfflinePackStatus = {
|
|
8
|
+
name: string;
|
|
9
|
+
state: number;
|
|
10
|
+
percentage: number;
|
|
11
|
+
completedResourceCount: number;
|
|
12
|
+
completedResourceSize: number;
|
|
13
|
+
completedTileSize: number;
|
|
14
|
+
completedTileCount: number;
|
|
15
|
+
requiredResourceCount: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
5
18
|
class OfflinePack {
|
|
6
|
-
|
|
19
|
+
private pack: OfflineCreatePackOptions;
|
|
20
|
+
private _metadata: any;
|
|
21
|
+
constructor(pack: OfflineCreatePackOptions) {
|
|
7
22
|
this.pack = pack;
|
|
8
23
|
this._metadata = null;
|
|
9
24
|
}
|
|
@@ -24,15 +39,15 @@ class OfflinePack {
|
|
|
24
39
|
return this._metadata;
|
|
25
40
|
}
|
|
26
41
|
|
|
27
|
-
status() {
|
|
42
|
+
status(): Promise<OfflinePackStatus> {
|
|
28
43
|
return MapboxGLOfflineManager.getPackStatus(this.name);
|
|
29
44
|
}
|
|
30
45
|
|
|
31
|
-
resume() {
|
|
46
|
+
resume(): Promise<void> {
|
|
32
47
|
return MapboxGLOfflineManager.resumePackDownload(this.name);
|
|
33
48
|
}
|
|
34
49
|
|
|
35
|
-
pause() {
|
|
50
|
+
pause(): Promise<void> {
|
|
36
51
|
return MapboxGLOfflineManager.pausePackDownload(this.name);
|
|
37
52
|
}
|
|
38
53
|
}
|