@rnmapbox/maps 10.0.0-beta.42 → 10.0.0-beta.44
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 +69 -2
- package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/components/camera/CameraStop.java +4 -4
- package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java +3 -3
- package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +6 -6
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +1 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +1 -1
- package/docs/HeadingIndicator.md +1 -1
- package/docs/ShapeSource.md +13 -9
- package/docs/SymbolLayer.md +4 -3
- package/docs/docs.json +41 -67
- package/index.d.ts +16 -128
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +5 -21
- package/ios/install.md +3 -2
- package/javascript/components/AbstractLayer.tsx +72 -0
- package/javascript/components/AbstractSource.tsx +23 -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} +6 -7
- package/javascript/components/HeatmapLayer.js +1 -1
- package/javascript/components/Images.js +1 -1
- package/javascript/components/LineLayer.js +1 -1
- package/javascript/components/MapView.js +5 -2
- package/javascript/components/MarkerView.tsx +1 -0
- package/javascript/components/NativeBridgeComponent.tsx +20 -14
- package/javascript/components/PointAnnotation.tsx +2 -1
- package/javascript/components/RasterLayer.js +1 -1
- package/javascript/components/RasterSource.js +1 -1
- package/javascript/components/ShapeSource.tsx +412 -0
- package/javascript/components/SkyLayer.js +1 -1
- package/javascript/components/Style.js +2 -2
- package/javascript/components/SymbolLayer.tsx +111 -0
- package/javascript/components/Terrain.tsx +0 -60
- package/javascript/components/UserLocation.js +1 -1
- package/javascript/components/VectorSource.js +6 -3
- package/javascript/components/annotations/Annotation.js +1 -1
- package/javascript/global.d.ts +4 -0
- package/javascript/index.js +2 -2
- package/javascript/utils/MapboxStyles.ts +157 -50
- package/javascript/utils/StyleValue.ts +8 -6
- package/javascript/utils/animated/Animated.js +2 -2
- package/javascript/utils/deprecation.ts +7 -4
- package/javascript/utils/{filterUtils.js → filterUtils.tsx} +1 -1
- package/javascript/utils/index.d.ts +16 -3
- 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/AbstractSource.js +0 -15
- package/javascript/components/ShapeSource.js +0 -373
- package/javascript/components/SymbolLayer.js +0 -120
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
HostComponent,
|
|
4
|
+
NativeMethods,
|
|
5
|
+
NativeModules,
|
|
6
|
+
NativeSyntheticEvent,
|
|
7
|
+
requireNativeComponent,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
import { getFilter } from '../utils/filterUtils';
|
|
11
|
+
import {
|
|
12
|
+
toJSONString,
|
|
13
|
+
cloneReactChildrenWithProps,
|
|
14
|
+
isFunction,
|
|
15
|
+
isAndroid,
|
|
16
|
+
} from '../utils';
|
|
17
|
+
import { copyPropertiesAsDeprecated } from '../utils/deprecation';
|
|
18
|
+
|
|
19
|
+
import AbstractSource from './AbstractSource';
|
|
20
|
+
import NativeBridgeComponent from './NativeBridgeComponent';
|
|
21
|
+
|
|
22
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
23
|
+
|
|
24
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLShapeSource';
|
|
25
|
+
|
|
26
|
+
export type OnPressEvent = {
|
|
27
|
+
features: Array<GeoJSON.Feature>;
|
|
28
|
+
coordinates: {
|
|
29
|
+
latitude: number;
|
|
30
|
+
longitude: number;
|
|
31
|
+
};
|
|
32
|
+
point: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type OnPressEventDeprecated = OnPressEvent & {
|
|
38
|
+
nativeEvent?: OnPressEvent;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type Props = {
|
|
42
|
+
/**
|
|
43
|
+
* A string that uniquely identifies the source.
|
|
44
|
+
*/
|
|
45
|
+
id: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* An HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle.
|
|
49
|
+
*/
|
|
50
|
+
url?: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The contents of the source. A shape can represent a GeoJSON geometry, a feature, or a feature collection.
|
|
54
|
+
*/
|
|
55
|
+
shape?:
|
|
56
|
+
| GeoJSON.GeometryCollection
|
|
57
|
+
| GeoJSON.Feature
|
|
58
|
+
| GeoJSON.FeatureCollection
|
|
59
|
+
| GeoJSON.Geometry;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Enables clustering on the source for point shapes.
|
|
63
|
+
*/
|
|
64
|
+
cluster?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Specifies the radius of each cluster if clustering is enabled.
|
|
68
|
+
* A value of 512 produces a radius equal to the width of a tile.
|
|
69
|
+
* The default value is 50.
|
|
70
|
+
*/
|
|
71
|
+
clusterRadius?: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Specifies the maximum zoom level at which to cluster points if clustering is enabled.
|
|
75
|
+
* Defaults to one zoom level less than the value of maxZoomLevel so that, at the maximum zoom level,
|
|
76
|
+
* the shapes are not clustered.
|
|
77
|
+
*/
|
|
78
|
+
clusterMaxZoomLevel?: number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* [`mapbox-gl` (v8) implementation only]
|
|
82
|
+
* Specifies custom properties on the generated clusters if clustering
|
|
83
|
+
* is enabled, aggregating values from clustered points.
|
|
84
|
+
*
|
|
85
|
+
* Has the form `{ "property_name": [operator, map_expression]}`, where
|
|
86
|
+
* `operator` is a custom reduce expression that references a special `["accumulated"]` value -
|
|
87
|
+
* it accumulates the property value from clusters/points the cluster contains
|
|
88
|
+
* `map_expression` produces the value of a single point
|
|
89
|
+
*
|
|
90
|
+
* Example: `{ "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }`
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
clusterProperties?: object;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Specifies the maximum zoom level at which to create vector tiles.
|
|
97
|
+
* A greater value produces greater detail at high zoom levels.
|
|
98
|
+
* The default value is 18.
|
|
99
|
+
*/
|
|
100
|
+
maxZoomLevel?: number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Specifies the size of the tile buffer on each side.
|
|
104
|
+
* A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself.
|
|
105
|
+
* Larger values produce fewer rendering artifacts near tile edges and slower performance.
|
|
106
|
+
* The default value is 128.
|
|
107
|
+
*/
|
|
108
|
+
buffer?: number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Specifies the Douglas-Peucker simplification tolerance.
|
|
112
|
+
* A greater value produces simpler geometries and improves performance.
|
|
113
|
+
* The default value is 0.375.
|
|
114
|
+
*/
|
|
115
|
+
tolerance?: number;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Whether to calculate line distance metrics.
|
|
119
|
+
* This is required for line layers that specify lineGradient values.
|
|
120
|
+
* The default value is false.
|
|
121
|
+
*/
|
|
122
|
+
lineMetrics?: boolean;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Source press listener, gets called when a user presses one of the children layers only
|
|
126
|
+
* if that layer has a higher z-index than another source layers
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} event
|
|
129
|
+
* @param {Object[]} event.features - the geojson features that have hit by the press (might be multiple)
|
|
130
|
+
* @param {Object} event.coordinates - the coordinates of the click
|
|
131
|
+
* @param {Object} event.point - the point of the click
|
|
132
|
+
* @return void
|
|
133
|
+
*/
|
|
134
|
+
onPress?: (event: OnPressEvent) => void;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Overrides the default touch hitbox(44x44 pixels) for the source layers
|
|
138
|
+
*/
|
|
139
|
+
hitbox?: {
|
|
140
|
+
/**
|
|
141
|
+
* `width` of hitbox
|
|
142
|
+
*/
|
|
143
|
+
width: number;
|
|
144
|
+
/**
|
|
145
|
+
* `height` of hitbox
|
|
146
|
+
*/
|
|
147
|
+
height: number;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
children: React.ReactElement | React.ReactElement[];
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* ShapeSource is a map content source that supplies vector shapes to be shown on the map.
|
|
155
|
+
* The shape may be an url or a GeoJSON object
|
|
156
|
+
*/
|
|
157
|
+
export class ShapeSource extends NativeBridgeComponent(
|
|
158
|
+
AbstractSource<Props, NativeProps>,
|
|
159
|
+
NATIVE_MODULE_NAME,
|
|
160
|
+
) {
|
|
161
|
+
static NATIVE_ASSETS_KEY = 'assets';
|
|
162
|
+
|
|
163
|
+
static defaultProps = {
|
|
164
|
+
id: MapboxGL.StyleSource.DefaultSourceID,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
constructor(props: Props) {
|
|
168
|
+
super(props);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
_setNativeRef(
|
|
172
|
+
nativeRef: React.Component<NativeProps> & Readonly<NativeMethods>,
|
|
173
|
+
) {
|
|
174
|
+
this.setNativeRef(nativeRef);
|
|
175
|
+
super._runPendingNativeCommands(nativeRef);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Returns all features from the source that match the query parameters whether the feature is currently
|
|
180
|
+
* rendered on the map.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* shapeSource.features()
|
|
184
|
+
*
|
|
185
|
+
* @param {Array=} filter - an optional filter statement to filter the returned Features.
|
|
186
|
+
* @return {FeatureCollection}
|
|
187
|
+
*/
|
|
188
|
+
async features(filter: Array<string> = []) {
|
|
189
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
190
|
+
'features',
|
|
191
|
+
this._nativeRef,
|
|
192
|
+
getFilter(filter),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
if (isAndroid()) {
|
|
196
|
+
return JSON.parse(res.data);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return res.data;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Returns the zoom needed to expand the cluster.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
|
|
207
|
+
*
|
|
208
|
+
* @param {Feature} feature - The feature cluster to expand.
|
|
209
|
+
* @return {number}
|
|
210
|
+
*/
|
|
211
|
+
async getClusterExpansionZoom(
|
|
212
|
+
feature: string | GeoJSON.Feature,
|
|
213
|
+
): Promise<string> {
|
|
214
|
+
if (typeof feature === 'number') {
|
|
215
|
+
console.warn(
|
|
216
|
+
'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
|
|
217
|
+
);
|
|
218
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
219
|
+
'getClusterExpansionZoomById',
|
|
220
|
+
this._nativeRef,
|
|
221
|
+
[feature],
|
|
222
|
+
);
|
|
223
|
+
return res.data;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
227
|
+
'getClusterExpansionZoom',
|
|
228
|
+
this._nativeRef,
|
|
229
|
+
[JSON.stringify(feature)],
|
|
230
|
+
);
|
|
231
|
+
return res.data;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Returns the FeatureCollection from the cluster.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
|
|
239
|
+
*
|
|
240
|
+
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
241
|
+
* @param {number} limit - The number of points to return.
|
|
242
|
+
* @param {number} offset - The amount of points to skip (for pagination).
|
|
243
|
+
* @return {FeatureCollection}
|
|
244
|
+
*/
|
|
245
|
+
async getClusterLeaves(
|
|
246
|
+
feature: number | GeoJSON.Feature,
|
|
247
|
+
limit: number,
|
|
248
|
+
offset: number,
|
|
249
|
+
) {
|
|
250
|
+
if (typeof feature === 'number') {
|
|
251
|
+
console.warn(
|
|
252
|
+
'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
|
|
253
|
+
);
|
|
254
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
255
|
+
'getClusterLeavesById',
|
|
256
|
+
this._nativeRef,
|
|
257
|
+
[feature, limit, offset],
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
if (isAndroid()) {
|
|
261
|
+
return JSON.parse(res.data);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return res.data;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
268
|
+
'getClusterLeaves',
|
|
269
|
+
this._nativeRef,
|
|
270
|
+
[JSON.stringify(feature), limit, offset],
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
if (isAndroid()) {
|
|
274
|
+
return JSON.parse(res.data);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return res.data;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Returns the FeatureCollection from the cluster (on the next zoom level).
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* const collection = await shapeSource.getClusterChildren(clusterId);
|
|
285
|
+
*
|
|
286
|
+
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
287
|
+
* @return {FeatureCollection}
|
|
288
|
+
*/
|
|
289
|
+
async getClusterChildren(feature: number | GeoJSON.Feature) {
|
|
290
|
+
if (typeof feature === 'number') {
|
|
291
|
+
console.warn(
|
|
292
|
+
'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
|
|
293
|
+
);
|
|
294
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
295
|
+
'getClusterChildrenById',
|
|
296
|
+
this._nativeRef,
|
|
297
|
+
[feature],
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
if (isAndroid()) {
|
|
301
|
+
return JSON.parse(res.data);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return res.data;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
308
|
+
'getClusterChildren',
|
|
309
|
+
this._nativeRef,
|
|
310
|
+
[JSON.stringify(feature)],
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
if (isAndroid()) {
|
|
314
|
+
return JSON.parse(res.data);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return res.data;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
setNativeProps(props: NativeProps) {
|
|
321
|
+
const shallowProps = Object.assign({}, props);
|
|
322
|
+
|
|
323
|
+
// Adds support for Animated
|
|
324
|
+
if (shallowProps.shape && typeof shallowProps.shape !== 'string') {
|
|
325
|
+
shallowProps.shape = JSON.stringify(shallowProps.shape);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
super.setNativeProps(shallowProps);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
_getShape() {
|
|
332
|
+
if (!this.props.shape) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
return toJSONString(this.props.shape);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
onPress(
|
|
339
|
+
event: NativeSyntheticEvent<{
|
|
340
|
+
payload: OnPressEvent;
|
|
341
|
+
}>,
|
|
342
|
+
) {
|
|
343
|
+
const {
|
|
344
|
+
nativeEvent: {
|
|
345
|
+
payload: { features, coordinates, point },
|
|
346
|
+
},
|
|
347
|
+
} = event;
|
|
348
|
+
let newEvent: OnPressEventDeprecated = {
|
|
349
|
+
features,
|
|
350
|
+
coordinates,
|
|
351
|
+
point,
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
newEvent = copyPropertiesAsDeprecated(
|
|
355
|
+
event as unknown as Record<string, unknown>,
|
|
356
|
+
newEvent,
|
|
357
|
+
(key) => {
|
|
358
|
+
console.warn(
|
|
359
|
+
`event.${key} is deprecated on ShapeSource#onPress, please use event.features`,
|
|
360
|
+
);
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
nativeEvent: (origNativeEvent: unknown) => ({
|
|
364
|
+
...(origNativeEvent as OnPressEvent),
|
|
365
|
+
payload: features[0],
|
|
366
|
+
}),
|
|
367
|
+
},
|
|
368
|
+
);
|
|
369
|
+
this.props.onPress?.(newEvent);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
render() {
|
|
373
|
+
const props = {
|
|
374
|
+
id: this.props.id,
|
|
375
|
+
url: this.props.url,
|
|
376
|
+
shape: this._getShape(),
|
|
377
|
+
hitbox: this.props.hitbox,
|
|
378
|
+
hasPressListener: isFunction(this.props.onPress),
|
|
379
|
+
onMapboxShapeSourcePress: this.onPress.bind(this),
|
|
380
|
+
cluster: this.props.cluster ? 1 : 0,
|
|
381
|
+
clusterRadius: this.props.clusterRadius,
|
|
382
|
+
clusterMaxZoomLevel: this.props.clusterMaxZoomLevel,
|
|
383
|
+
clusterProperties: this.props.clusterProperties,
|
|
384
|
+
maxZoomLevel: this.props.maxZoomLevel,
|
|
385
|
+
buffer: this.props.buffer,
|
|
386
|
+
tolerance: this.props.tolerance,
|
|
387
|
+
lineMetrics: this.props.lineMetrics,
|
|
388
|
+
onPress: undefined,
|
|
389
|
+
ref: (
|
|
390
|
+
nativeRef: React.Component<NativeProps> & Readonly<NativeMethods>,
|
|
391
|
+
) => this._setNativeRef(nativeRef),
|
|
392
|
+
onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
return (
|
|
396
|
+
<RCTMGLShapeSource {...props}>
|
|
397
|
+
{cloneReactChildrenWithProps(this.props.children, {
|
|
398
|
+
sourceID: this.props.id,
|
|
399
|
+
})}
|
|
400
|
+
</RCTMGLShapeSource>
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
type NativeProps = {
|
|
406
|
+
id: string;
|
|
407
|
+
shape?: string;
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
type NativeShapeSource = HostComponent<NativeProps>;
|
|
411
|
+
const RCTMGLShapeSource: NativeShapeSource =
|
|
412
|
+
requireNativeComponent(NATIVE_MODULE_NAME);
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
|
|
4
4
|
import CircleLayer from './CircleLayer';
|
|
5
5
|
import RasterLayer from './RasterLayer';
|
|
6
|
-
import SymbolLayer from './SymbolLayer';
|
|
6
|
+
import { SymbolLayer } from './SymbolLayer';
|
|
7
7
|
import LineLayer from './LineLayer';
|
|
8
8
|
import FillLayer from './FillLayer';
|
|
9
9
|
import FillExtrusionLayer from './FillExtrusionLayer';
|
|
@@ -12,7 +12,7 @@ import HeatmapLayer from './HeatmapLayer';
|
|
|
12
12
|
import VectorSource from './VectorSource';
|
|
13
13
|
import RasterSource from './RasterSource';
|
|
14
14
|
import ImageSource from './ImageSource';
|
|
15
|
-
import ShapeSource from './ShapeSource';
|
|
15
|
+
import { ShapeSource } from './ShapeSource';
|
|
16
16
|
|
|
17
17
|
function toCamelCase(s) {
|
|
18
18
|
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
export 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
|
+
}
|
|
@@ -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,
|
|
@@ -22,7 +22,10 @@ export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
|
|
|
22
22
|
* VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
|
|
23
23
|
* 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.
|
|
24
24
|
*/
|
|
25
|
-
class VectorSource extends NativeBridgeComponent(
|
|
25
|
+
class VectorSource extends NativeBridgeComponent(
|
|
26
|
+
AbstractSource,
|
|
27
|
+
NATIVE_MODULE_NAME,
|
|
28
|
+
) {
|
|
26
29
|
static propTypes = {
|
|
27
30
|
...viewPropTypes,
|
|
28
31
|
|
|
@@ -98,7 +101,7 @@ class VectorSource extends NativeBridgeComponent(AbstractSource) {
|
|
|
98
101
|
};
|
|
99
102
|
|
|
100
103
|
constructor(props) {
|
|
101
|
-
super(props
|
|
104
|
+
super(props);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
_setNativeRef(nativeRef) {
|
|
@@ -177,7 +180,7 @@ class VectorSource extends NativeBridgeComponent(AbstractSource) {
|
|
|
177
180
|
onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
|
|
178
181
|
};
|
|
179
182
|
return (
|
|
180
|
-
<RCTMGLVectorSource ref=
|
|
183
|
+
<RCTMGLVectorSource ref={this.setNativeRef} {...props}>
|
|
181
184
|
{cloneReactChildrenWithProps(this.props.children, {
|
|
182
185
|
sourceID: this.props.id,
|
|
183
186
|
})}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Easing } from 'react-native';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
|
|
5
|
-
import SymbolLayer from '../SymbolLayer';
|
|
5
|
+
import { SymbolLayer } from '../SymbolLayer';
|
|
6
6
|
import Animated from '../../utils/animated/Animated';
|
|
7
7
|
import { AnimatedPoint } from '../../classes';
|
|
8
8
|
|
package/javascript/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import Annotation from './components/annotations/Annotation';
|
|
|
9
9
|
import Callout from './components/Callout';
|
|
10
10
|
import UserLocation from './components/UserLocation';
|
|
11
11
|
import VectorSource from './components/VectorSource';
|
|
12
|
-
import ShapeSource from './components/ShapeSource';
|
|
12
|
+
import { ShapeSource } from './components/ShapeSource';
|
|
13
13
|
import RasterSource from './components/RasterSource';
|
|
14
14
|
import RasterDemSource from './components/RasterDemSource';
|
|
15
15
|
import ImageSource from './components/ImageSource';
|
|
@@ -20,7 +20,7 @@ import HeatmapLayer from './components/HeatmapLayer';
|
|
|
20
20
|
import LineLayer from './components/LineLayer';
|
|
21
21
|
import CircleLayer from './components/CircleLayer';
|
|
22
22
|
import SkyLayer from './components/SkyLayer';
|
|
23
|
-
import SymbolLayer from './components/SymbolLayer';
|
|
23
|
+
import { SymbolLayer } from './components/SymbolLayer';
|
|
24
24
|
import RasterLayer from './components/RasterLayer';
|
|
25
25
|
import BackgroundLayer from './components/BackgroundLayer';
|
|
26
26
|
import { Terrain } from './components/Terrain';
|