@maplibre/maplibre-react-native 10.2.1 → 10.4.0
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/src/main/java/org/maplibre/reactnative/components/images/MLRNImagesManager.java +3 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/DownloadMapImageTask.java +8 -10
- package/android/src/main/java/org/maplibre/reactnative/utils/DownloadedImage.java +6 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/ImageEntry.java +1 -0
- package/ios/MLRN/MLRNImageQueue.h +1 -0
- package/ios/MLRN/MLRNImageQueue.m +2 -0
- package/ios/MLRN/MLRNImageQueueOperation.h +1 -0
- package/ios/MLRN/MLRNImageQueueOperation.m +17 -15
- package/ios/MLRN/MLRNMapViewManager.m +4 -4
- package/ios/MLRN/MLRNStyle.m +5 -5
- package/ios/MLRN/MLRNStyleValue.h +1 -0
- package/ios/MLRN/MLRNStyleValue.m +13 -0
- package/ios/MLRN/MLRNUtils.h +1 -0
- package/ios/MLRN/MLRNUtils.m +10 -1
- package/lib/commonjs/components/Images.js +32 -46
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/module/components/Images.js +32 -46
- package/lib/module/components/Images.js.map +1 -1
- package/lib/typescript/commonjs/src/components/BackgroundLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Callout.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/CircleLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/FillExtrusionLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/FillLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/HeatmapLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/ImageSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Images.d.ts +11 -2
- package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Light.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/LineLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/MarkerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/NativeUserLocation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/RasterLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/RasterSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/plugin/android.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/plugin/ios.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts +6 -6
- package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/BackgroundLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Callout.d.ts.map +1 -1
- package/lib/typescript/module/src/components/CircleLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/FillExtrusionLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/FillLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/HeatmapLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/ImageSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Images.d.ts +11 -2
- package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Light.d.ts.map +1 -1
- package/lib/typescript/module/src/components/LineLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MarkerView.d.ts.map +1 -1
- package/lib/typescript/module/src/components/NativeUserLocation.d.ts.map +1 -1
- package/lib/typescript/module/src/components/RasterLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/RasterSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/plugin/android.d.ts.map +1 -1
- package/lib/typescript/module/src/plugin/ios.d.ts.map +1 -1
- package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts +6 -6
- package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Images.tsx +62 -67
- package/src/types/MapLibreRNStyles.ts +6 -6
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ReactNode, useMemo } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Image,
|
|
4
|
+
type ImageResolvedAssetSource,
|
|
4
5
|
type ImageSourcePropType,
|
|
5
|
-
type ImageURISource,
|
|
6
6
|
type NativeSyntheticEvent,
|
|
7
7
|
requireNativeComponent,
|
|
8
8
|
} from "react-native";
|
|
9
|
+
import type {
|
|
10
|
+
ImageRequireSource,
|
|
11
|
+
ImageURISource,
|
|
12
|
+
} from "react-native/Libraries/Image/ImageSource";
|
|
9
13
|
|
|
10
14
|
import { type BaseProps } from "../types/BaseProps";
|
|
11
15
|
|
|
12
16
|
export const NATIVE_MODULE_NAME = "MLRNImages";
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
|
19
|
+
type XOR<T, U> = T | U extends object
|
|
20
|
+
? (Without<T, U> & U) | (Without<U, T> & T)
|
|
21
|
+
: T | U;
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
value.startsWith("http://") ||
|
|
21
|
-
value.startsWith("https://") ||
|
|
22
|
-
value.startsWith("data:") ||
|
|
23
|
-
value.startsWith("asset://") ||
|
|
24
|
-
value.startsWith("/"))
|
|
25
|
-
);
|
|
26
|
-
}
|
|
23
|
+
export type ImageSourceWithSdf = {
|
|
24
|
+
source: ImageSourcePropType;
|
|
25
|
+
sdf?: boolean;
|
|
26
|
+
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
const valueAsSource = value as ImageURISource;
|
|
35
|
-
return !!valueAsSource.uri && typeof valueAsSource.uri === "string";
|
|
36
|
-
}
|
|
28
|
+
export type ImageEntry =
|
|
29
|
+
| string
|
|
30
|
+
| ImageRequireSource
|
|
31
|
+
| ImageURISource[]
|
|
32
|
+
| XOR<ImageURISource, ImageSourceWithSdf>;
|
|
37
33
|
|
|
38
34
|
interface ImagesProps extends BaseProps {
|
|
39
35
|
/**
|
|
@@ -59,7 +55,7 @@ interface ImagesProps extends BaseProps {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
/**
|
|
62
|
-
* Images defines the images used in Symbol
|
|
58
|
+
* Images defines the images used in Symbol layers
|
|
63
59
|
*/
|
|
64
60
|
export const Images = ({
|
|
65
61
|
images,
|
|
@@ -68,56 +64,55 @@ export const Images = ({
|
|
|
68
64
|
id,
|
|
69
65
|
children,
|
|
70
66
|
}: ImagesProps) => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const imagesResult: { [key: string]: ImageEntry } = {};
|
|
80
|
-
let nativeImages: ImageEntry[] = [];
|
|
67
|
+
const props = useMemo(() => {
|
|
68
|
+
const getImages = (): {
|
|
69
|
+
images?: { [key: string]: ImageEntry };
|
|
70
|
+
nativeImages?: ImageEntry[];
|
|
71
|
+
} => {
|
|
72
|
+
if (!images && !nativeAssetImages) {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
76
|
+
const imagesResult: {
|
|
77
|
+
[key: string]: string | (ImageResolvedAssetSource & { sdf?: boolean });
|
|
78
|
+
} = {};
|
|
79
|
+
|
|
80
|
+
if (images) {
|
|
81
|
+
Object.entries(images).forEach(([imageName, value]) => {
|
|
82
|
+
if (typeof value === "string") {
|
|
83
|
+
imagesResult[imageName] = value;
|
|
84
|
+
} else if (
|
|
85
|
+
typeof value === "object" &&
|
|
86
|
+
"source" in value &&
|
|
87
|
+
value.source
|
|
88
|
+
) {
|
|
89
|
+
imagesResult[imageName] = {
|
|
90
|
+
...Image.resolveAssetSource(value.source),
|
|
91
|
+
sdf: value.sdf,
|
|
92
|
+
};
|
|
93
|
+
} else {
|
|
94
|
+
imagesResult[imageName] = Image.resolveAssetSource(value);
|
|
92
95
|
}
|
|
93
|
-
}
|
|
96
|
+
});
|
|
94
97
|
}
|
|
95
|
-
}
|
|
96
98
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
99
|
+
return imagesResult;
|
|
100
|
+
};
|
|
100
101
|
|
|
101
102
|
return {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
id,
|
|
104
|
+
hasOnImageMissing: !!onImageMissing,
|
|
105
|
+
onImageMissing: (
|
|
106
|
+
event: NativeSyntheticEvent<{ payload: { imageKey: string } }>,
|
|
107
|
+
): void => {
|
|
108
|
+
if (onImageMissing) {
|
|
109
|
+
onImageMissing(event.nativeEvent.payload.imageKey);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
images: getImages(),
|
|
113
|
+
nativeImages: nativeAssetImages ?? [],
|
|
104
114
|
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const _onImageMissing = (
|
|
108
|
-
event: NativeSyntheticEvent<{ payload: { imageKey: string } }>,
|
|
109
|
-
): void => {
|
|
110
|
-
if (onImageMissing) {
|
|
111
|
-
onImageMissing(event.nativeEvent.payload.imageKey);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const props = {
|
|
116
|
-
id,
|
|
117
|
-
hasOnImageMissing: !!onImageMissing,
|
|
118
|
-
onImageMissing: _onImageMissing,
|
|
119
|
-
..._getImages(),
|
|
120
|
-
};
|
|
115
|
+
}, [id, onImageMissing, images, nativeAssetImages]);
|
|
121
116
|
|
|
122
117
|
return <MLRNImages {...props}>{children}</MLRNImages>;
|
|
123
118
|
};
|
|
@@ -301,11 +301,11 @@ export interface LineLayerStyle {
|
|
|
301
301
|
*/
|
|
302
302
|
lineBlurTransition?: Transition;
|
|
303
303
|
/**
|
|
304
|
-
* Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width.
|
|
304
|
+
* Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. ZoomDependent expressions will be evaluated only at integer zoom levels. The only way to create an array value is using `["literal", [...]]`; arrays cannot be read from or derived from feature properties.
|
|
305
305
|
*
|
|
306
306
|
* @disabledBy linePattern
|
|
307
307
|
*/
|
|
308
|
-
lineDasharray?: Value<number[], ["zoom"]>;
|
|
308
|
+
lineDasharray?: Value<number[], ["zoom", "feature"]>;
|
|
309
309
|
|
|
310
310
|
/**
|
|
311
311
|
* The transition affecting any changes to this layer’s lineDasharray property.
|
|
@@ -463,7 +463,7 @@ export interface SymbolLayerStyle {
|
|
|
463
463
|
*/
|
|
464
464
|
textField?: Value<FormattedString, ["zoom", "feature"]>;
|
|
465
465
|
/**
|
|
466
|
-
*
|
|
466
|
+
* Fonts to use for displaying text. If the `glyphs` root property is specified, this array is joined together and interpreted as a font stack name. Otherwise, it is interpreted as a cascading fallback list of local font names.
|
|
467
467
|
*
|
|
468
468
|
* @requires textField
|
|
469
469
|
*/
|
|
@@ -1048,7 +1048,7 @@ export interface HillshadeLayerStyle {
|
|
|
1048
1048
|
*/
|
|
1049
1049
|
visibility?: "visible" | "none";
|
|
1050
1050
|
/**
|
|
1051
|
-
* The direction of the light source used to generate the hillshading with 0 as the top of the viewport if `hillshadeIlluminationAnchor` is set to `viewport` and due north if `hillshadeIlluminationAnchor` is set to `map`.
|
|
1051
|
+
* The direction of the light source(s) used to generate the hillshading with 0 as the top of the viewport if `hillshadeIlluminationAnchor` is set to `viewport` and due north if `hillshadeIlluminationAnchor` is set to `map`. Only when `hillshadeMethod` is set to `multidirectional` can you specify multiple light sources.
|
|
1052
1052
|
*/
|
|
1053
1053
|
hillshadeIlluminationDirection?: Value<number, ["zoom"]>;
|
|
1054
1054
|
/**
|
|
@@ -1065,7 +1065,7 @@ export interface HillshadeLayerStyle {
|
|
|
1065
1065
|
*/
|
|
1066
1066
|
hillshadeExaggerationTransition?: Transition;
|
|
1067
1067
|
/**
|
|
1068
|
-
* The shading color of areas that face away from the light source.
|
|
1068
|
+
* The shading color of areas that face away from the light source(s). Only when `hillshadeMethod` is set to `multidirectional` can you specify multiple light sources.
|
|
1069
1069
|
*/
|
|
1070
1070
|
hillshadeShadowColor?: Value<string, ["zoom"]>;
|
|
1071
1071
|
|
|
@@ -1074,7 +1074,7 @@ export interface HillshadeLayerStyle {
|
|
|
1074
1074
|
*/
|
|
1075
1075
|
hillshadeShadowColorTransition?: Transition;
|
|
1076
1076
|
/**
|
|
1077
|
-
* The shading color of areas that faces towards the light source.
|
|
1077
|
+
* The shading color of areas that faces towards the light source(s). Only when `hillshadeMethod` is set to `multidirectional` can you specify multiple light sources.
|
|
1078
1078
|
*/
|
|
1079
1079
|
hillshadeHighlightColor?: Value<string, ["zoom"]>;
|
|
1080
1080
|
|