@maplibre/maplibre-react-native 9.1.0 → 10.0.0-alpha.2

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 (141) hide show
  1. package/.eslintrc.js +10 -2
  2. package/.husky/pre-commit +5 -0
  3. package/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
  4. package/.yarn/sdks/eslint/bin/eslint.js +20 -0
  5. package/.yarn/sdks/eslint/lib/api.js +20 -0
  6. package/.yarn/sdks/eslint/package.json +6 -0
  7. package/.yarn/sdks/integrations.yml +5 -0
  8. package/.yarn/sdks/prettier/index.js +20 -0
  9. package/.yarn/sdks/prettier/package.json +6 -0
  10. package/.yarn/sdks/typescript/bin/tsc +20 -0
  11. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  12. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  13. package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
  14. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
  15. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  16. package/.yarn/sdks/typescript/package.json +6 -0
  17. package/CHANGELOG.md +18 -0
  18. package/android/rctmgl/build.gradle +7 -7
  19. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java +2 -2
  20. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java +21 -26
  21. package/docs/Annotation.md +8 -9
  22. package/docs/BackgroundLayer.md +2 -10
  23. package/docs/Callout.md +5 -5
  24. package/docs/Camera.md +18 -47
  25. package/docs/CircleLayer.md +2 -10
  26. package/docs/FillExtrusionLayer.md +2 -10
  27. package/docs/FillLayer.md +2 -10
  28. package/docs/HeatmapLayer.md +2 -10
  29. package/docs/ImageSource.md +3 -2
  30. package/docs/Images.md +5 -3
  31. package/docs/Light.md +1 -1
  32. package/docs/LineLayer.md +2 -10
  33. package/docs/MapView.md +53 -37
  34. package/docs/MarkerView.md +4 -2
  35. package/docs/NativeUserLocation.md +2 -2
  36. package/docs/PointAnnotation.md +5 -8
  37. package/docs/RasterLayer.md +2 -10
  38. package/docs/RasterSource.md +3 -2
  39. package/docs/ShapeSource.md +12 -7
  40. package/docs/Style.md +1 -1
  41. package/docs/SymbolLayer.md +3 -10
  42. package/docs/UserLocation.md +8 -10
  43. package/docs/VectorSource.md +6 -5
  44. package/docs/coordinates.md +6 -0
  45. package/docs/docs.json +518 -1272
  46. package/docs/location.md +6 -0
  47. package/docs/snapshotManager.md +3 -3
  48. package/javascript/@types/assets.d.ts +4 -0
  49. package/javascript/MGLModule.ts +37 -0
  50. package/javascript/Maplibre.ts +65 -0
  51. package/javascript/components/AbstractLayer.tsx +107 -0
  52. package/javascript/components/AbstractSource.tsx +27 -0
  53. package/javascript/components/BackgroundLayer.tsx +43 -0
  54. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  55. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  56. package/javascript/components/CircleLayer.tsx +46 -0
  57. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  58. package/javascript/components/FillLayer.tsx +41 -0
  59. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  60. package/javascript/components/HeatmapLayer.tsx +44 -0
  61. package/javascript/components/ImageSource.tsx +78 -0
  62. package/javascript/components/Images.tsx +134 -0
  63. package/javascript/components/Light.tsx +67 -0
  64. package/javascript/components/LineLayer.tsx +42 -0
  65. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  66. package/javascript/components/MarkerView.tsx +104 -0
  67. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  68. package/javascript/components/NativeUserLocation.tsx +33 -0
  69. package/javascript/components/PointAnnotation.tsx +221 -0
  70. package/javascript/components/RasterLayer.tsx +41 -0
  71. package/javascript/components/RasterSource.tsx +117 -0
  72. package/javascript/components/ShapeSource.tsx +383 -0
  73. package/javascript/components/{Style.js → Style.tsx} +129 -38
  74. package/javascript/components/SymbolLayer.tsx +72 -0
  75. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  76. package/javascript/components/VectorSource.tsx +207 -0
  77. package/javascript/components/annotations/Annotation.tsx +134 -0
  78. package/javascript/index.ts +4 -0
  79. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  80. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  81. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  82. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  83. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  84. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  85. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  86. package/javascript/types/BaseProps.ts +5 -0
  87. package/javascript/types/OnPressEvent.ts +13 -0
  88. package/javascript/types/index.ts +7 -0
  89. package/javascript/utils/BridgeValue.ts +90 -0
  90. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  91. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  92. package/javascript/utils/StyleValue.ts +49 -0
  93. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  94. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  95. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  96. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  97. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  98. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  99. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  100. package/javascript/utils/filterUtils.ts +9 -0
  101. package/javascript/utils/geoUtils.ts +79 -0
  102. package/javascript/utils/{index.js → index.ts} +44 -24
  103. package/javascript/utils/styleMap.ts +264 -0
  104. package/package.json +35 -27
  105. package/plugin/build/withMapLibre.js +18 -3
  106. package/scripts/autogenHelpers/globals.js +1 -1
  107. package/scripts/autogenerate.js +14 -6
  108. package/scripts/download-style-spec.sh +1 -1
  109. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  110. package/scripts/templates/index.d.ts.ejs +71 -42
  111. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  112. package/setup-jest.js +1 -10
  113. package/tsconfig.json +20 -61
  114. package/index.d.ts +0 -955
  115. package/javascript/components/AbstractLayer.js +0 -75
  116. package/javascript/components/AbstractSource.js +0 -15
  117. package/javascript/components/BackgroundLayer.js +0 -97
  118. package/javascript/components/CircleLayer.js +0 -101
  119. package/javascript/components/FillExtrusionLayer.js +0 -98
  120. package/javascript/components/FillLayer.js +0 -94
  121. package/javascript/components/HeatmapLayer.js +0 -99
  122. package/javascript/components/ImageSource.js +0 -82
  123. package/javascript/components/Images.js +0 -119
  124. package/javascript/components/Light.js +0 -47
  125. package/javascript/components/LineLayer.js +0 -94
  126. package/javascript/components/MarkerView.js +0 -87
  127. package/javascript/components/NativeUserLocation.js +0 -41
  128. package/javascript/components/PointAnnotation.js +0 -216
  129. package/javascript/components/RasterLayer.js +0 -95
  130. package/javascript/components/RasterSource.js +0 -124
  131. package/javascript/components/ShapeSource.js +0 -372
  132. package/javascript/components/SymbolLayer.js +0 -120
  133. package/javascript/components/VectorSource.js +0 -200
  134. package/javascript/components/annotations/Annotation.js +0 -122
  135. package/javascript/index.js +0 -149
  136. package/javascript/utils/BridgeValue.js +0 -81
  137. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  138. package/javascript/utils/filterUtils.js +0 -7
  139. package/javascript/utils/geoUtils.js +0 -73
  140. package/javascript/utils/styleMap.js +0 -1932
  141. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -1,124 +0,0 @@
