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