@orioro/react-maplibre-util 0.5.0 → 0.5.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.
package/CHANGELOG.md
CHANGED
@@ -17,5 +17,5 @@ type TerrainControlProps = Omit<ControlContainerProps, 'children'> & {
|
|
17
17
|
demSource?: SourceSpecInput;
|
18
18
|
contourTileOptions?: Partial<GlobalContourTileOptions>;
|
19
19
|
};
|
20
|
-
export declare function TerrainControl({ value: externalValue, onSetValue: onSetExternalValue, demSourceId: DEM_SOURCE_ID, demSource: DEM_SOURCE_SPEC, contourTileOptions: contourTileOptionsInput, }: TerrainControlProps): React.JSX.Element;
|
20
|
+
export declare function TerrainControl({ value: externalValue, onSetValue: onSetExternalValue, demSourceId: DEM_SOURCE_ID, demSource: DEM_SOURCE_SPEC, contourTileOptions: contourTileOptionsInput, ...controlContainerProps }: TerrainControlProps): React.JSX.Element;
|
21
21
|
export {};
|
@@ -24,9 +24,17 @@ export declare function svgToMaplibreImage(svgString: string, pixelRatio?: numbe
|
|
24
24
|
Partial<StyleImageMetadata>
|
25
25
|
]>;
|
26
26
|
export declare function svgIconId(iconId: string, options?: IconPathToSvgOptions): string;
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
type SvgIconGeneratorReturn<T extends Record<string, string>> = {
|
28
|
+
(imageId: string): Promise<[
|
29
|
+
{
|
30
|
+
width: number;
|
31
|
+
height: number;
|
32
|
+
data: Uint8ClampedArray;
|
33
|
+
},
|
34
|
+
Partial<StyleImageMetadata>
|
35
|
+
] | null>;
|
36
|
+
} & {
|
37
|
+
[K in keyof T]: (options?: IconPathToSvgOptions) => string;
|
38
|
+
};
|
39
|
+
export declare function svgIconGenerator<T extends Record<string, string>>(iconPathsById: T): SvgIconGeneratorReturn<T>;
|
32
40
|
export {};
|
package/dist/index.mjs
CHANGED
@@ -920,7 +920,7 @@ function DynamicImages(_a) {
|
|
920
920
|
if (!map.hasImage(imageId)) {
|
921
921
|
if (Array.isArray(result)) {
|
922
922
|
map.addImage(imageId, result[0], result[1]);
|
923
|
-
} else {
|
923
|
+
} else if (result) {
|
924
924
|
map.addImage(imageId, result);
|
925
925
|
}
|
926
926
|
}
|
@@ -1027,15 +1027,28 @@ function svgIconGenerator(iconPathsById) {
|
|
1027
1027
|
var expr = strExpr({
|
1028
1028
|
expressions: fns
|
1029
1029
|
});
|
1030
|
-
|
1030
|
+
function onGenerateSvgImage(imageId) {
|
1031
1031
|
return __awaiter(this, void 0, void 0, function () {
|
1032
|
-
var svg;
|
1032
|
+
var imageExpr, svg;
|
1033
1033
|
return __generator(this, function (_a) {
|
1034
|
-
|
1035
|
-
|
1034
|
+
try {
|
1035
|
+
imageExpr = expr.parse(imageId);
|
1036
|
+
svg = expr.apply(imageExpr, undefined);
|
1037
|
+
return [2 /*return*/, svgToMaplibreImage(svg)];
|
1038
|
+
} catch (err) {
|
1039
|
+
// console.log(`will skip: ${imageId}`)
|
1040
|
+
return [2 /*return*/, null];
|
1041
|
+
}
|
1042
|
+
return [2 /*return*/];
|
1036
1043
|
});
|
1037
1044
|
});
|
1038
|
-
}
|
1045
|
+
}
|
1046
|
+
Object.assign(onGenerateSvgImage, Object.fromEntries(Object.keys(iconPathsById).map(function (iconId) {
|
1047
|
+
return [iconId, function (options) {
|
1048
|
+
return svgIconId(iconId, options);
|
1049
|
+
}];
|
1050
|
+
})));
|
1051
|
+
return onGenerateSvgImage;
|
1039
1052
|
}
|
1040
1053
|
|
1041
1054
|
var DEFAULT_MIN_K = 3;
|
@@ -1293,7 +1306,8 @@ function TerrainControl(_a) {
|
|
1293
1306
|
_f = _a.demSource,
|
1294
1307
|
DEM_SOURCE_SPEC = _f === void 0 ? DEFAULT_DEM_SOURCE_SPEC : _f,
|
1295
1308
|
_g = _a.contourTileOptions,
|
1296
|
-
contourTileOptionsInput = _g === void 0 ? DEFAULT_CONTOUR_TILE_OPTIONS : _g
|
1309
|
+
contourTileOptionsInput = _g === void 0 ? DEFAULT_CONTOUR_TILE_OPTIONS : _g,
|
1310
|
+
controlContainerProps = __rest(_a, ["value", "onSetValue", "demSourceId", "demSource", "contourTileOptions"]);
|
1297
1311
|
var _contourTileOptions = useMemo(function () {
|
1298
1312
|
return __assign(__assign({}, contourTileOptionsInput), DEFAULT_CONTOUR_TILE_OPTIONS);
|
1299
1313
|
}, [contourTileOptionsInput]);
|
@@ -1485,7 +1499,7 @@ function TerrainControl(_a) {
|
|
1485
1499
|
return map.off('style.load', handleStyleLoad);
|
1486
1500
|
};
|
1487
1501
|
}, [(_c = mapRef.current) === null || _c === void 0 ? void 0 : _c.getMap(), settings && settings.enable3d]);
|
1488
|
-
return /*#__PURE__*/React.createElement(ControlContainer,
|
1502
|
+
return /*#__PURE__*/React.createElement(ControlContainer, __assign({}, controlContainerProps), /*#__PURE__*/React.createElement(DropdownMenu, {
|
1489
1503
|
size: "1",
|
1490
1504
|
options: [{
|
1491
1505
|
label: (/*#__PURE__*/React.createElement(React.Fragment, null, "Relevo", settings && (settings.hillshade || settings.enable3d) && (/*#__PURE__*/React.createElement(Icon, {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orioro/react-maplibre-util",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.2",
|
4
4
|
"packageManager": "yarn@4.0.2",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.mjs",
|
@@ -17,6 +17,7 @@
|
|
17
17
|
},
|
18
18
|
"license": "ISC",
|
19
19
|
"scripts": {
|
20
|
+
"prepublish": "yarn build",
|
20
21
|
"build": "rm -rf dist && rollup --config ./rollup.config.mjs",
|
21
22
|
"dev": "storybook dev -p 6006",
|
22
23
|
"build-storybook": "storybook build"
|