@rnmapbox/maps 10.0.0-beta.41 → 10.0.0-beta.42
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/.eslintrc.js +2 -1
- package/.github/workflows/ios-actions.yml +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +21 -31
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +26 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphere.kt +59 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphereManager.kt +30 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrain.kt +32 -27
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrainManager.kt +5 -11
- package/docs/Annotations.md +4 -3
- package/docs/Camera.md +1 -1
- package/docs/MapView.md +2 -2
- package/docs/Terrain.md +64 -9
- package/docs/docs.json +54 -45
- package/index.d.ts +2 -7
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +25 -7
- package/ios/RCTMGL-v10/RCTMGLImages.swift +1 -99
- package/ios/RCTMGL-v10/RCTMGLLogging.swift +8 -0
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +35 -39
- package/ios/RCTMGL-v10/RCTMGLSingletonLayer.swift +7 -1
- package/ios/RCTMGL-v10/RCTMGLStyle.swift +34 -0
- package/ios/RCTMGL-v10/RCTMGLTerrain.swift +56 -63
- package/ios/RCTMGL-v10/RCTMGLTerrainManager.m +2 -3
- package/javascript/components/Camera.tsx +17 -1
- package/javascript/components/MapView.js +8 -12
- package/javascript/components/Terrain.tsx +112 -0
- package/javascript/index.js +8 -4
- package/javascript/types/index.ts +0 -14
- package/javascript/utils/MapboxStyles.ts +20 -2
- package/javascript/utils/deprecation.ts +39 -0
- package/javascript/utils/styleMap.ts +26 -0
- package/package.json +6 -6
- package/scripts/autogenHelpers/globals.js +2 -0
- package/scripts/autogenerate.js +13 -0
- package/scripts/templates/MapboxStyles.ts.ejs +1 -1
- package/scripts/templates/RCTMGLStyleFactoryv10.java.ejs +1 -0
- package/.eslintignore +0 -1
- package/javascript/components/Terrain.js +0 -56
- package/javascript/utils/deprecation.js +0 -24
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { viewPropTypes } from '../utils';
|
|
7
|
+
|
|
8
|
+
import AbstractLayer from './AbstractLayer';
|
|
9
|
+
|
|
10
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
11
|
+
|
|
12
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';
|
|
13
|
+
|
|
14
|
+
**
|
|
15
|
+
* A global modifier that elevates layers and markers based on a DEM data source.
|
|
16
|
+
*
|
|
17
|
+
class Terrain extends React.PureComponent {
|
|
18
|
+
static propTypes = {
|
|
19
|
+
...viewPropTypes,
|
|
20
|
+
|
|
21
|
+
**
|
|
22
|
+
* Name of a source of raster_dem type to be used for terrain elevation.
|
|
23
|
+
*
|
|
24
|
+
sourceID: PropTypes.string,
|
|
25
|
+
|
|
26
|
+
**
|
|
27
|
+
* Optional number between 0 and 1000 inclusive. Defaults to 1. Supports interpolateexpressions. Transitionable.
|
|
28
|
+
* Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.
|
|
29
|
+
*
|
|
30
|
+
exaggeration: PropTypes.oneOfType([PropTypes.number, PropTypes.array]),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
static defaultProps = {
|
|
34
|
+
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
get baseProps() {
|
|
38
|
+
return {
|
|
39
|
+
...this.props,
|
|
40
|
+
sourceID: this.props.sourceID,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
const props = {
|
|
46
|
+
...this.baseProps,
|
|
47
|
+
sourceID: this.props.sourceID,
|
|
48
|
+
};
|
|
49
|
+
return <RCTMGLTerrain ref="nativeLayer" {...props} />;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const RCTMGLTerrain = requireNativeComponent(NATIVE_MODULE_NAME, Terrain, {
|
|
54
|
+
nativeOnly: { reactStyle: true },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default Terrain;
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
import React, { memo, useMemo } from 'react';
|
|
61
|
+
import { HostComponent, requireNativeComponent } from 'react-native';
|
|
62
|
+
|
|
63
|
+
import type { TerrainLayerStyleProps, Value } from '../utils/MapboxStyles';
|
|
64
|
+
import { StyleValue, transformStyle } from '../utils/StyleValue';
|
|
65
|
+
|
|
66
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';
|
|
67
|
+
|
|
68
|
+
type Props = {
|
|
69
|
+
/**
|
|
70
|
+
* Name of a source of raster_dem type to be used for terrain elevation.
|
|
71
|
+
*/
|
|
72
|
+
sourceID: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Deprecated, use exaggeration in style instead
|
|
76
|
+
*/
|
|
77
|
+
exaggeration?: Value<number, ['zoom']>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Customizable style attributes
|
|
81
|
+
*/
|
|
82
|
+
style: TerrainLayerStyleProps;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const Terrain = memo((props: Props) => {
|
|
86
|
+
let { style = {} } = props;
|
|
87
|
+
|
|
88
|
+
if (props.exaggeration) {
|
|
89
|
+
console.warn(
|
|
90
|
+
`Tarrain: exaggeration property is deprecated pls use style.exaggeration instead!`,
|
|
91
|
+
);
|
|
92
|
+
style = { exaggeration: props.exaggeration, ...style };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log('STYLE:', style);
|
|
96
|
+
const baseProps = useMemo(() => {
|
|
97
|
+
return {
|
|
98
|
+
...props,
|
|
99
|
+
reactStyle: transformStyle(style),
|
|
100
|
+
style: undefined,
|
|
101
|
+
};
|
|
102
|
+
}, [props, style]);
|
|
103
|
+
console.log('BASE PROPS', baseProps);
|
|
104
|
+
|
|
105
|
+
return <RCTMGLTerrain {...baseProps} />;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const RCTMGLTerrain: HostComponent<{
|
|
109
|
+
sourceID: string;
|
|
110
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
111
|
+
style?: undefined;
|
|
112
|
+
}> = requireNativeComponent(NATIVE_MODULE_NAME);
|
package/javascript/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import { Camera } from './components/Camera';
|
|
3
|
+
import { Camera, UserTrackingModes } from './components/Camera';
|
|
4
4
|
import { Atmosphere } from './components/Atmosphere';
|
|
5
5
|
import MapView from './components/MapView';
|
|
6
6
|
import Light from './components/Light';
|
|
@@ -23,7 +23,7 @@ import SkyLayer from './components/SkyLayer';
|
|
|
23
23
|
import SymbolLayer from './components/SymbolLayer';
|
|
24
24
|
import RasterLayer from './components/RasterLayer';
|
|
25
25
|
import BackgroundLayer from './components/BackgroundLayer';
|
|
26
|
-
import Terrain from './components/Terrain';
|
|
26
|
+
import { Terrain } from './components/Terrain';
|
|
27
27
|
import locationManager from './modules/location/locationManager';
|
|
28
28
|
import offlineManager from './modules/offline/offlineManager';
|
|
29
29
|
import snapshotManager from './modules/snapshot/snapshotManager';
|
|
@@ -38,13 +38,14 @@ import {
|
|
|
38
38
|
} from './classes';
|
|
39
39
|
import Style from './components/Style';
|
|
40
40
|
import Logger from './utils/Logger';
|
|
41
|
+
import { deprecatedClass } from './utils/deprecation';
|
|
41
42
|
import { requestAndroidLocationPermissions } from './requestAndroidLocationPermissions';
|
|
42
43
|
|
|
43
44
|
const MapboxGL = { ...NativeModules.MGLModule };
|
|
44
45
|
|
|
45
46
|
// static methods
|
|
46
47
|
MapboxGL.requestAndroidLocationPermissions = requestAndroidLocationPermissions;
|
|
47
|
-
MapboxGL.UserTrackingModes =
|
|
48
|
+
MapboxGL.UserTrackingModes = UserTrackingModes;
|
|
48
49
|
|
|
49
50
|
// components
|
|
50
51
|
MapboxGL.MapView = MapView;
|
|
@@ -57,7 +58,10 @@ MapboxGL.Style = Style;
|
|
|
57
58
|
|
|
58
59
|
// classes
|
|
59
60
|
MapboxGL.AnimatedPoint = AnimatedPoint;
|
|
60
|
-
MapboxGL.AnimatedMapPoint =
|
|
61
|
+
MapboxGL.AnimatedMapPoint = deprecatedClass(
|
|
62
|
+
AnimatedPoint,
|
|
63
|
+
'AnimatedMapPoint is deprecated please use AnimatedPoint',
|
|
64
|
+
);
|
|
61
65
|
MapboxGL.AnimatedShape = AnimatedShape;
|
|
62
66
|
MapboxGL.AnimatedCoordinatesArray = AnimatedCoordinatesArray;
|
|
63
67
|
MapboxGL.AnimatedExtractCoordinateFromArray =
|
|
@@ -10,20 +10,6 @@ export type MapboxGLEvent<
|
|
|
10
10
|
V = Element,
|
|
11
11
|
> = SyntheticEvent<V, { type: T; payload: P }>;
|
|
12
12
|
|
|
13
|
-
// Camera.
|
|
14
|
-
|
|
15
|
-
export type UserTrackingMode = 'normal' | 'compass' | 'course';
|
|
16
|
-
|
|
17
|
-
export type UserTrackingModeChangeCallback = (
|
|
18
|
-
event: MapboxGLEvent<
|
|
19
|
-
'usertrackingmodechange',
|
|
20
|
-
{
|
|
21
|
-
followUserLocation: boolean;
|
|
22
|
-
followUserMode: UserTrackingMode | null;
|
|
23
|
-
}
|
|
24
|
-
>,
|
|
25
|
-
) => void;
|
|
26
|
-
|
|
27
13
|
// Animated.
|
|
28
14
|
|
|
29
15
|
export interface AnimatedPoint extends GeoJsonObject {
|
|
@@ -121,7 +121,7 @@ type ExpressionParameters =
|
|
|
121
121
|
| 'heatmap-density';
|
|
122
122
|
|
|
123
123
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
124
|
-
type Value<T, AllowedParameters extends ExpressionParameters[] = []> =
|
|
124
|
+
export type Value<T, AllowedParameters extends ExpressionParameters[] = []> =
|
|
125
125
|
| T
|
|
126
126
|
| Expression;
|
|
127
127
|
|
|
@@ -1468,6 +1468,23 @@ export interface AtmosphereLayerStyleProps {
|
|
|
1468
1468
|
*/
|
|
1469
1469
|
starIntensityTransition?: Transition;
|
|
1470
1470
|
}
|
|
1471
|
+
export interface TerrainLayerStyleProps {
|
|
1472
|
+
/**
|
|
1473
|
+
* Name of a source of `raster_dem` type to be used for terrain elevation.
|
|
1474
|
+
*/
|
|
1475
|
+
source?: string;
|
|
1476
|
+
/**
|
|
1477
|
+
* Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.
|
|
1478
|
+
*
|
|
1479
|
+
* @requires source
|
|
1480
|
+
*/
|
|
1481
|
+
exaggeration?: Value<number, ['zoom']>;
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* The transition affecting any changes to this layer’s exaggeration property.
|
|
1485
|
+
*/
|
|
1486
|
+
exaggerationTransition?: Transition;
|
|
1487
|
+
}
|
|
1471
1488
|
|
|
1472
1489
|
export type AllLayerStyleProps =
|
|
1473
1490
|
| FillLayerStyleProps
|
|
@@ -1481,4 +1498,5 @@ export type AllLayerStyleProps =
|
|
|
1481
1498
|
| BackgroundLayerStyleProps
|
|
1482
1499
|
| SkyLayerStyleProps
|
|
1483
1500
|
| LightLayerStyleProps
|
|
1484
|
-
| AtmosphereLayerStyleProps
|
|
1501
|
+
| AtmosphereLayerStyleProps
|
|
1502
|
+
| TerrainLayerStyleProps;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deprecatedClass: creates a subclass of the class, which prints deprecated warning when called
|
|
3
|
+
*/
|
|
4
|
+
export function deprecatedClass<C extends new (...args: any[]) => object>(
|
|
5
|
+
origClass: C,
|
|
6
|
+
deprecationMessage: string,
|
|
7
|
+
): C {
|
|
8
|
+
const result = class extends origClass {
|
|
9
|
+
constructor(...args: any[]) {
|
|
10
|
+
console.log(`Deprecated: ${deprecationMessage}`);
|
|
11
|
+
super(...args);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Copy properties from origObject to newObject, which not exists in newObject,
|
|
19
|
+
* calls onDeprecatedCalled callback in case a copied property is invoked.
|
|
20
|
+
*/
|
|
21
|
+
export function copyPropertiesAsDeprecated(
|
|
22
|
+
origObject: { [key: string]: unknown },
|
|
23
|
+
newObject: { [key: string]: unknown },
|
|
24
|
+
onDeprecatedCalled: (key: string) => void,
|
|
25
|
+
accessors: { [key: string]: (value: unknown) => unknown } = {},
|
|
26
|
+
): { [key: string]: unknown } {
|
|
27
|
+
const result = newObject;
|
|
28
|
+
for (const [key, value] of Object.entries(origObject)) {
|
|
29
|
+
if (!newObject[key]) {
|
|
30
|
+
Object.defineProperty(result, key, {
|
|
31
|
+
get() {
|
|
32
|
+
onDeprecatedCalled(key);
|
|
33
|
+
return accessors[key] ? accessors[key](value) : value;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -1671,6 +1671,28 @@ export const AtmosphereLayerStyleProp = PropTypes.shape({
|
|
|
1671
1671
|
}),
|
|
1672
1672
|
});
|
|
1673
1673
|
|
|
1674
|
+
export const TerrainLayerStyleProp = PropTypes.shape({
|
|
1675
|
+
/**
|
|
1676
|
+
* Name of a source of `raster_dem` type to be used for terrain elevation.
|
|
1677
|
+
*/
|
|
1678
|
+
source: PropTypes.string,
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.
|
|
1682
|
+
*
|
|
1683
|
+
* @requires source
|
|
1684
|
+
*/
|
|
1685
|
+
exaggeration: PropTypes.oneOfType([PropTypes.number, PropTypes.array]),
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* The transition affecting any changes to this layer’s exaggeration property.
|
|
1689
|
+
*/
|
|
1690
|
+
exaggerationTransition: PropTypes.shape({
|
|
1691
|
+
duration: PropTypes.number,
|
|
1692
|
+
delay: PropTypes.number,
|
|
1693
|
+
}),
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1674
1696
|
const styleMap = {
|
|
1675
1697
|
fillSortKey: StyleTypes.Constant,
|
|
1676
1698
|
fillAntialias: StyleTypes.Constant,
|
|
@@ -1891,6 +1913,10 @@ const styleMap = {
|
|
|
1891
1913
|
starIntensity: StyleTypes.Constant,
|
|
1892
1914
|
starIntensityTransition: StyleTypes.Transition,
|
|
1893
1915
|
|
|
1916
|
+
source: StyleTypes.Constant,
|
|
1917
|
+
exaggeration: StyleTypes.Constant,
|
|
1918
|
+
exaggerationTransition: StyleTypes.Transition,
|
|
1919
|
+
|
|
1894
1920
|
color: StyleTypes.Color,
|
|
1895
1921
|
colorTransition: StyleTypes.Transition,
|
|
1896
1922
|
visibility: StyleTypes.Constant,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnmapbox/maps",
|
|
3
3
|
"description": "A Mapbox react native module for creating custom maps",
|
|
4
|
-
"version": "10.0.0-beta.
|
|
4
|
+
"version": "10.0.0-beta.42",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"unittest:single": "jest --testNamePattern",
|
|
30
30
|
"lint": "eslint .",
|
|
31
31
|
"lint:fix": "eslint . --fix",
|
|
32
|
-
"type:check": "tsc --noEmit",
|
|
32
|
+
"type:check": "npx tsc --noEmit",
|
|
33
33
|
"test:plugin": "expo-module test plugin",
|
|
34
|
-
"build:plugin": "tsc --build plugin",
|
|
34
|
+
"build:plugin": "npx tsc --build plugin",
|
|
35
35
|
"lint:plugin": "eslint plugin/src/*",
|
|
36
36
|
"prepare": "husky install"
|
|
37
37
|
},
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@types/react-native": ">=0.59.9",
|
|
74
74
|
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
75
75
|
"@typescript-eslint/parser": "^5.37.0",
|
|
76
|
-
"babel-jest": "^
|
|
77
|
-
"documentation": "
|
|
76
|
+
"babel-jest": "^29.0.3",
|
|
77
|
+
"documentation": "14.0.0",
|
|
78
78
|
"ejs": "^3.1.3",
|
|
79
79
|
"ejs-lint": "^1.1.0",
|
|
80
80
|
"eslint": "^8.23.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"react-docgen": "rnmapbox/react-docgen#rnmapbox-dist",
|
|
96
96
|
"react-native": "0.67.0",
|
|
97
97
|
"react-test-renderer": "17.0.2",
|
|
98
|
-
"typescript": "
|
|
98
|
+
"typescript": "4.8.3"
|
|
99
99
|
},
|
|
100
100
|
"jest": {
|
|
101
101
|
"preset": "react-native",
|
|
@@ -107,6 +107,8 @@ global.getLayerType = function (layer, platform) {
|
|
|
107
107
|
return isIOS ? 'MGLSkyLayer' : 'SkyLayer';
|
|
108
108
|
case 'atmosphere':
|
|
109
109
|
return isIOS ? 'MGLAtmosphere' : 'Atmosphere';
|
|
110
|
+
case 'terrain':
|
|
111
|
+
return isIOS ? 'MGLTerrain' : 'Terrain';
|
|
110
112
|
default:
|
|
111
113
|
throw new Error(
|
|
112
114
|
`Is ${layer.name} a new layer? We should add support for it!`,
|
package/scripts/autogenerate.js
CHANGED
|
@@ -155,6 +155,19 @@ layers.push({
|
|
|
155
155
|
support: { gl: false, v10: true },
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
// add terrain as a layer
|
|
159
|
+
layers.push({
|
|
160
|
+
name: 'terrain',
|
|
161
|
+
properties: getPropertiesFor('terrain'),
|
|
162
|
+
props: {
|
|
163
|
+
gl: getPropertiesFor('terrain', 'gl'),
|
|
164
|
+
v10: getPropertiesFor('terrain', 'v10')
|
|
165
|
+
.filter(({ name }) => name !== 'source')
|
|
166
|
+
.map((i) => ({ ...i, transition: false })),
|
|
167
|
+
},
|
|
168
|
+
support: { gl: false, v10: true },
|
|
169
|
+
});
|
|
170
|
+
|
|
158
171
|
function getPropertiesFor(kind, only) {
|
|
159
172
|
const attributes = styleSpecJSON[kind];
|
|
160
173
|
|
|
@@ -48,7 +48,7 @@ export type Expression = [ExpressionName, ...ExpressionField[]];
|
|
|
48
48
|
type ExpressionParameters = 'zoom' | 'feature' | 'feature-state' | 'sky-radial-progress' | 'line-progress' | 'heatmap-density';
|
|
49
49
|
|
|
50
50
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
-
type Value<T, AllowedParameters extends ExpressionParameters[] = []> =
|
|
51
|
+
export type Value<T, AllowedParameters extends ExpressionParameters[] = []> =
|
|
52
52
|
| T
|
|
53
53
|
| Expression;
|
|
54
54
|
|
|
@@ -20,6 +20,7 @@ import com.mapbox.maps.extension.style.layers.generated.SymbolLayer;
|
|
|
20
20
|
import com.mapbox.maps.extension.style.layers.generated.HeatmapLayer;
|
|
21
21
|
import com.mapbox.maps.extension.style.layers.generated.HillshadeLayer;
|
|
22
22
|
import com.mapbox.maps.extension.style.atmosphere.generated.Atmosphere;
|
|
23
|
+
import com.mapbox.maps.extension.style.terrain.generated.Terrain;
|
|
23
24
|
// import com.mapbox.maps.extension.style.layers.properties.generated.Visibility;
|
|
24
25
|
import com.mapbox.maps.extension.style.layers.properties.generated.*;
|
|
25
26
|
import com.mapbox.maps.extension.style.types.StyleTransition;
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/plugin/build
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import { viewPropTypes } from '../utils';
|
|
6
|
-
|
|
7
|
-
import AbstractLayer from './AbstractLayer';
|
|
8
|
-
|
|
9
|
-
const MapboxGL = NativeModules.MGLModule;
|
|
10
|
-
|
|
11
|
-
export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A global modifier that elevates layers and markers based on a DEM data source.
|
|
15
|
-
*/
|
|
16
|
-
class Terrain extends React.PureComponent {
|
|
17
|
-
static propTypes = {
|
|
18
|
-
...viewPropTypes,
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Name of a source of raster_dem type to be used for terrain elevation.
|
|
22
|
-
*/
|
|
23
|
-
sourceID: PropTypes.string,
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Optional number between 0 and 1000 inclusive. Defaults to 1. Supports interpolateexpressions. Transitionable.
|
|
27
|
-
* Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.
|
|
28
|
-
*/
|
|
29
|
-
exaggeration: PropTypes.oneOfType([PropTypes.number, PropTypes.array]),
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
static defaultProps = {
|
|
33
|
-
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
get baseProps() {
|
|
37
|
-
return {
|
|
38
|
-
...this.props,
|
|
39
|
-
sourceID: this.props.sourceID,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
render() {
|
|
44
|
-
const props = {
|
|
45
|
-
...this.baseProps,
|
|
46
|
-
sourceID: this.props.sourceID,
|
|
47
|
-
};
|
|
48
|
-
return <RCTMGLTerrain ref="nativeLayer" {...props} />;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const RCTMGLTerrain = requireNativeComponent(NATIVE_MODULE_NAME, Terrain, {
|
|
53
|
-
nativeOnly: { reactStyle: true },
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export default Terrain;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copy properties from origObject to newObject, which not exists in newObject,
|
|
3
|
-
* calls onDeprecatedCalled callback in case a copied property is invoked.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export function copyPropertiesAsDeprecated(
|
|
7
|
-
origObject,
|
|
8
|
-
newObject,
|
|
9
|
-
onDeprecatedCalled,
|
|
10
|
-
accessors = {},
|
|
11
|
-
) {
|
|
12
|
-
const result = newObject;
|
|
13
|
-
for (const [key, value] of Object.entries(origObject)) {
|
|
14
|
-
if (!newObject[key]) {
|
|
15
|
-
Object.defineProperty(result, key, {
|
|
16
|
-
get() {
|
|
17
|
-
onDeprecatedCalled(key);
|
|
18
|
-
return accessors[key] ? accessors[key](value) : value;
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}
|