@antv/gpt-vis 0.3.2 → 0.3.3
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/dist/cjs/Map/Component/MapView.d.ts +3 -0
- package/dist/cjs/Map/Component/MapView.js +40 -0
- package/dist/cjs/Map/Component/Marker.d.ts +3 -0
- package/dist/cjs/Map/Component/Marker.js +53 -0
- package/dist/cjs/Map/Component/Polyline.d.ts +3 -0
- package/dist/cjs/Map/Component/Polyline.js +50 -0
- package/dist/cjs/Map/Component/index.d.ts +4 -0
- package/dist/cjs/Map/Component/index.js +45 -0
- package/dist/cjs/Map/index.js +8 -15
- package/dist/cjs/utils/map/context.js +3 -0
- package/dist/cjs/utils/map/view.d.ts +2 -0
- package/dist/cjs/utils/map/view.js +10 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Map/Component/MapView.d.ts +3 -0
- package/dist/esm/Map/Component/MapView.js +18 -0
- package/dist/esm/Map/Component/Marker.d.ts +3 -0
- package/dist/esm/Map/Component/Marker.js +35 -0
- package/dist/esm/Map/Component/Polyline.d.ts +3 -0
- package/dist/esm/Map/Component/Polyline.js +30 -0
- package/dist/esm/Map/Component/index.d.ts +4 -0
- package/dist/esm/Map/Component/index.js +4 -0
- package/dist/esm/Map/index.js +12 -29
- package/dist/esm/utils/map/context.js +9 -3
- package/dist/esm/utils/map/view.d.ts +2 -0
- package/dist/esm/utils/map/view.js +6 -5
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Map/Component/MapView.tsx
|
|
20
|
+
var MapView_exports = {};
|
|
21
|
+
__export(MapView_exports, {
|
|
22
|
+
default: () => MapView_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(MapView_exports);
|
|
25
|
+
var import_larkmap = require("@antv/larkmap");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_map = require("../../utils/map");
|
|
28
|
+
var MapView_default = (props) => {
|
|
29
|
+
const scene = (0, import_larkmap.useScene)();
|
|
30
|
+
(0, import_react.useEffect)(() => {
|
|
31
|
+
(0, import_map.setMapView)(props, scene);
|
|
32
|
+
}, []);
|
|
33
|
+
(0, import_react.useEffect)(() => {
|
|
34
|
+
(0, import_map.setMapStatus)(props, scene);
|
|
35
|
+
}, [props.enableRotate, props.enableScroll, props.enableZoom]);
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
(0, import_map.fitBounds)(props, scene);
|
|
38
|
+
}, [props.includePoints, props.markers, props.polyline, props.includePadding]);
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Map/Component/Marker.tsx
|
|
20
|
+
var Marker_exports = {};
|
|
21
|
+
__export(Marker_exports, {
|
|
22
|
+
default: () => Marker_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Marker_exports);
|
|
25
|
+
var import_larkmap = require("@antv/larkmap");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_map = require("../../utils/map");
|
|
28
|
+
var Marker_default = (props) => {
|
|
29
|
+
const scene = (0, import_larkmap.useScene)();
|
|
30
|
+
const [layers, setLayers] = (0, import_react.useState)([]);
|
|
31
|
+
const removeLayers = () => {
|
|
32
|
+
layers.forEach((item) => {
|
|
33
|
+
scene.removeLayer(item);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!props.markers)
|
|
39
|
+
return;
|
|
40
|
+
(_a = (0, import_map.setMapContext)(props, scene)) == null ? void 0 : _a.then(() => {
|
|
41
|
+
const markerLayer = (0, import_map.setMarkers)(props.markers || []);
|
|
42
|
+
removeLayers();
|
|
43
|
+
markerLayer.forEach((item) => {
|
|
44
|
+
scene.addLayer(item);
|
|
45
|
+
});
|
|
46
|
+
setLayers(markerLayer);
|
|
47
|
+
});
|
|
48
|
+
return () => {
|
|
49
|
+
removeLayers();
|
|
50
|
+
};
|
|
51
|
+
}, [props.markers]);
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Map/Component/Polyline.tsx
|
|
20
|
+
var Polyline_exports = {};
|
|
21
|
+
__export(Polyline_exports, {
|
|
22
|
+
default: () => Polyline_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Polyline_exports);
|
|
25
|
+
var import_larkmap = require("@antv/larkmap");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_map = require("../../utils/map");
|
|
28
|
+
var Polyline_default = (props) => {
|
|
29
|
+
const scene = (0, import_larkmap.useScene)();
|
|
30
|
+
const [layers, setLayers] = (0, import_react.useState)([]);
|
|
31
|
+
const removeLayers = () => {
|
|
32
|
+
layers.forEach((item) => {
|
|
33
|
+
scene.removeLayer(item);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
if (!props.polyline)
|
|
38
|
+
return;
|
|
39
|
+
const lineLayers = (0, import_map.setPolyline)(props.polyline || []);
|
|
40
|
+
removeLayers();
|
|
41
|
+
lineLayers.forEach((item) => {
|
|
42
|
+
scene.addLayer(item);
|
|
43
|
+
});
|
|
44
|
+
setLayers(lineLayers);
|
|
45
|
+
return () => {
|
|
46
|
+
removeLayers();
|
|
47
|
+
};
|
|
48
|
+
}, [props.polyline]);
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Map/Component/index.tsx
|
|
30
|
+
var Component_exports = {};
|
|
31
|
+
__export(Component_exports, {
|
|
32
|
+
MapView: () => import_MapView.default,
|
|
33
|
+
Marker: () => import_Marker.default,
|
|
34
|
+
Polyline: () => import_Polyline.default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(Component_exports);
|
|
37
|
+
var import_MapView = __toESM(require("./MapView"));
|
|
38
|
+
var import_Marker = __toESM(require("./Marker"));
|
|
39
|
+
var import_Polyline = __toESM(require("./Polyline"));
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
MapView,
|
|
43
|
+
Marker,
|
|
44
|
+
Polyline
|
|
45
|
+
});
|
package/dist/cjs/Map/index.js
CHANGED
|
@@ -35,24 +35,14 @@ module.exports = __toCommonJS(Map_exports);
|
|
|
35
35
|
var import_larkmap = require("@antv/larkmap");
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_map = require("../utils/map");
|
|
38
|
+
var import_Component = require("./Component/");
|
|
38
39
|
var Map = (props) => {
|
|
39
40
|
const { className, containerStyle, children } = props;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
await (0, import_map.setMapContext)(props, scene);
|
|
45
|
-
if (props.polyline) {
|
|
46
|
-
const polylineLayer = (0, import_map.setPolyline)(props.polyline || []);
|
|
47
|
-
allLayers.push(...polylineLayer);
|
|
41
|
+
const mapConfig = (0, import_react.useMemo)(() => (0, import_map.formatMapStyle)(props), [props]);
|
|
42
|
+
const onSceneLoaded = async () => {
|
|
43
|
+
if (props.onInitComplete) {
|
|
44
|
+
props.onInitComplete();
|
|
48
45
|
}
|
|
49
|
-
if (props.markers) {
|
|
50
|
-
const markerLayer = (0, import_map.setMarkers)(props.markers || []);
|
|
51
|
-
allLayers.push(...markerLayer);
|
|
52
|
-
}
|
|
53
|
-
allLayers.forEach((item) => {
|
|
54
|
-
scene.addLayer(item);
|
|
55
|
-
});
|
|
56
46
|
};
|
|
57
47
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
58
48
|
import_larkmap.LarkMap,
|
|
@@ -62,6 +52,9 @@ var Map = (props) => {
|
|
|
62
52
|
...mapConfig,
|
|
63
53
|
onSceneLoaded
|
|
64
54
|
},
|
|
55
|
+
/* @__PURE__ */ import_react.default.createElement(import_Component.MapView, { ...props }),
|
|
56
|
+
/* @__PURE__ */ import_react.default.createElement(import_Component.Marker, { ...props }),
|
|
57
|
+
/* @__PURE__ */ import_react.default.createElement(import_Component.Polyline, { ...props }),
|
|
65
58
|
children
|
|
66
59
|
);
|
|
67
60
|
};
|
|
@@ -31,6 +31,9 @@ function setMapContext(props, scene) {
|
|
|
31
31
|
return Promise.all(
|
|
32
32
|
Array.from(icons.values()).map(async (url) => {
|
|
33
33
|
const id = (0, import_util.urlToMarkerId)(url);
|
|
34
|
+
if (scene.hasImage(id)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
34
37
|
return await scene.addImage(id, url);
|
|
35
38
|
})
|
|
36
39
|
);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Scene } from '@antv/l7';
|
|
2
2
|
import type { Map } from '../../types/map';
|
|
3
3
|
export declare const setMapView: (props: Map, scene: Scene) => void;
|
|
4
|
+
export declare const fitBounds: (props: Map, scene: Scene) => void;
|
|
5
|
+
export declare const setMapStatus: (props: Map, scene: Scene) => void;
|
|
@@ -19,6 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/utils/map/view.ts
|
|
20
20
|
var view_exports = {};
|
|
21
21
|
__export(view_exports, {
|
|
22
|
+
fitBounds: () => fitBounds,
|
|
23
|
+
setMapStatus: () => setMapStatus,
|
|
22
24
|
setMapView: () => setMapView
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(view_exports);
|
|
@@ -47,6 +49,10 @@ function fitIncludePoints(includePoints, scene, includePadding) {
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
var setMapView = (props, scene) => {
|
|
52
|
+
fitBounds(props, scene);
|
|
53
|
+
setMapStatus(props, scene);
|
|
54
|
+
};
|
|
55
|
+
var fitBounds = (props, scene) => {
|
|
50
56
|
if (props.includePoints) {
|
|
51
57
|
fitIncludePoints(props.includePoints, scene, props.includePadding);
|
|
52
58
|
} else {
|
|
@@ -67,6 +73,8 @@ var setMapView = (props, scene) => {
|
|
|
67
73
|
fitIncludePoints(points, scene, props.includePadding);
|
|
68
74
|
}
|
|
69
75
|
}
|
|
76
|
+
};
|
|
77
|
+
var setMapStatus = (props, scene) => {
|
|
70
78
|
if (props.enableZoom !== void 0) {
|
|
71
79
|
scene.setMapStatus({
|
|
72
80
|
zoomEnable: props.enableZoom
|
|
@@ -82,12 +90,10 @@ var setMapView = (props, scene) => {
|
|
|
82
90
|
dragEnable: props.enableScroll
|
|
83
91
|
});
|
|
84
92
|
}
|
|
85
|
-
if (props.onInitComplete) {
|
|
86
|
-
scene.off("loaded", props.onInitComplete);
|
|
87
|
-
scene.on("loaded", props.onInitComplete);
|
|
88
|
-
}
|
|
89
93
|
};
|
|
90
94
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
95
|
0 && (module.exports = {
|
|
96
|
+
fitBounds,
|
|
97
|
+
setMapStatus,
|
|
92
98
|
setMapView
|
|
93
99
|
});
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "0.3.
|
|
1
|
+
declare const _default: "0.3.3";
|
|
2
2
|
export default _default;
|
package/dist/cjs/version.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useScene } from '@antv/larkmap';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { fitBounds, setMapStatus, setMapView } from "../../utils/map";
|
|
4
|
+
|
|
5
|
+
// 更新地图视野
|
|
6
|
+
export default (function (props) {
|
|
7
|
+
var scene = useScene();
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
setMapView(props, scene);
|
|
10
|
+
}, []);
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
setMapStatus(props, scene);
|
|
13
|
+
}, [props.enableRotate, props.enableScroll, props.enableZoom]);
|
|
14
|
+
useEffect(function () {
|
|
15
|
+
fitBounds(props, scene);
|
|
16
|
+
}, [props.includePoints, props.markers, props.polyline, props.includePadding]);
|
|
17
|
+
return null;
|
|
18
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useScene } from '@antv/larkmap';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { setMapContext, setMarkers } from "../../utils/map";
|
|
5
|
+
// 渲染标记点
|
|
6
|
+
export default (function (props) {
|
|
7
|
+
var scene = useScene();
|
|
8
|
+
var _useState = useState([]),
|
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10
|
+
layers = _useState2[0],
|
|
11
|
+
setLayers = _useState2[1];
|
|
12
|
+
var removeLayers = function removeLayers() {
|
|
13
|
+
layers.forEach(function (item) {
|
|
14
|
+
scene.removeLayer(item);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
var _setMapContext;
|
|
19
|
+
if (!props.markers) return;
|
|
20
|
+
// 异步调用
|
|
21
|
+
(_setMapContext = setMapContext(props, scene)) === null || _setMapContext === void 0 || _setMapContext.then(function () {
|
|
22
|
+
// 初始化资源
|
|
23
|
+
var markerLayer = setMarkers(props.markers || []);
|
|
24
|
+
removeLayers();
|
|
25
|
+
markerLayer.forEach(function (item) {
|
|
26
|
+
scene.addLayer(item);
|
|
27
|
+
});
|
|
28
|
+
setLayers(markerLayer);
|
|
29
|
+
});
|
|
30
|
+
return function () {
|
|
31
|
+
removeLayers();
|
|
32
|
+
};
|
|
33
|
+
}, [props.markers]);
|
|
34
|
+
return null;
|
|
35
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useScene } from '@antv/larkmap';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { setPolyline } from "../../utils/map";
|
|
5
|
+
// 渲染线图层
|
|
6
|
+
export default (function (props) {
|
|
7
|
+
var scene = useScene();
|
|
8
|
+
var _useState = useState([]),
|
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10
|
+
layers = _useState2[0],
|
|
11
|
+
setLayers = _useState2[1];
|
|
12
|
+
var removeLayers = function removeLayers() {
|
|
13
|
+
layers.forEach(function (item) {
|
|
14
|
+
scene.removeLayer(item);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
if (!props.polyline) return;
|
|
19
|
+
var lineLayers = setPolyline(props.polyline || []);
|
|
20
|
+
removeLayers();
|
|
21
|
+
lineLayers.forEach(function (item) {
|
|
22
|
+
scene.addLayer(item);
|
|
23
|
+
});
|
|
24
|
+
setLayers(lineLayers);
|
|
25
|
+
return function () {
|
|
26
|
+
removeLayers();
|
|
27
|
+
};
|
|
28
|
+
}, [props.polyline]);
|
|
29
|
+
return null;
|
|
30
|
+
});
|
package/dist/esm/Map/index.js
CHANGED
|
@@ -1,50 +1,33 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
4
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
6
5
|
import { LarkMap } from '@antv/larkmap';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { formatMapStyle
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
import { formatMapStyle } from "../utils/map";
|
|
8
|
+
import { MapView, Marker, Polyline } from "./Component/";
|
|
9
9
|
var Map = function Map(props) {
|
|
10
10
|
var className = props.className,
|
|
11
11
|
containerStyle = props.containerStyle,
|
|
12
12
|
children = props.children;
|
|
13
|
-
var
|
|
14
|
-
|
|
13
|
+
var mapConfig = useMemo(function () {
|
|
14
|
+
return formatMapStyle(props);
|
|
15
|
+
}, [props]);
|
|
15
16
|
var onSceneLoaded = /*#__PURE__*/function () {
|
|
16
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
|
17
|
-
var polylineLayer, markerLayer;
|
|
17
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
18
18
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19
19
|
while (1) switch (_context.prev = _context.next) {
|
|
20
20
|
case 0:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// 初始化地图资源和状态
|
|
24
|
-
_context.next = 3;
|
|
25
|
-
return setMapContext(props, scene);
|
|
26
|
-
case 3:
|
|
27
|
-
// 添加线图层
|
|
28
|
-
if (props.polyline) {
|
|
29
|
-
polylineLayer = setPolyline(props.polyline || []);
|
|
30
|
-
allLayers.push.apply(allLayers, _toConsumableArray(polylineLayer));
|
|
21
|
+
if (props.onInitComplete) {
|
|
22
|
+
props.onInitComplete();
|
|
31
23
|
}
|
|
32
|
-
|
|
33
|
-
// 添加标记
|
|
34
|
-
if (props.markers) {
|
|
35
|
-
markerLayer = setMarkers(props.markers || []);
|
|
36
|
-
allLayers.push.apply(allLayers, _toConsumableArray(markerLayer));
|
|
37
|
-
}
|
|
38
|
-
allLayers.forEach(function (item) {
|
|
39
|
-
scene.addLayer(item);
|
|
40
|
-
});
|
|
41
|
-
case 6:
|
|
24
|
+
case 1:
|
|
42
25
|
case "end":
|
|
43
26
|
return _context.stop();
|
|
44
27
|
}
|
|
45
28
|
}, _callee);
|
|
46
29
|
}));
|
|
47
|
-
return function onSceneLoaded(
|
|
30
|
+
return function onSceneLoaded() {
|
|
48
31
|
return _ref.apply(this, arguments);
|
|
49
32
|
};
|
|
50
33
|
}();
|
|
@@ -55,6 +38,6 @@ var Map = function Map(props) {
|
|
|
55
38
|
}, containerStyle)
|
|
56
39
|
}, mapConfig, {
|
|
57
40
|
onSceneLoaded: onSceneLoaded
|
|
58
|
-
}), children);
|
|
41
|
+
}), /*#__PURE__*/React.createElement(MapView, props), /*#__PURE__*/React.createElement(Marker, props), /*#__PURE__*/React.createElement(Polyline, props), children);
|
|
59
42
|
};
|
|
60
43
|
export default Map;
|
|
@@ -16,11 +16,17 @@ export function setMapContext(props, scene) {
|
|
|
16
16
|
while (1) switch (_context.prev = _context.next) {
|
|
17
17
|
case 0:
|
|
18
18
|
id = urlToMarkerId(url);
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (!scene.hasImage(id)) {
|
|
20
|
+
_context.next = 3;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
return _context.abrupt("return");
|
|
21
24
|
case 3:
|
|
25
|
+
_context.next = 5;
|
|
26
|
+
return scene.addImage(id, url);
|
|
27
|
+
case 5:
|
|
22
28
|
return _context.abrupt("return", _context.sent);
|
|
23
|
-
case
|
|
29
|
+
case 6:
|
|
24
30
|
case "end":
|
|
25
31
|
return _context.stop();
|
|
26
32
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Scene } from '@antv/l7';
|
|
2
2
|
import type { Map } from '../../types/map';
|
|
3
3
|
export declare const setMapView: (props: Map, scene: Scene) => void;
|
|
4
|
+
export declare const fitBounds: (props: Map, scene: Scene) => void;
|
|
5
|
+
export declare const setMapStatus: (props: Map, scene: Scene) => void;
|
|
@@ -32,7 +32,10 @@ function fitIncludePoints(includePoints, scene, includePadding) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
export var setMapView = function setMapView(props, scene) {
|
|
35
|
-
|
|
35
|
+
fitBounds(props, scene);
|
|
36
|
+
setMapStatus(props, scene);
|
|
37
|
+
};
|
|
38
|
+
export var fitBounds = function fitBounds(props, scene) {
|
|
36
39
|
if (props.includePoints) {
|
|
37
40
|
fitIncludePoints(props.includePoints, scene, props.includePadding);
|
|
38
41
|
} else {
|
|
@@ -59,6 +62,8 @@ export var setMapView = function setMapView(props, scene) {
|
|
|
59
62
|
fitIncludePoints(points, scene, props.includePadding);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
65
|
+
};
|
|
66
|
+
export var setMapStatus = function setMapStatus(props, scene) {
|
|
62
67
|
if (props.enableZoom !== undefined) {
|
|
63
68
|
scene.setMapStatus({
|
|
64
69
|
zoomEnable: props.enableZoom
|
|
@@ -74,8 +79,4 @@ export var setMapView = function setMapView(props, scene) {
|
|
|
74
79
|
dragEnable: props.enableScroll
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
|
-
if (props.onInitComplete) {
|
|
78
|
-
scene.off('loaded', props.onInitComplete);
|
|
79
|
-
scene.on('loaded', props.onInitComplete);
|
|
80
|
-
}
|
|
81
82
|
};
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "0.3.
|
|
1
|
+
declare const _default: "0.3.3";
|
|
2
2
|
export default _default;
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '0.3.
|
|
1
|
+
export default '0.3.3';
|