@maplibre/maplibre-react-native 9.0.1 → 10.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +10 -2
- package/.husky/pre-commit +5 -0
- package/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
- package/.yarn/sdks/eslint/bin/eslint.js +20 -0
- package/.yarn/sdks/eslint/lib/api.js +20 -0
- package/.yarn/sdks/eslint/package.json +6 -0
- package/.yarn/sdks/integrations.yml +5 -0
- package/.yarn/sdks/prettier/index.js +20 -0
- package/.yarn/sdks/prettier/package.json +6 -0
- package/.yarn/sdks/typescript/bin/tsc +20 -0
- package/.yarn/sdks/typescript/bin/tsserver +20 -0
- package/.yarn/sdks/typescript/lib/tsc.js +20 -0
- package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
- package/.yarn/sdks/typescript/lib/typescript.js +20 -0
- package/.yarn/sdks/typescript/package.json +6 -0
- package/CHANGELOG.md +15 -1
- package/android/build.gradle +2 -2
- package/android/rctmgl/build.gradle +2 -4
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.java +14 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.java +26 -0
- package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ClusterPropertyEntry.java +13 -0
- package/docs/Annotation.md +8 -9
- package/docs/BackgroundLayer.md +2 -10
- package/docs/Callout.md +5 -5
- package/docs/Camera.md +18 -47
- package/docs/CircleLayer.md +2 -10
- package/docs/FillExtrusionLayer.md +2 -10
- package/docs/FillLayer.md +2 -10
- package/docs/HeatmapLayer.md +2 -10
- package/docs/ImageSource.md +3 -2
- package/docs/Images.md +5 -3
- package/docs/Light.md +1 -1
- package/docs/LineLayer.md +2 -10
- package/docs/MapView.md +53 -37
- package/docs/MarkerView.md +4 -2
- package/docs/NativeUserLocation.md +2 -2
- package/docs/PointAnnotation.md +5 -8
- package/docs/RasterLayer.md +2 -10
- package/docs/RasterSource.md +3 -2
- package/docs/ShapeSource.md +12 -6
- package/docs/Style.md +1 -1
- package/docs/SymbolLayer.md +3 -10
- package/docs/UserLocation.md +8 -10
- package/docs/VectorSource.md +6 -5
- package/docs/coordinates.md +6 -0
- package/docs/docs.json +561 -1308
- package/docs/location.md +6 -0
- package/docs/snapshotManager.md +3 -3
- package/ios/RCTMGL/RCTMGLShapeSource.h +1 -0
- package/ios/RCTMGL/RCTMGLShapeSource.m +14 -0
- package/ios/RCTMGL/RCTMGLShapeSourceManager.m +1 -0
- package/ios/RCTMGL.xcodeproj/project.pbxproj +1 -0
- package/javascript/@types/assets.d.ts +4 -0
- package/javascript/MGLModule.ts +37 -0
- package/javascript/Maplibre.ts +65 -0
- package/javascript/components/AbstractLayer.tsx +107 -0
- package/javascript/components/AbstractSource.tsx +27 -0
- package/javascript/components/BackgroundLayer.tsx +43 -0
- package/javascript/components/{Callout.js → Callout.tsx} +67 -65
- package/javascript/components/{Camera.js → Camera.tsx} +266 -251
- package/javascript/components/CircleLayer.tsx +46 -0
- package/javascript/components/FillExtrusionLayer.tsx +47 -0
- package/javascript/components/FillLayer.tsx +41 -0
- package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
- package/javascript/components/HeatmapLayer.tsx +44 -0
- package/javascript/components/ImageSource.tsx +78 -0
- package/javascript/components/Images.tsx +134 -0
- package/javascript/components/Light.tsx +67 -0
- package/javascript/components/LineLayer.tsx +42 -0
- package/javascript/components/{MapView.js → MapView.tsx} +365 -354
- package/javascript/components/MarkerView.tsx +104 -0
- package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
- package/javascript/components/NativeUserLocation.tsx +33 -0
- package/javascript/components/PointAnnotation.tsx +221 -0
- package/javascript/components/RasterLayer.tsx +41 -0
- package/javascript/components/RasterSource.tsx +117 -0
- package/javascript/components/ShapeSource.tsx +383 -0
- package/javascript/components/{Style.js → Style.tsx} +132 -38
- package/javascript/components/SymbolLayer.tsx +72 -0
- package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
- package/javascript/components/VectorSource.tsx +207 -0
- package/javascript/components/annotations/Annotation.tsx +134 -0
- package/javascript/index.ts +4 -0
- package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
- package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
- package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
- package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
- package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
- package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
- package/javascript/requestAndroidLocationPermissions.ts +29 -0
- package/javascript/types/BaseProps.ts +5 -0
- package/javascript/types/OnPressEvent.ts +13 -0
- package/javascript/types/index.ts +7 -0
- package/javascript/utils/BridgeValue.ts +90 -0
- package/javascript/utils/{Logger.js → Logger.ts} +37 -18
- package/javascript/utils/MaplibreStyles.d.ts +1486 -0
- package/javascript/utils/StyleValue.ts +49 -0
- package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
- package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
- package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
- package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
- package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
- package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
- package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
- package/javascript/utils/filterUtils.ts +9 -0
- package/javascript/utils/geoUtils.ts +79 -0
- package/javascript/utils/{index.js → index.ts} +44 -24
- package/javascript/utils/styleMap.ts +264 -0
- package/package.json +43 -34
- package/plugin/build/withMapLibre.js +3 -2
- package/scripts/autogenHelpers/globals.js +1 -1
- package/scripts/autogenerate.js +14 -6
- package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
- package/scripts/templates/index.d.ts.ejs +71 -42
- package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
- package/setup-jest.js +3 -10
- package/tsconfig.json +20 -61
- package/index.d.ts +0 -954
- package/javascript/components/AbstractLayer.js +0 -75
- package/javascript/components/AbstractSource.js +0 -15
- package/javascript/components/BackgroundLayer.js +0 -97
- package/javascript/components/CircleLayer.js +0 -101
- package/javascript/components/FillExtrusionLayer.js +0 -98
- package/javascript/components/FillLayer.js +0 -94
- package/javascript/components/HeatmapLayer.js +0 -99
- package/javascript/components/ImageSource.js +0 -82
- package/javascript/components/Images.js +0 -119
- package/javascript/components/Light.js +0 -47
- package/javascript/components/LineLayer.js +0 -94
- package/javascript/components/MarkerView.js +0 -87
- package/javascript/components/NativeUserLocation.js +0 -41
- package/javascript/components/PointAnnotation.js +0 -216
- package/javascript/components/RasterLayer.js +0 -95
- package/javascript/components/RasterSource.js +0 -124
- package/javascript/components/ShapeSource.js +0 -357
- package/javascript/components/SymbolLayer.js +0 -120
- package/javascript/components/VectorSource.js +0 -200
- package/javascript/components/annotations/Annotation.js +0 -122
- package/javascript/index.js +0 -149
- package/javascript/utils/BridgeValue.js +0 -81
- package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
- package/javascript/utils/filterUtils.js +0 -7
- package/javascript/utils/geoUtils.js +0 -73
- package/javascript/utils/styleMap.js +0 -1932
- /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {Animated} from 'react-native';
|
|
2
|
-
|
|
3
|
-
// see
|
|
4
|
-
// https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js
|
|
5
|
-
const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
|
|
6
|
-
if (__DEV__) {
|
|
7
|
-
if (AnimatedWithChildren.name !== 'AnimatedWithChildren') {
|
|
8
|
-
console.error(
|
|
9
|
-
'AnimatedCoordinatesArray could not obtain AnimatedWithChildren base class',
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const defaultConfig = {
|
|
15
|
-
useNativeDriver: false,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
class AnimatedCoordinatesArray extends AnimatedWithChildren {
|
|
19
|
-
constructor(...args) {
|
|
20
|
-
super();
|
|
21
|
-
|
|
22
|
-
this.state = this.onInitialState(...args);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Subclasses can override to calculate initial state
|
|
27
|
-
*
|
|
28
|
-
* @param {*} args - to value from animate
|
|
29
|
-
* @returns {object} - the state object
|
|
30
|
-
*/
|
|
31
|
-
onInitialState(coordinatesArray) {
|
|
32
|
-
return {coords: coordinatesArray.map(coord => [coord[0], coord[1]])};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Subclasses can override getValue to calculate value from state.
|
|
37
|
-
* Value is typically coordinates array, but can be anything
|
|
38
|
-
*
|
|
39
|
-
* @param {object} state - either state from initialState and/or from calculate
|
|
40
|
-
* @returns {object}
|
|
41
|
-
*/
|
|
42
|
-
onGetValue(state) {
|
|
43
|
-
return state.coords;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Calculates state based on startingState and progress, returns a new state
|
|
48
|
-
*
|
|
49
|
-
* @param {object} state - state object from initialState and/or from calculate
|
|
50
|
-
* @param {number} progress - value between 0 and 1
|
|
51
|
-
* @returns {object} next state
|
|
52
|
-
*/
|
|
53
|
-
onCalculate(state, progress) {
|
|
54
|
-
const {coords, targetCoords} = state;
|
|
55
|
-
const newF = progress;
|
|
56
|
-
const origF = 1.0 - newF;
|
|
57
|
-
|
|
58
|
-
// common
|
|
59
|
-
const commonLen = Math.min(coords.length, targetCoords.length);
|
|
60
|
-
const common = coords
|
|
61
|
-
.slice(0, commonLen)
|
|
62
|
-
.map((origCoord, i) => [
|
|
63
|
-
origCoord[0] * origF + targetCoords[i][0] * newF,
|
|
64
|
-
origCoord[1] * origF + targetCoords[i][1] * newF,
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
if (targetCoords.length > coords.length) {
|
|
68
|
-
// only in new (adding)
|
|
69
|
-
const addingOrig =
|
|
70
|
-
coords.length > 0 ? coords[coords.length - 1] : targetCoords[0];
|
|
71
|
-
const adding = targetCoords
|
|
72
|
-
.slice(commonLen, targetCoords.length)
|
|
73
|
-
.map(newCoord => [
|
|
74
|
-
addingOrig[0] * origF + newCoord[0] * newF,
|
|
75
|
-
addingOrig[1] * origF + newCoord[1] * newF,
|
|
76
|
-
]);
|
|
77
|
-
return {coords: [...common, ...adding], targetCoords};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (coords.length > targetCoords.length) {
|
|
81
|
-
// only in orig (dissapearing)
|
|
82
|
-
const dissapearingNew =
|
|
83
|
-
targetCoords.length > 0
|
|
84
|
-
? targetCoords[targetCoords.length - 1]
|
|
85
|
-
: coords[0];
|
|
86
|
-
const dissapearing = coords
|
|
87
|
-
.slice(commonLen, coords.length)
|
|
88
|
-
.map(origCoord => [
|
|
89
|
-
origCoord[0] * origF + dissapearingNew[0] * newF,
|
|
90
|
-
origCoord[1] * origF + dissapearingNew[1] * newF,
|
|
91
|
-
]);
|
|
92
|
-
return {coords: [...common, ...dissapearing], targetCoords};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {coords: common, targetCoords};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Subclasses can override to start a new animation
|
|
100
|
-
*
|
|
101
|
-
* @param {*} toValue - to value from animate
|
|
102
|
-
* @param {*} actCoords - the current coordinates array to start from
|
|
103
|
-
* @returns {object} The state
|
|
104
|
-
*/
|
|
105
|
-
onStart(state, toValue) {
|
|
106
|
-
const targetCoords = toValue.map(coord => [coord[0], coord[1]]);
|
|
107
|
-
return {
|
|
108
|
-
...state,
|
|
109
|
-
targetCoords,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
animate(progressValue, progressAnimation, config) {
|
|
114
|
-
const {toValue} = config;
|
|
115
|
-
|
|
116
|
-
const onAnimationStart = animation => {
|
|
117
|
-
if (this.animation) {
|
|
118
|
-
// there was a started but not finsihed animation
|
|
119
|
-
const actProgress = this.progressValue.__getValue();
|
|
120
|
-
this.animation.stop();
|
|
121
|
-
this.state = this.onCalculate(this.state, actProgress);
|
|
122
|
-
this.progressValue.__removeChild(this);
|
|
123
|
-
this.progressValue = null;
|
|
124
|
-
this.animation = null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.progressValue = progressValue;
|
|
128
|
-
this.progressValue.__addChild(this);
|
|
129
|
-
this.animation = animation;
|
|
130
|
-
this.state = this.onStart(this.state, toValue);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const origAnimationStart = progressAnimation.start;
|
|
134
|
-
const newAnimation = progressAnimation;
|
|
135
|
-
newAnimation.start = function start(...args) {
|
|
136
|
-
onAnimationStart(progressAnimation);
|
|
137
|
-
origAnimationStart(...args);
|
|
138
|
-
};
|
|
139
|
-
return newAnimation;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
timing(config) {
|
|
143
|
-
const progressValue = new Animated.Value(0.0);
|
|
144
|
-
return this.animate(
|
|
145
|
-
progressValue,
|
|
146
|
-
Animated.timing(progressValue, {
|
|
147
|
-
...defaultConfig,
|
|
148
|
-
...config,
|
|
149
|
-
toValue: 1.0,
|
|
150
|
-
}),
|
|
151
|
-
config,
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
spring(config) {
|
|
156
|
-
const progressValue = new Animated.Value(0.0);
|
|
157
|
-
return this.animate(
|
|
158
|
-
progressValue,
|
|
159
|
-
Animated.spring(progressValue, {
|
|
160
|
-
...defaultConfig,
|
|
161
|
-
...config,
|
|
162
|
-
toValue: 1.0,
|
|
163
|
-
}),
|
|
164
|
-
config,
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
decay(config) {
|
|
169
|
-
const progressValue = new Animated.Value(0.0);
|
|
170
|
-
return this.animate(
|
|
171
|
-
progressValue,
|
|
172
|
-
Animated.decay(this.progressValue, {
|
|
173
|
-
...defaultConfig,
|
|
174
|
-
...config,
|
|
175
|
-
toValue: 1.0,
|
|
176
|
-
}),
|
|
177
|
-
config,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
__getValue() {
|
|
182
|
-
if (!this.progressValue) {
|
|
183
|
-
return this.onGetValue(this.state);
|
|
184
|
-
}
|
|
185
|
-
return this.onGetValue(
|
|
186
|
-
this.onCalculate(this.state, this.progressValue.__getValue()),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export default AnimatedCoordinatesArray;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {featureCollection, point, feature, lineString} from '@turf/helpers';
|
|
2
|
-
import distance from '@turf/distance';
|
|
3
|
-
import along from '@turf/along';
|
|
4
|
-
import geoViewport from '@mapbox/geo-viewport';
|
|
5
|
-
|
|
6
|
-
const VECTOR_TILE_SIZE = 512;
|
|
7
|
-
|
|
8
|
-
export function makePoint(coordinates, properties, options) {
|
|
9
|
-
return point(coordinates, properties, options);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function makeLineString(coordinates, properties, options) {
|
|
13
|
-
return lineString(coordinates, properties, options);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function makeLatLngBounds(northEastCoordinates, southWestCoordinates) {
|
|
17
|
-
return featureCollection([
|
|
18
|
-
point(northEastCoordinates),
|
|
19
|
-
point(southWestCoordinates),
|
|
20
|
-
]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function makeFeature(geometry, properties) {
|
|
24
|
-
return feature(geometry, properties);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function makeFeatureCollection(features = [], options) {
|
|
28
|
-
return featureCollection(features, options);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function addToFeatureCollection(newFeatureCollection, newFeature) {
|
|
32
|
-
return {
|
|
33
|
-
...newFeatureCollection,
|
|
34
|
-
features: [...newFeatureCollection.features, newFeature],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function calculateDistance(origin, dest, options) {
|
|
39
|
-
return distance(origin, dest, options);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function pointAlongLine(newLineString, distAlong, options) {
|
|
43
|
-
return along(newLineString, distAlong, options);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function getOrCalculateVisibleRegion(
|
|
47
|
-
coord,
|
|
48
|
-
zoomLevel,
|
|
49
|
-
width,
|
|
50
|
-
height,
|
|
51
|
-
nativeRegion,
|
|
52
|
-
) {
|
|
53
|
-
const region = {
|
|
54
|
-
ne: [0, 0],
|
|
55
|
-
sw: [0, 0],
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
if (!nativeRegion || !Array.isArray(nativeRegion.visibleBounds)) {
|
|
59
|
-
const bounds = geoViewport.bounds(
|
|
60
|
-
coord,
|
|
61
|
-
zoomLevel,
|
|
62
|
-
[width, height],
|
|
63
|
-
VECTOR_TILE_SIZE,
|
|
64
|
-
);
|
|
65
|
-
region.ne = [bounds[3], bounds[2]];
|
|
66
|
-
region.sw = [bounds[1], bounds[0]];
|
|
67
|
-
} else {
|
|
68
|
-
region.ne = nativeRegion.properties.visibleBounds[0];
|
|
69
|
-
region.sw = nativeRegion.properties.visibleBounds[1];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return region;
|
|
73
|
-
}
|