@rnmapbox/maps 10.0.0-beta.42 → 10.0.0-beta.43
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/install.md +20 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +1 -0
- package/docs/HeadingIndicator.md +1 -1
- package/docs/SymbolLayer.md +4 -3
- package/docs/docs.json +12 -8
- package/index.d.ts +11 -73
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +3 -19
- package/javascript/components/AbstractLayer.tsx +72 -0
- package/javascript/components/BackgroundLayer.js +1 -1
- package/javascript/components/CircleLayer.js +1 -1
- package/javascript/components/FillExtrusionLayer.js +1 -1
- package/javascript/components/FillLayer.js +1 -1
- package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +5 -6
- package/javascript/components/HeatmapLayer.js +1 -1
- package/javascript/components/LineLayer.js +1 -1
- package/javascript/components/RasterLayer.js +1 -1
- package/javascript/components/SkyLayer.js +1 -1
- package/javascript/components/SymbolLayer.tsx +113 -0
- package/javascript/components/Terrain.tsx +0 -60
- package/javascript/components/UserLocation.js +1 -1
- package/javascript/global.d.ts +4 -0
- package/javascript/utils/MapboxStyles.ts +157 -50
- package/javascript/utils/StyleValue.ts +8 -6
- package/javascript/utils/{filterUtils.js → filterUtils.tsx} +1 -1
- package/package.json +1 -1
- package/scripts/autogenHelpers/DocJSONBuilder.js +2 -3
- package/scripts/autogenHelpers/globals.js +18 -7
- package/scripts/templates/MapboxStyles.ts.ejs +7 -2
- package/javascript/components/AbstractLayer.js +0 -46
- package/javascript/components/SymbolLayer.js +0 -120
package/android/install.md
CHANGED
|
@@ -12,7 +12,7 @@ Add `RNMapboxMapsImpl = "mapbox"` to your gradle file - see bellow for details.
|
|
|
12
12
|
|
|
13
13
|
### Custom versions
|
|
14
14
|
|
|
15
|
-
*Warning*: If you set a
|
|
15
|
+
*Warning*: If you set a custom version, make sure you revisit, any time you update @rnmapbox/maps. Setting it to earlier version than what we exepect will likely result in a build error.
|
|
16
16
|
|
|
17
17
|
Overwrite mapbox dependencies within your `android/build.gradle > buildscript > ext` section
|
|
18
18
|
|
|
@@ -32,6 +32,7 @@ buildscript {
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
If you see `2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs` issue see [possible workaround](#workaround-for-2-files-found-with-path-libarm64-v8alibc_sharedso-from-inputs).
|
|
35
36
|
|
|
36
37
|
## Using MapLibre
|
|
37
38
|
|
|
@@ -138,4 +139,22 @@ Feel free to check out the `/example` projects [`android/build.gradle`](https://
|
|
|
138
139
|
<br>
|
|
139
140
|
|
|
140
141
|
|
|
142
|
+
### Workaround for 2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
code android/app/build.gradle
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
add the following
|
|
149
|
+
```gradle
|
|
150
|
+
android {
|
|
151
|
+
packagingOptions {
|
|
152
|
+
pickFirst 'lib/x86/libc++_shared.so'
|
|
153
|
+
pickFirst 'lib/x86_64/libc++_shared.so'
|
|
154
|
+
pickFirst 'lib/arm64-v8a/libc++_shared.so'
|
|
155
|
+
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
141
160
|
|
package/docs/HeadingIndicator.md
CHANGED
package/docs/SymbolLayer.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- This file was autogenerated from SymbolLayer.
|
|
1
|
+
<!-- This file was autogenerated from SymbolLayer.tsx do not modify -->
|
|
2
2
|
# <MapboxGL.SymbolLayer />
|
|
3
3
|
SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
|
|
4
4
|
|
|
@@ -11,10 +11,11 @@ SymbolLayer is a style layer that renders icon and text labels at points or alon
|
|
|
11
11
|
| aboveLayerID | `string` | `none` | `false` | Inserts a layer above aboveLayerID. |
|
|
12
12
|
| belowLayerID | `string` | `none` | `false` | Inserts a layer below belowLayerID |
|
|
13
13
|
| layerIndex | `number` | `none` | `false` | Inserts a layer at a specified index |
|
|
14
|
-
| filter | `
|
|
14
|
+
| filter | `Array` | `none` | `false` | Filter only the features in the source layer that satisfy a condition that you define |
|
|
15
15
|
| minZoomLevel | `number` | `none` | `false` | The minimum zoom level at which the layer gets parsed and appears. |
|
|
16
16
|
| maxZoomLevel | `number` | `none` | `false` | The maximum zoom level at which the layer gets parsed and appears. |
|
|
17
|
-
| style | `
|
|
17
|
+
| style | `SymbolLayerStyleProps` | `none` | `true` | FIX ME NO DESCRIPTION |
|
|
18
|
+
| children | `JSX.Element \| JSX.Element[]` | `none` | `false` | FIX ME NO DESCRIPTION |
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
## styles
|
package/docs/docs.json
CHANGED
|
@@ -1646,7 +1646,7 @@
|
|
|
1646
1646
|
"description": "FIX ME NO DESCRIPTION"
|
|
1647
1647
|
}
|
|
1648
1648
|
],
|
|
1649
|
-
"fileNameWithExt": "HeadingIndicator.
|
|
1649
|
+
"fileNameWithExt": "HeadingIndicator.tsx",
|
|
1650
1650
|
"name": "HeadingIndicator"
|
|
1651
1651
|
},
|
|
1652
1652
|
"HeatmapLayer": {
|
|
@@ -4411,7 +4411,7 @@
|
|
|
4411
4411
|
{
|
|
4412
4412
|
"name": "filter",
|
|
4413
4413
|
"required": false,
|
|
4414
|
-
"type": "
|
|
4414
|
+
"type": "Array",
|
|
4415
4415
|
"default": "none",
|
|
4416
4416
|
"description": "Filter only the features in the source layer that satisfy a condition that you define"
|
|
4417
4417
|
},
|
|
@@ -4431,16 +4431,20 @@
|
|
|
4431
4431
|
},
|
|
4432
4432
|
{
|
|
4433
4433
|
"name": "style",
|
|
4434
|
+
"required": true,
|
|
4435
|
+
"type": "SymbolLayerStyleProps",
|
|
4436
|
+
"default": "none",
|
|
4437
|
+
"description": "FIX ME NO DESCRIPTION"
|
|
4438
|
+
},
|
|
4439
|
+
{
|
|
4440
|
+
"name": "children",
|
|
4434
4441
|
"required": false,
|
|
4435
|
-
"type": "
|
|
4442
|
+
"type": "JSX.Element \\| JSX.Element[]",
|
|
4436
4443
|
"default": "none",
|
|
4437
|
-
"description": "
|
|
4444
|
+
"description": "FIX ME NO DESCRIPTION"
|
|
4438
4445
|
}
|
|
4439
4446
|
],
|
|
4440
|
-
"
|
|
4441
|
-
"../utils"
|
|
4442
|
-
],
|
|
4443
|
-
"fileNameWithExt": "SymbolLayer.js",
|
|
4447
|
+
"fileNameWithExt": "SymbolLayer.tsx",
|
|
4444
4448
|
"name": "SymbolLayer",
|
|
4445
4449
|
"styles": [
|
|
4446
4450
|
{
|
package/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
FeatureCollection,
|
|
23
23
|
} from '@turf/helpers';
|
|
24
24
|
|
|
25
|
+
import type { SymbolLayerStyleProps } from './javascript/utils/MapboxStyles';
|
|
25
26
|
import {
|
|
26
27
|
Camera as _Camera,
|
|
27
28
|
CameraStop as _CameraStop,
|
|
@@ -38,6 +39,10 @@ import {
|
|
|
38
39
|
import { MarkerView as _MarkerView } from './javascript/components/MarkerView';
|
|
39
40
|
import { PointAnnotation as _PointAnnotation } from './javascript/components/PointAnnotation';
|
|
40
41
|
import { Atmosphere as _Atmosphere } from './javascript/components/Atmosphere';
|
|
42
|
+
import {
|
|
43
|
+
SymbolLayer as _SymbolLayer,
|
|
44
|
+
Props as _SymbolLayerProps,
|
|
45
|
+
} from './javascript/components/SymbolLayer';
|
|
41
46
|
import type {
|
|
42
47
|
MapboxGLEvent as _MapboxGLEvent,
|
|
43
48
|
AnimatedPoint as _AnimatedPoint,
|
|
@@ -96,7 +101,7 @@ type AutoAlignment = Alignment | 'auto';
|
|
|
96
101
|
|
|
97
102
|
type NamedStyles<T> = {
|
|
98
103
|
[P in keyof T]:
|
|
99
|
-
|
|
|
104
|
+
| SymbolLayerStyleProps
|
|
100
105
|
| RasterLayerStyle
|
|
101
106
|
| LineLayerStyle
|
|
102
107
|
| FillLayerStyle
|
|
@@ -142,6 +147,7 @@ declare namespace MapboxGL {
|
|
|
142
147
|
const Atmosphere = _Atmosphere;
|
|
143
148
|
const MarkerView = _MarkerView;
|
|
144
149
|
const PointAnnotation = _PointAnnotation;
|
|
150
|
+
const SymbolLayer = _SymbolLayer;
|
|
145
151
|
|
|
146
152
|
type MapboxGLEvent = _MapboxGLEvent;
|
|
147
153
|
type UserTrackingMode = _UserTrackingMode;
|
|
@@ -246,7 +252,7 @@ declare namespace MapboxGL {
|
|
|
246
252
|
class FillExtrusionLayer extends Component<FillExtrusionLayerProps> {}
|
|
247
253
|
class LineLayer extends Component<LineLayerProps> {}
|
|
248
254
|
class CircleLayer extends Component<CircleLayerProps> {}
|
|
249
|
-
class SymbolLayer extends Component<
|
|
255
|
+
class SymbolLayer extends Component<_SymbolLayerProps> {}
|
|
250
256
|
class RasterLayer extends Component<RasterLayerProps> {}
|
|
251
257
|
class BackgroundLayer extends Component<BackgroundLayerProps> {}
|
|
252
258
|
}
|
|
@@ -397,7 +403,6 @@ declare namespace MapboxGL {
|
|
|
397
403
|
class FillLayer extends Component<FillLayerProps> {}
|
|
398
404
|
class LineLayer extends Component<LineLayerProps> {}
|
|
399
405
|
class RasterLayer extends Component<RasterLayerProps> {}
|
|
400
|
-
class SymbolLayer extends Component<SymbolLayerProps> {}
|
|
401
406
|
class HeatmapLayer extends Component<HeatmapLayerProps> {}
|
|
402
407
|
class Images extends Component<ImagesProps> {}
|
|
403
408
|
class ImageSource extends Component<ImageSourceProps> {}
|
|
@@ -752,75 +757,8 @@ export type TextVariableAnchorValues =
|
|
|
752
757
|
| 'bottom-left'
|
|
753
758
|
| 'bottom-right';
|
|
754
759
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
symbolSpacing?: number | Expression;
|
|
758
|
-
symbolAvoidEdges?: boolean | Expression;
|
|
759
|
-
symbolSortKey?: number | Expression;
|
|
760
|
-
symbolZOrder?: 'auto' | 'viewport-y' | 'source' | Expression;
|
|
761
|
-
iconAllowOverlap?: boolean | Expression;
|
|
762
|
-
iconIgnorePlacement?: boolean | Expression;
|
|
763
|
-
iconOptional?: boolean | Expression;
|
|
764
|
-
iconRotationAlignment?: AutoAlignment | Expression;
|
|
765
|
-
iconSize?: number | Expression;
|
|
766
|
-
iconTextFit?: 'none' | 'width' | 'height' | 'both' | Expression;
|
|
767
|
-
iconTextFitPadding?: Array<number> | Expression;
|
|
768
|
-
iconImage?: string | Expression;
|
|
769
|
-
iconRotate?: number | Expression;
|
|
770
|
-
iconPadding?: number | Expression;
|
|
771
|
-
iconKeepUpright?: boolean | Expression;
|
|
772
|
-
iconOffset?: Array<number> | Expression;
|
|
773
|
-
iconAnchor?: Anchor | Expression;
|
|
774
|
-
iconPitchAlignment?: AutoAlignment | Expression;
|
|
775
|
-
textPitchAlignment?: AutoAlignment | Expression;
|
|
776
|
-
textRotationAlignment?: AutoAlignment | Expression;
|
|
777
|
-
textField?: string | Expression;
|
|
778
|
-
textFont?: Array<string> | Expression;
|
|
779
|
-
textSize?: number | Expression;
|
|
780
|
-
textMaxWidth?: number | Expression;
|
|
781
|
-
textLineHeight?: number | Expression;
|
|
782
|
-
textLetterSpacing?: number | Expression;
|
|
783
|
-
textJustify?: 'left' | 'center' | 'right' | Expression;
|
|
784
|
-
textAnchor?: Anchor | Expression;
|
|
785
|
-
textMaxAngle?: number | Expression;
|
|
786
|
-
textRotate?: number | Expression;
|
|
787
|
-
textPadding?: number | Expression;
|
|
788
|
-
textKeepUpright?: boolean | Expression;
|
|
789
|
-
textTransform?: 'none' | 'uppercase' | 'lowercase' | Expression;
|
|
790
|
-
textOffset?: Array<number> | Expression;
|
|
791
|
-
textAllowOverlap?: boolean | Expression;
|
|
792
|
-
textIgnorePlacement?: boolean | Expression;
|
|
793
|
-
textOptional?: boolean | Expression;
|
|
794
|
-
textVariableAnchor?: Array<TextVariableAnchorValues>;
|
|
795
|
-
textRadialOffset?: number | Expression;
|
|
796
|
-
visibility?: Visibility | Expression;
|
|
797
|
-
iconOpacity?: number | Expression;
|
|
798
|
-
iconOpacityTransition?: Transition | Expression;
|
|
799
|
-
iconColor?: string | Expression;
|
|
800
|
-
iconColorTransition?: Transition | Expression;
|
|
801
|
-
iconHaloColor?: string | Expression;
|
|
802
|
-
iconHaloColorTransition?: Transition | Expression;
|
|
803
|
-
iconHaloWidth?: number | Expression;
|
|
804
|
-
iconHaloWidthTransition?: Transition | Expression;
|
|
805
|
-
iconHaloBlur?: number | Expression;
|
|
806
|
-
iconHaloBlurTransition?: Transition | Expression;
|
|
807
|
-
iconTranslate?: Array<number> | Expression;
|
|
808
|
-
iconTranslateTransition?: Transition | Expression;
|
|
809
|
-
iconTranslateAnchor?: Alignment | Expression;
|
|
810
|
-
textOpacity?: number | Expression;
|
|
811
|
-
textOpacityTransition?: Transition | Expression;
|
|
812
|
-
textColor?: string | Expression;
|
|
813
|
-
textColorTransition?: Transition | Expression;
|
|
814
|
-
textHaloColor?: string | Expression;
|
|
815
|
-
textHaloColorTransition?: Transition | Expression;
|
|
816
|
-
textHaloWidth?: number | Expression;
|
|
817
|
-
textHaloWidthTransition?: Transition | Expression;
|
|
818
|
-
textHaloBlur?: number | Expression;
|
|
819
|
-
textHaloBlurTransition?: Transition | Expression;
|
|
820
|
-
textTranslate?: Array<number> | Expression;
|
|
821
|
-
textTranslateTransition?: Transition | Expression;
|
|
822
|
-
textTranslateAnchor?: Alignment | Expression;
|
|
823
|
-
}
|
|
760
|
+
/** @deprecated Will be removed in next betas */
|
|
761
|
+
export type SymbolLayerStyle = SymbolLayerStyleProps;
|
|
824
762
|
|
|
825
763
|
export interface HeatmapLayerStyle {
|
|
826
764
|
visibility?: Visibility | Expression;
|
|
@@ -938,7 +876,7 @@ export interface RasterLayerProps extends LayerBaseProps {
|
|
|
938
876
|
}
|
|
939
877
|
|
|
940
878
|
export interface SymbolLayerProps extends LayerBaseProps {
|
|
941
|
-
style?:
|
|
879
|
+
style?: SymbolLayerStyleProps;
|
|
942
880
|
}
|
|
943
881
|
|
|
944
882
|
export interface HeatmapLayerProps extends LayerBaseProps {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
-
|
|
2
|
+
import MapboxMaps
|
|
3
3
|
import Turf
|
|
4
4
|
|
|
5
|
-
protocol RCTMGLMapComponent :
|
|
5
|
+
protocol RCTMGLMapComponent : AnyObject {
|
|
6
6
|
func addToMap(_ map: RCTMGLMapView, style: Style)
|
|
7
7
|
func removeFromMap(_ map: RCTMGLMapView)
|
|
8
8
|
|
|
@@ -29,10 +29,7 @@ struct CameraUpdateItem {
|
|
|
29
29
|
}
|
|
30
30
|
switch mode {
|
|
31
31
|
case .flight:
|
|
32
|
-
|
|
33
|
-
_camera.padding = nil
|
|
34
|
-
map.camera.fly(to: _camera, duration: duration)
|
|
35
|
-
changePadding(map: map, cameraAnimator: &cameraAnimator, curve: .linear)
|
|
32
|
+
map.camera.fly(to: camera, duration: duration)
|
|
36
33
|
case .ease:
|
|
37
34
|
map.camera.ease(to: camera, duration: duration ?? 0, curve: .easeInOut, completion: nil)
|
|
38
35
|
case .linear:
|
|
@@ -42,18 +39,6 @@ struct CameraUpdateItem {
|
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
/// Padding is not currently animatable on the camera's `fly(to:)` method, so we create a separate animator instead.
|
|
47
|
-
/// If this changes, remove this and call `fly(to:)` with an unmodified `camera`.
|
|
48
|
-
func changePadding(map: RCTMGLMapView, cameraAnimator: inout BasicCameraAnimator?, curve: UIView.AnimationCurve) {
|
|
49
|
-
if let cameraAnimator = cameraAnimator {
|
|
50
|
-
cameraAnimator.stopAnimation()
|
|
51
|
-
}
|
|
52
|
-
cameraAnimator = map.camera.makeAnimator(duration: duration ?? 0, curve: curve) { (transition) in
|
|
53
|
-
transition.padding.toValue = camera.padding
|
|
54
|
-
}
|
|
55
|
-
cameraAnimator?.startAnimation()
|
|
56
|
-
}
|
|
57
42
|
}
|
|
58
43
|
|
|
59
44
|
class CameraUpdateQueue {
|
|
@@ -454,7 +439,6 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
454
439
|
}
|
|
455
440
|
}
|
|
456
441
|
|
|
457
|
-
/// Converts milliseconds to seconds.
|
|
458
442
|
private func toSeconds(_ ms: Double) -> TimeInterval {
|
|
459
443
|
return ms * 0.001
|
|
460
444
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint react/prop-types:0 */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NativeMethods, processColor } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { getFilter } from '../utils/filterUtils';
|
|
6
|
+
import { transformStyle } from '../utils/StyleValue';
|
|
7
|
+
import { AllLayerStyleProps } from '../utils/MapboxStyles';
|
|
8
|
+
|
|
9
|
+
type PropsBase = {
|
|
10
|
+
id: string;
|
|
11
|
+
sourceID?: string;
|
|
12
|
+
minZoomLevel?: number;
|
|
13
|
+
maxZoomLevel?: number;
|
|
14
|
+
aboveLayerID?: string;
|
|
15
|
+
belowLayerID?: string;
|
|
16
|
+
layerIndex?: number;
|
|
17
|
+
filter?: string[];
|
|
18
|
+
style: AllLayerStyleProps;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class AbstractLayer<
|
|
22
|
+
PropsType extends PropsBase,
|
|
23
|
+
NativePropsType,
|
|
24
|
+
> extends React.PureComponent<PropsType> {
|
|
25
|
+
get baseProps(): PropsType {
|
|
26
|
+
return {
|
|
27
|
+
...this.props,
|
|
28
|
+
id: this.props.id,
|
|
29
|
+
sourceID: this.props.sourceID,
|
|
30
|
+
reactStyle: this.getStyle(this.props.style),
|
|
31
|
+
minZoomLevel: this.props.minZoomLevel,
|
|
32
|
+
maxZoomLevel: this.props.maxZoomLevel,
|
|
33
|
+
aboveLayerID: this.props.aboveLayerID,
|
|
34
|
+
belowLayerID: this.props.belowLayerID,
|
|
35
|
+
layerIndex: this.props.layerIndex,
|
|
36
|
+
filter: getFilter(this.props.filter),
|
|
37
|
+
style: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
nativeLayer:
|
|
42
|
+
| (React.Component<NativePropsType> & Readonly<NativeMethods>)
|
|
43
|
+
| undefined = undefined;
|
|
44
|
+
|
|
45
|
+
setNativeLayer(
|
|
46
|
+
instance: React.Component<NativePropsType> & Readonly<NativeMethods>,
|
|
47
|
+
) {
|
|
48
|
+
this.nativeLayer = instance;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getStyleTypeFormatter(styleType: string) {
|
|
52
|
+
if (styleType === 'color') {
|
|
53
|
+
return processColor;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getStyle(style: AllLayerStyleProps) {
|
|
58
|
+
return transformStyle(style);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setNativeProps(props: { [key: string]: unknown }) {
|
|
62
|
+
if (this.nativeLayer) {
|
|
63
|
+
let propsToPass = props;
|
|
64
|
+
if (props.style) {
|
|
65
|
+
propsToPass = { ...props, reactStyle: this.getStyle(props.style) };
|
|
66
|
+
}
|
|
67
|
+
this.nativeLayer?.setNativeProps(propsToPass);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default AbstractLayer;
|
|
@@ -83,7 +83,7 @@ class FillExtrusionLayer extends AbstractLayer {
|
|
|
83
83
|
...this.baseProps,
|
|
84
84
|
sourceLayerID: this.props.sourceLayerID,
|
|
85
85
|
};
|
|
86
|
-
return <RCTMGLFillExtrusionLayer ref=
|
|
86
|
+
return <RCTMGLFillExtrusionLayer ref={this.setNativeLayer} {...props} />;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
|
|
4
3
|
import headingIcon from '../../assets/heading.png';
|
|
5
4
|
|
|
@@ -10,9 +9,13 @@ const style = {
|
|
|
10
9
|
iconAllowOverlap: true,
|
|
11
10
|
iconPitchAlignment: 'map',
|
|
12
11
|
iconRotationAlignment: 'map',
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
heading?: number;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
|
-
const HeadingIndicator = (heading) => (
|
|
18
|
+
const HeadingIndicator = ({ heading }: Props) => (
|
|
16
19
|
<SymbolLayer
|
|
17
20
|
key="mapboxUserLocationHeadingIndicator"
|
|
18
21
|
id="mapboxUserLocationHeadingIndicator"
|
|
@@ -24,8 +27,4 @@ const HeadingIndicator = (heading) => (
|
|
|
24
27
|
/>
|
|
25
28
|
);
|
|
26
29
|
|
|
27
|
-
HeadingIndicator.propTypes = {
|
|
28
|
-
heading: PropTypes.number,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
30
|
export default HeadingIndicator;
|
|
@@ -84,7 +84,7 @@ class HeatmapLayer extends AbstractLayer {
|
|
|
84
84
|
...this.baseProps,
|
|
85
85
|
sourceLayerID: this.props.sourceLayerID,
|
|
86
86
|
};
|
|
87
|
-
return <RCTMGLHeatmapLayer ref=
|
|
87
|
+
return <RCTMGLHeatmapLayer ref={this.setNativeLayer} {...props} />;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, NativeModules, requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { type SymbolLayerStyleProps } from '../utils/MapboxStyles';
|
|
5
|
+
import { type StyleValue } from '../utils/StyleValue';
|
|
6
|
+
|
|
7
|
+
import AbstractLayer from './AbstractLayer';
|
|
8
|
+
|
|
9
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
10
|
+
|
|
11
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLSymbolLayer';
|
|
12
|
+
|
|
13
|
+
export type Props = {
|
|
14
|
+
/**
|
|
15
|
+
* A string that uniquely identifies the source in the style to which it is added.
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The source from which to obtain the data to style.
|
|
21
|
+
* If the source has not yet been added to the current style, the behavior is undefined.
|
|
22
|
+
* Inferred from parent source only if the layer is a direct child to it.
|
|
23
|
+
*/
|
|
24
|
+
sourceID?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
|
|
28
|
+
*/
|
|
29
|
+
sourceLayerID?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Inserts a layer above aboveLayerID.
|
|
33
|
+
*/
|
|
34
|
+
aboveLayerID?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Inserts a layer below belowLayerID
|
|
38
|
+
*/
|
|
39
|
+
belowLayerID?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Inserts a layer at a specified index
|
|
43
|
+
*/
|
|
44
|
+
layerIndex?: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Filter only the features in the source layer that satisfy a condition that you define
|
|
48
|
+
*/
|
|
49
|
+
filter?: string[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The minimum zoom level at which the layer gets parsed and appears.
|
|
53
|
+
*/
|
|
54
|
+
minZoomLevel?: number;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The maximum zoom level at which the layer gets parsed and appears.
|
|
58
|
+
*/
|
|
59
|
+
maxZoomLevel?: number;
|
|
60
|
+
|
|
61
|
+
style: SymbolLayerStyleProps;
|
|
62
|
+
|
|
63
|
+
children?: JSX.Element | JSX.Element[];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type NativeTypeProps = Omit<Props, 'style'> & {
|
|
67
|
+
snapshot: boolean;
|
|
68
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const RCTMGLSymbolLayer =
|
|
72
|
+
requireNativeComponent<NativeTypeProps>(NATIVE_MODULE_NAME);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
|
|
76
|
+
*/
|
|
77
|
+
class SymbolLayer extends AbstractLayer<Props, NativeTypeProps> {
|
|
78
|
+
static defaultProps = {
|
|
79
|
+
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_shouldSnapshot() {
|
|
83
|
+
let isSnapshot = false;
|
|
84
|
+
|
|
85
|
+
if (React.Children.count(this.props.children) <= 0) {
|
|
86
|
+
return isSnapshot;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
React.Children.forEach(this.props.children, (child) => {
|
|
90
|
+
if (child?.type === View) {
|
|
91
|
+
isSnapshot = true;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return isSnapshot;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
render() {
|
|
99
|
+
const props = {
|
|
100
|
+
...this.baseProps,
|
|
101
|
+
snapshot: this._shouldSnapshot(),
|
|
102
|
+
sourceLayerID: this.props.sourceLayerID,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<RCTMGLSymbolLayer ref={this.setNativeLayer} {...props}>
|
|
107
|
+
{this.props.children}
|
|
108
|
+
</RCTMGLSymbolLayer>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default SymbolLayer;
|
|
@@ -1,62 +1,3 @@
|
|
|
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
1
|
import React, { memo, useMemo } from 'react';
|
|
61
2
|
import { HostComponent, requireNativeComponent } from 'react-native';
|
|
62
3
|
|
|
@@ -92,7 +33,6 @@ export const Terrain = memo((props: Props) => {
|
|
|
92
33
|
style = { exaggeration: props.exaggeration, ...style };
|
|
93
34
|
}
|
|
94
35
|
|
|
95
|
-
console.log('STYLE:', style);
|
|
96
36
|
const baseProps = useMemo(() => {
|
|
97
37
|
return {
|
|
98
38
|
...props,
|