1
- import {cloneReactChildrenWithProps, viewPropTypes} from '../utils';
2
-
3
- import AbstractSource from './AbstractSource';
4
-
5
- import PropTypes from 'prop-types';
6
- import {NativeModules, requireNativeComponent} from 'react-native';
7
- import React from 'react';
8
-
9
- const MapLibreGL = NativeModules.MGLModule;
10
-
11
- export const NATIVE_MODULE_NAME = 'RCTMGLRasterSource';
12
-
13
- const isTileTemplateUrl = url =>
14
- url &&
15
- (url.includes('{z}') || url.includes('{bbox-') || url.includes('{quadkey}'));
16
-
17
- /**
18
- * RasterSource is a map content source that supplies raster image tiles to be shown on the map.
19
- * The location of and metadata about the tiles are defined either by an option dictionary
20
- * or by an external file that conforms to the TileJSON specification.
21
- */
22
- class RasterSource extends AbstractSource {
23
- static propTypes = {
24
- ...viewPropTypes,
25
-
26
- /**
27
- * A string that uniquely identifies the source.
28
- */
29
- id: PropTypes.string.isRequired,
30
-
31
- /**
32
- * A URL to a TileJSON configuration file describing the source’s contents and other metadata.
33
- */
34
- url: PropTypes.string,
35
-
36
- /**
37
- * An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.
38
- * Example: https://example.com/raster-tiles/{z}/{x}/{y}.png
39
- */
40
- tileUrlTemplates: PropTypes.arrayOf(PropTypes.string),
41
-
42
- /**
43
- * An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
44
- * The value should be between 0 and 22, inclusive, and less than
45
- * maxZoomLevel, if specified. The default value for this option is 0.
46
- */
47
- minZoomLevel: PropTypes.number,
48
-
49
- /**
50
- * An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
51
- * The value should be between 0 and 22, inclusive, and less than
52
- * minZoomLevel, if specified. The default value for this option is 22.
53
- */
54
- maxZoomLevel: PropTypes.number,
55
-
56
- /**
57
- * Size of the map tiles.
58
- * Mapbox urls default to 256, all others default to 512.
59
- */
60
- tileSize: PropTypes.number,
61
-
62
- /**
63
- * Influences the y direction of the tile coordinates. (tms inverts y axis)
64
- */
65
- tms: PropTypes.bool,
66
-
67
- /**
68
- * An HTML or literal text string defining the buttons to be displayed in an action sheet when the
69
- * source is part of a map view’s style and the map view’s attribution button is pressed.
70
- */
71
- attribution: PropTypes.string,
72
- };
73
-
74
- static defaultProps = {
75
- id: MapLibreGL.StyleSource.DefaultSourceID,
76
- };
77
-
78
- constructor(props) {
79
- super(props);
80
- if (isTileTemplateUrl(props.url)) {
81
- console.warn(
82
- `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.`,
83
- );
84
- }
85
- }
86
-
87
- render() {
88
- let {url} = this.props;
89
- let {tileUrlTemplates} = this.props;
90
-
91
- // Swapping url for tileUrlTemplates to provide backward compatiblity
92
- // when RasterSource supported only tile url as url prop
93
- if (isTileTemplateUrl(url)) {
94
- tileUrlTemplates = [url];
95
- url = undefined;
96
- }
97
-
98
- const props = {
99
- ...this.props,
100
- id: this.props.id,
101
- url,
102
- tileUrlTemplates,
103
- minZoomLevel: this.props.minZoomLevel,
104
- maxZoomLevel: this.props.maxZoomLevel,
105
- tileSize: this.props.tileSize,
106
- tms: this.props.tms,
107
- attribution: this.props.attribution,
108
- };
109
- return (
110
- <RCTMGLRasterSource ref="nativeSource" {...props}>
111
- {cloneReactChildrenWithProps(this.props.children, {
112
- sourceID: this.props.id,
113
- })}
114
- </RCTMGLRasterSource>
115
- );
116
- }
117
- }
118
-
119
- const RCTMGLRasterSource = requireNativeComponent(
120
- NATIVE_MODULE_NAME,
121
- RasterSource,
122
- );
123
-
124
- export default RasterSource;
@@ -1,372 +0,0 @@
1
- import {getFilter} from '../utils/filterUtils';
2
- import {
3
- toJSONString,
4
- cloneReactChildrenWithProps,
5
- viewPropTypes,
6
- isFunction,
7
- isAndroid,
8
- } from '../utils';
9
- import {copyPropertiesAsDeprecated} from '../utils/deprecation';
10
-
11
- import AbstractSource from './AbstractSource';
12
- import NativeBridgeComponent from './NativeBridgeComponent';
13
-
14
- import PropTypes from 'prop-types';
15
- import React from 'react';
16
- import {NativeModules, requireNativeComponent} from 'react-native';
17
-
18
- const MapLibreGL = 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 a 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 colllection.
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
- * Specifies custom properties on the generated clusters if clustering
68
- * is enabled, aggregating values from clustered points.
69
- *
70
- * Has the form `{ "property_name": [operator, map_expression]}`, where
71
- * `operator` is a custom reduce expression that references a special `["accumulated"]` value -
72
- * it accumulates the property value from clusters/points the cluster contains
73
- * `map_expression` produces the value of a single point
74
- *
75
- * Example: `{ "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }`
76
- *
77
- */
78
- clusterProperties: PropTypes.object,
79
-
80
- /**
81
- * Specifies the maximum zoom level at which to create vector tiles.
82
- * A greater value produces greater detail at high zoom levels.
83
- * The default value is 18.
84
- */
85
- maxZoomLevel: PropTypes.number,
86
-
87
- /**
88
- * Specifies the size of the tile buffer on each side.
89
- * A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself.
90
- * Larger values produce fewer rendering artifacts near tile edges and slower performance.
91
- * The default value is 128.
92
- */
93
- buffer: PropTypes.number,
94
-
95
- /**
96
- * Specifies the Douglas-Peucker simplification tolerance.
97
- * A greater value produces simpler geometries and improves performance.
98
- * The default value is 0.375.
99
- */
100
- tolerance: PropTypes.number,
101
-
102
- /**
103
- * Whether to calculate line distance metrics.
104
- * This is required for line layers that specify lineGradient values.
105
- * The default value is false.
106
- */
107
- lineMetrics: PropTypes.bool,
108
-
109
- /**
110
- * Source press listener, gets called when a user presses one of the children layers only
111
- * if that layer has a higher z-index than another source layers
112
- *
113
- * @param {Object} event
114
- * @param {Object[]} event.features - the geojson features that have hit by the press (might be multiple)
115
- * @param {Object} event.coordinates - the coordinates of the click
116
- * @param {Object} event.point - the point of the click
117
- * @return void
118
- */
119
- onPress: PropTypes.func,
120
-
121
- /**
122
- * Overrides the default touch hitbox(44x44 pixels) for the source layers
123
- */
124
- hitbox: PropTypes.shape({
125
- /**
126
- * `width` of hitbox
127
- */
128
- width: PropTypes.number.isRequired,
129
- /**
130
- * `height` of hitbox
131
- */
132
- height: PropTypes.number.isRequired,
133
- }),
134
- };
135
-
136
- static defaultProps = {
137
- id: MapLibreGL.StyleSource.DefaultSourceID,
138
- };
139
-
140
- constructor(props) {
141
- super(props, NATIVE_MODULE_NAME);
142
- }
143
-
144
- _setNativeRef(nativeRef) {
145
- this._nativeRef = nativeRef;
146
- super._runPendingNativeCommands(nativeRef);
147
- }
148
-
149
- /**
150
- * Returns all features from the source that match the query parameters regardless of whether or not the feature is
151
- * currently rendered on the map.
152
- *
153
- * @example
154
- * shapeSource.features()
155
- *
156
- * @param {Array=} filter - an optional filter statement to filter the returned Features.
157
- * @return {FeatureCollection}
158
- */
159
- async features(filter = []) {
160
- const res = await this._runNativeCommand('features', this._nativeRef, [
161
- getFilter(filter),
162
- ]);
163
-
164
- if (isAndroid()) {
165
- return JSON.parse(res.data);
166
- }
167
-
168
- return res.data;
169
- }
170
-
171
- /**
172
- * Returns the zoom needed to expand the cluster.
173
- *
174
- * @example
175
- * const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
176
- *
177
- * @param {Feature} feature - The feature cluster to expand.
178
- * @return {number}
179
- */
180
- async getClusterExpansionZoom(feature) {
181
- if (typeof feature === 'number') {
182
- console.warn(
183
- 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
184
- );
185
- const res = await this._runNativeCommand(
186
- 'getClusterExpansionZoomById',
187
- this._nativeRef,
188
- [feature],
189
- );
190
- return res.data;
191
- }
192
-
193
- const res = await this._runNativeCommand(
194
- 'getClusterExpansionZoom',
195
- this._nativeRef,
196
- [JSON.stringify(feature)],
197
- );
198
- return res.data;
199
- }
200
-
201
- /**
202
- * Returns the FeatureCollection from the cluster.
203
- *
204
- * @example
205
- * const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
206
- *
207
- * @param {Feature} feature - The feature cluster to expand.
208
- * @param {number} limit - The number of points to return.
209
- * @param {number} offset - The amount of points to skip (for pagination).
210
- * @return {FeatureCollection}
211
- */
212
- async getClusterLeaves(feature, limit, offset) {
213
- if (typeof feature === 'number') {
214
- console.warn(
215
- 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
216
- );
217
- const res = await this._runNativeCommand(
218
- 'getClusterLeavesById',
219
- this._nativeRef,
220
- [feature, limit, offset],
221
- );
222
-
223
- if (isAndroid()) {
224
- return JSON.parse(res.data);
225
- }
226
-
227
- return res.data;
228
- }
229
-
230
- const res = await this._runNativeCommand(
231
- 'getClusterLeaves',
232
- this._nativeRef,
233
- [JSON.stringify(feature), limit, offset],
234
- );
235
-
236
- if (isAndroid()) {
237
- return JSON.parse(res.data);
238
- }
239
-
240
- return res.data;
241
- }
242
-
243
- /**
244
- * Returns the FeatureCollection from the cluster (on the next zoom level).
245
- *
246
- * @example
247
- * const collection = await shapeSource.getClusterChildren(clusterId);
248
- *
249
- * @param {Feature} feature - The feature cluster to expand.
250
- * @return {FeatureCollection}
251
- */
252
- async getClusterChildren(feature) {
253
- if (typeof feature === 'number') {
254
- console.warn(
255
- 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
256
- );
257
- const res = await this._runNativeCommand(
258
- 'getClusterChildrenById',
259
- this._nativeRef,
260
- [feature],
261
- );
262
-
263
- if (isAndroid()) {
264
- return JSON.parse(res.data);
265
- }
266
-
267
- return res.data;
268
- }
269
-
270
- const res = await this._runNativeCommand(
271
- 'getClusterChildren',
272
- this._nativeRef,
273
- [JSON.stringify(feature)],
274
- );
275
-
276
- if (isAndroid()) {
277
- return JSON.parse(res.data);
278
- }
279
-
280
- return res.data;
281
- }
282
-
283
- setNativeProps(props) {
284
- const shallowProps = Object.assign({}, props);
285
-
286
- // Adds support for Animated
287
- if (shallowProps.shape && typeof shallowProps !== 'string') {
288
- shallowProps.shape = JSON.stringify(shallowProps.shape);
289
- }
290
-
291
- super.setNativeProps(shallowProps);
292
- }
293
-
294
- _getShape() {
295
- if (!this.props.shape) {
296
- return;
297
- }
298
- return toJSONString(this.props.shape);
299
- }
300
-
301
- onPress(event) {
302
- const {
303
- nativeEvent: {
304
- payload: {features, coordinates, point},
305
- },
306
- } = event;
307
- let newEvent = {
308
- features,
309
- coordinates,
310
- point,
311
- };
312
- newEvent = copyPropertiesAsDeprecated(
313
- event,
314
- newEvent,
315
- key => {
316
- console.warn(
317
- `event.${key} is deprecated on ShapeSource#onPress, please use event.features`,
318
- );
319
- },
320
- {
321
- nativeEvent: origNativeEvent => ({
322
- ...origNativeEvent,
323
- payload: features[0],
324
- }),
325
- },
326
- );
327
- this.props.onPress(newEvent);
328
- }
329
-
330
- render() {
331
- const props = {
332
- id: this.props.id,
333
- url: this.props.url,
334
- shape: this._getShape(),
335
- hitbox: this.props.hitbox,
336
- hasPressListener: isFunction(this.props.onPress),
337
- onMapboxShapeSourcePress: this.onPress.bind(this),
338
- cluster: this.props.cluster ? 1 : 0,
339
- clusterRadius: this.props.clusterRadius,
340
- clusterMaxZoomLevel: this.props.clusterMaxZoomLevel,
341
- clusterProperties: this.props.clusterProperties,
342
- maxZoomLevel: this.props.maxZoomLevel,
343
- buffer: this.props.buffer,
344
- tolerance: this.props.tolerance,
345
- lineMetrics: this.props.lineMetrics,
346
- onPress: undefined,
347
- ref: nativeRef => this._setNativeRef(nativeRef),
348
- onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
349
- };
350
-
351
- return (
352
- <RCTMGLShapeSource {...props}>
353
- {cloneReactChildrenWithProps(this.props.children, {
354
- sourceID: this.props.id,
355
- })}
356
- </RCTMGLShapeSource>
357
- );
358
- }
359
- }
360
-
361
- const RCTMGLShapeSource = requireNativeComponent(
362
- NATIVE_MODULE_NAME,
363
- ShapeSource,
364
- {
365
- nativeOnly: {
366
- hasPressListener: true,
367
- onMapboxShapeSourcePress: true,
368
- },
369
- },
370
- );
371
-
372
- export default ShapeSource;
@@ -1,120 +0,0 @@
1
- import {viewPropTypes} from '../utils';
2
- import {SymbolLayerStyleProp} from '../utils/styleMap';
3
-
4
- import AbstractLayer from './AbstractLayer';
5
-
6
- import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import {View, NativeModules, requireNativeComponent} from 'react-native';
9
-
10
- const MapLibreGL = NativeModules.MGLModule;
11
-
12
- export const NATIVE_MODULE_NAME = 'RCTMGLSymbolLayer';
13
-
14
- /**
15
- * SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
16
- */
17
- class SymbolLayer extends AbstractLayer {
18
- static propTypes = {
19
- ...viewPropTypes,
20
-
21
- /**
22
- * A string that uniquely identifies the source in the style to which it is added.
23
- */
24
- id: PropTypes.string.isRequired,
25
-
26
- /**
27
- * The source from which to obtain the data to style.
28
- * If the source has not yet been added to the current style, the behavior is undefined.
29
- * Inferred from parent source only if the layer is a direct child to it.
30
- */
31
- sourceID: PropTypes.string,
32
-
33
- /**
34
- * Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
35
- */
36
- sourceLayerID: PropTypes.string,
37
-
38
- /**
39
- * Inserts a layer above aboveLayerID.
40
- */
41
- aboveLayerID: PropTypes.string,
42
-
43
- /**
44
- * Inserts a layer below belowLayerID
45
- */
46
- belowLayerID: PropTypes.string,
47
-
48
- /**
49
- * Inserts a layer at a specified index
50
- */
51
- layerIndex: PropTypes.number,
52
-
53
- /**
54
- * Filter only the features in the source layer that satisfy a condition that you define
55
- */
56
- filter: PropTypes.array,
57
-
58
- /**
59
- * The minimum zoom level at which the layer gets parsed and appears.
60
- */
61
- minZoomLevel: PropTypes.number,
62
-
63
- /**
64
- * The maximum zoom level at which the layer gets parsed and appears.
65
- */
66
- maxZoomLevel: PropTypes.number,
67
-
68
- /**
69
- * Customizable style attributes
70
- */
71
- style: PropTypes.oneOfType([
72
- SymbolLayerStyleProp,
73
- PropTypes.arrayOf(SymbolLayerStyleProp),
74
- ]),
75
- };
76
-
77
- static defaultProps = {
78
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
79
- };
80
-
81
- _shouldSnapshot() {
82
- let isSnapshot = false;
83
-
84
- if (React.Children.count(this.props.children) <= 0) {
85
- return isSnapshot;
86
- }
87
-
88
- React.Children.forEach(this.props.children, child => {
89
- if (child.type === View) {
90
- isSnapshot = true;
91
- }
92
- });
93
-
94
- return isSnapshot;
95
- }
96
-
97
- render() {
98
- const props = {
99
- ...this.baseProps,
100
- snapshot: this._shouldSnapshot(),
101
- sourceLayerID: this.props.sourceLayerID,
102
- };
103
-
104
- return (
105
- <RCTMGLSymbolLayer ref="nativeLayer" {...props}>
106
- {this.props.children}
107
- </RCTMGLSymbolLayer>
108
- );
109
- }
110
- }
111
-
112
- const RCTMGLSymbolLayer = requireNativeComponent(
113
- NATIVE_MODULE_NAME,
114
- SymbolLayer,
115
- {
116
- nativeOnly: {reactStyle: true, snapshot: true},
117
- },
118
- );
119
-
120
- export default SymbolLayer;