gisviewer-vue3-arcgis 1.0.89 → 1.0.90
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/es/src/gis-map/gis-map.vue.d.ts +2 -1
- package/es/src/gis-map/gis-map.vue.mjs +78 -77
- package/es/src/gis-map/index.d.ts +1 -0
- package/es/src/gis-map/utils/GreenWaveline.mjs +1 -1
- package/es/src/gis-map/utils/map-initializer.d.ts +2 -1
- package/es/src/gis-map/utils/map-initializer.mjs +104 -85
- package/es/src/gis-map/utils/renderer/greenWaveline.d.ts +2 -2
- package/es/src/types/index.d.ts +5 -1
- package/lib/src/gis-map/gis-map.vue.d.ts +2 -1
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +1 -0
- package/lib/src/gis-map/utils/GreenWaveline.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.d.ts +2 -1
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/gis-map/utils/renderer/greenWaveline.d.ts +2 -2
- package/lib/src/types/index.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
|
-
import { ILaneNumberParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IStartCrossBufferParam } from '../types';
|
|
3
|
+
import { ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IStartCrossBufferParam } from '../types';
|
|
4
4
|
import HoloFlow from './utils/holo-flow';
|
|
5
5
|
import MapInitializer from './utils/map-initializer';
|
|
6
6
|
import OpenDriveRenderer from './utils/open-drive-renderer';
|
|
@@ -31,6 +31,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
31
31
|
setMapCenter: (params: ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
32
32
|
setMapCamera: (params: ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
33
33
|
lookAt: (params: ILookAtParams) => Promise<void>;
|
|
34
|
+
setLayerVisibility: (params: ILayerVisibleParams) => import("../types").IResult;
|
|
34
35
|
requestCoordinateTransform: (points: number[][], callback: (points: number[][]) => void) => {
|
|
35
36
|
handle: number;
|
|
36
37
|
points: number[][];
|
|
@@ -1,109 +1,110 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import ce, { registerStore as
|
|
1
|
+
import { defineComponent as ee, ref as te, onMounted as ae, getCurrentInstance as ne, computed as re, openBlock as oe, createElementBlock as se, createElementVNode as ie } from "vue";
|
|
2
|
+
import ce, { registerStore as le } from "./stores/index.mjs";
|
|
3
3
|
import "./style/index.css";
|
|
4
4
|
import w from "./utils/holo-flow/index.mjs";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
const
|
|
5
|
+
import me from "./utils/map-initializer.mjs";
|
|
6
|
+
import pe from "./utils/open-drive-renderer/index.mjs";
|
|
7
|
+
import ue from "./utils/overlay.mjs";
|
|
8
|
+
import de from "./utils/queue-length.mjs";
|
|
9
|
+
import g from "./utils/road-config-tool/index.mjs";
|
|
10
|
+
import fe from "./utils/traffic-flow.mjs";
|
|
11
|
+
const we = { class: "gis-viewer" }, be = /* @__PURE__ */ ee({
|
|
12
12
|
__name: "gis-map",
|
|
13
13
|
props: {
|
|
14
14
|
config: {},
|
|
15
15
|
assetsRoot: {}
|
|
16
16
|
},
|
|
17
17
|
emits: ["mapLoaded", "markerClick", "mapClick"],
|
|
18
|
-
setup(
|
|
19
|
-
const m =
|
|
20
|
-
let r,
|
|
21
|
-
|
|
18
|
+
setup(v, { expose: h, emit: k }) {
|
|
19
|
+
const m = te(null);
|
|
20
|
+
let r, o, n, s, t, a, c, l;
|
|
21
|
+
le(), ae(async () => {
|
|
22
22
|
if (!m.value)
|
|
23
23
|
return;
|
|
24
|
-
const e =
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
24
|
+
const e = ne(), { $gisviewerAssetsRoot: i } = e.appContext.config.globalProperties, C = await (await fetch(y.config)).json();
|
|
25
|
+
C.assetsRoot = y.assetsRoot || i;
|
|
26
|
+
const Y = ce.useAppDataStore;
|
|
27
|
+
Y.mapConfig = C, o = new me(), r = await o.initialize({
|
|
28
28
|
container: m.value,
|
|
29
|
-
markerClickCallback: (u, d, f,
|
|
30
|
-
p("markerClick", u, d, f,
|
|
29
|
+
markerClickCallback: (u, d, f, F) => {
|
|
30
|
+
p("markerClick", u, d, f, F);
|
|
31
31
|
},
|
|
32
32
|
mapClickCallback: (u, d, f) => {
|
|
33
33
|
p("mapClick", u, d, f);
|
|
34
34
|
}
|
|
35
|
-
}),
|
|
35
|
+
}), t = new w(r), p("mapLoaded");
|
|
36
36
|
});
|
|
37
|
-
const O =
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
},
|
|
37
|
+
const O = re(() => r), L = async (e) => await o.setMapCenter(e), T = async (e) => await o.setMapCamera(e), A = async (e) => await o.lookAt(e), b = (e) => o.setLayerVisibility(e), I = (e, i) => o.requestCoordinateTransform(e, i), D = (e) => {
|
|
38
|
+
o.cancelCoordinateTransform(e);
|
|
39
|
+
}, S = (e) => {
|
|
40
|
+
o.setMapZoomRange(e);
|
|
41
|
+
}, _ = (e) => (n || (n = new g(r)), n.showLaneNumber(e)), M = () => {
|
|
42
42
|
n == null || n.clearLaneNumber();
|
|
43
|
-
},
|
|
44
|
-
}, B = async (e,
|
|
45
|
-
|
|
43
|
+
}, R = async (e) => (n || (n = new g(r)), await n.initializeSearch(e)), V = async () => n == null ? void 0 : n.calCrossIndicatorArea(), x = async () => {
|
|
44
|
+
}, B = async (e, i) => {
|
|
45
|
+
s || (s = new fe(r)), s.connectTrafficFlow(e, i);
|
|
46
46
|
}, H = () => {
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
47
|
+
s == null || s.disconnectTrafficFlow();
|
|
48
|
+
}, z = (e) => {
|
|
49
|
+
t || (t = new w(r)), t.handleVehicleTraceData(e);
|
|
50
|
+
}, N = () => {
|
|
51
|
+
t == null || t.clearHoloTrace();
|
|
52
|
+
}, Q = async (e) => {
|
|
53
|
+
t || (t = new w(r)), await t.handleSignalData(e);
|
|
54
|
+
}, P = () => {
|
|
55
|
+
t == null || t.clearHoloSignal();
|
|
56
|
+
}, E = (e) => {
|
|
57
57
|
switch (e.name.toLowerCase()) {
|
|
58
58
|
case "vehiclePlate".toLowerCase():
|
|
59
|
-
|
|
59
|
+
s == null || s.toggleVehiclePlate(e.visible);
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
l || (l = new
|
|
72
|
-
},
|
|
62
|
+
}, Z = (e) => {
|
|
63
|
+
t == null || t.updatePanelContent(e);
|
|
64
|
+
}, j = async (e) => (a || (a = new ue(r)), await a.addOverlays(e)), q = (e) => a == null ? void 0 : a.removeOverlaysByType(e), $ = (e) => a == null ? void 0 : a.removeOverlaysById(e), G = () => a == null ? void 0 : a.removeAllOverlays(), J = () => {
|
|
65
|
+
a == null || a.showAllOverlays();
|
|
66
|
+
}, K = (e) => {
|
|
67
|
+
c || (c = new de(r)), c.updateQueueLength(e);
|
|
68
|
+
}, U = () => {
|
|
69
|
+
c == null || c.removeQueueLength();
|
|
70
|
+
}, W = async (e, i) => {
|
|
71
|
+
l || (l = new pe(r)), await l.showOpenDrive(e, i);
|
|
72
|
+
}, X = async () => {
|
|
73
73
|
await (l == null ? void 0 : l.hideOpenDrive());
|
|
74
|
-
},
|
|
74
|
+
}, y = v, p = k;
|
|
75
75
|
return h({
|
|
76
76
|
mapViewer: O,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
setLayerVisibility: b,
|
|
78
|
+
setMapCenter: L,
|
|
79
|
+
lookAt: A,
|
|
80
|
+
setMapCamera: T,
|
|
81
|
+
setMapZoomRange: S,
|
|
81
82
|
requestCoordinateTransform: I,
|
|
82
83
|
cancelCoordinateTransform: D,
|
|
83
|
-
addOverlays:
|
|
84
|
-
showAllOverlays:
|
|
85
|
-
removeOverlaysByType:
|
|
86
|
-
removeOverlaysById:
|
|
87
|
-
removeAllOverlays:
|
|
88
|
-
showLaneNumber:
|
|
89
|
-
clearLaneNumber:
|
|
90
|
-
initializeAreaTool:
|
|
91
|
-
calCrossIndicatorArea:
|
|
84
|
+
addOverlays: j,
|
|
85
|
+
showAllOverlays: J,
|
|
86
|
+
removeOverlaysByType: q,
|
|
87
|
+
removeOverlaysById: $,
|
|
88
|
+
removeAllOverlays: G,
|
|
89
|
+
showLaneNumber: _,
|
|
90
|
+
clearLaneNumber: M,
|
|
91
|
+
initializeAreaTool: R,
|
|
92
|
+
calCrossIndicatorArea: V,
|
|
92
93
|
calRoadIndicatorArea: x,
|
|
93
94
|
connectCarFlow: B,
|
|
94
95
|
disconnectCarFlow: H,
|
|
95
|
-
handleHoloVehicleTraceData:
|
|
96
|
-
clearHoloTrace:
|
|
97
|
-
handleHoloSignalData:
|
|
98
|
-
clearHoloSignal:
|
|
99
|
-
toggleTrafficInfo:
|
|
100
|
-
toggleVehicleInfo:
|
|
101
|
-
updateQueueLength:
|
|
102
|
-
removeQueueLength:
|
|
103
|
-
showOpenDrive:
|
|
104
|
-
hideOpenDrive:
|
|
105
|
-
}), (e,
|
|
106
|
-
|
|
96
|
+
handleHoloVehicleTraceData: z,
|
|
97
|
+
clearHoloTrace: N,
|
|
98
|
+
handleHoloSignalData: Q,
|
|
99
|
+
clearHoloSignal: P,
|
|
100
|
+
toggleTrafficInfo: E,
|
|
101
|
+
toggleVehicleInfo: Z,
|
|
102
|
+
updateQueueLength: K,
|
|
103
|
+
removeQueueLength: U,
|
|
104
|
+
showOpenDrive: W,
|
|
105
|
+
hideOpenDrive: X
|
|
106
|
+
}), (e, i) => (oe(), se("div", we, [
|
|
107
|
+
ie("div", {
|
|
107
108
|
class: "gis-viewer-main",
|
|
108
109
|
ref_key: "mapContainer",
|
|
109
110
|
ref: m
|
|
@@ -112,5 +113,5 @@ const fe = { class: "gis-viewer" }, Le = /* @__PURE__ */ F({
|
|
|
112
113
|
}
|
|
113
114
|
});
|
|
114
115
|
export {
|
|
115
|
-
|
|
116
|
+
be as default
|
|
116
117
|
};
|
|
@@ -21,6 +21,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
21
21
|
setMapCenter: (params: import("../types").ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
22
22
|
setMapCamera: (params: import("../types").ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
23
23
|
lookAt: (params: import("../types").ILookAtParams) => Promise<void>;
|
|
24
|
+
setLayerVisibility: (params: import("../types").ILayerVisibleParams) => import("../types").IResult;
|
|
24
25
|
requestCoordinateTransform: (points: number[][], callback: (points: number[][]) => void) => {
|
|
25
26
|
handle: number;
|
|
26
27
|
points: number[][];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
|
-
import { ILookAtParams, IResult, ISetMapCameraParams, ISetMapCenterParams } from '../../types';
|
|
3
|
+
import { ILayerVisibleParams, ILookAtParams, IResult, ISetMapCameraParams, ISetMapCenterParams } from '../../types';
|
|
4
4
|
export default class MapInitializer {
|
|
5
5
|
private view;
|
|
6
6
|
private mapConfig;
|
|
@@ -14,6 +14,7 @@ export default class MapInitializer {
|
|
|
14
14
|
markerClickCallback?: (type: string, id: string, detail: any, event?: any) => void;
|
|
15
15
|
mapClickCallback?: (mapPoint: number[], screenPoint: number[], event?: any) => void;
|
|
16
16
|
}): Promise<MapView | SceneView>;
|
|
17
|
+
setLayerVisibility(params: ILayerVisibleParams): IResult;
|
|
17
18
|
/**
|
|
18
19
|
* 设置地图中心点
|
|
19
20
|
* @param params
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import { Point as
|
|
1
|
+
import M from "@arcgis/core/Basemap";
|
|
2
|
+
import P from "@arcgis/core/Map";
|
|
3
|
+
import g from "@arcgis/core/config";
|
|
4
|
+
import * as T from "@arcgis/core/core/reactiveUtils";
|
|
5
|
+
import { Point as k } from "@arcgis/core/geometry";
|
|
6
6
|
import * as f from "@arcgis/core/geometry/support/webMercatorUtils";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
7
|
+
import z from "@arcgis/core/layers/GeoJSONLayer";
|
|
8
|
+
import W from "@arcgis/core/layers/TileLayer";
|
|
9
|
+
import x from "@arcgis/core/layers/WebTileLayer";
|
|
10
|
+
import L from "@arcgis/core/views/MapView";
|
|
11
|
+
import R from "@arcgis/core/views/SceneView";
|
|
12
12
|
import S from "@turf/destination";
|
|
13
|
-
import * as
|
|
13
|
+
import * as H from "@turf/helpers";
|
|
14
14
|
import I from "../stores/index.mjs";
|
|
15
|
-
function
|
|
15
|
+
function v(m, e) {
|
|
16
16
|
return m.startsWith("http://") || m.startsWith("https://") ? m : e + m;
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class D {
|
|
19
19
|
constructor() {
|
|
20
20
|
this.mapConfig = {}, this.watchHandleMap = /* @__PURE__ */ new Map(), this.handleIndex = 0, this.zoomWatchHandle = null;
|
|
21
21
|
}
|
|
@@ -25,29 +25,29 @@ class j {
|
|
|
25
25
|
* @returns view
|
|
26
26
|
*/
|
|
27
27
|
async initialize(e) {
|
|
28
|
-
const
|
|
28
|
+
const s = I.useAppDataStore, t = JSON.parse(JSON.stringify(s.mapConfig));
|
|
29
29
|
this.mapConfig = t;
|
|
30
|
-
const { container: a, markerClickCallback:
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
if ((t == null ? void 0 : t.mapOptions.mode.toLowerCase()) === "2d" ? this.view = new
|
|
34
|
-
map:
|
|
30
|
+
const { container: a, markerClickCallback: r, mapClickCallback: d } = e;
|
|
31
|
+
g.assetsPath = `${t.assetsRoot}/ArcgisAssets`, g.fontsUrl = `${t.assetsRoot}/fonts`, g.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
|
|
32
|
+
const c = new P();
|
|
33
|
+
if ((t == null ? void 0 : t.mapOptions.mode.toLowerCase()) === "2d" ? this.view = new L({
|
|
34
|
+
map: c,
|
|
35
35
|
container: a,
|
|
36
36
|
...t.mapOptions
|
|
37
|
-
}) : this.view = new
|
|
38
|
-
map:
|
|
37
|
+
}) : this.view = new R({
|
|
38
|
+
map: c,
|
|
39
39
|
container: a,
|
|
40
40
|
...t == null ? void 0 : t.mapOptions
|
|
41
|
-
}), this.view.on("click", async (
|
|
42
|
-
var
|
|
43
|
-
if (
|
|
44
|
-
let o =
|
|
41
|
+
}), this.view.on("click", async (i) => {
|
|
42
|
+
var y, b;
|
|
43
|
+
if (d) {
|
|
44
|
+
let o = i.mapPoint;
|
|
45
45
|
o.spatialReference.isWebMercator && (o = f.webMercatorToGeographic(
|
|
46
46
|
o
|
|
47
|
-
)),
|
|
47
|
+
)), d(
|
|
48
48
|
[o.x, o.y],
|
|
49
|
-
[
|
|
50
|
-
|
|
49
|
+
[i.screenPoint.x, i.screenPoint.y],
|
|
50
|
+
i
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
if (this.view.type === "3d") {
|
|
@@ -55,12 +55,12 @@ class j {
|
|
|
55
55
|
if (this.view.spatialReference.isWebMercator) {
|
|
56
56
|
const l = f.webMercatorToGeographic(
|
|
57
57
|
o.position
|
|
58
|
-
),
|
|
58
|
+
), w = {
|
|
59
59
|
heading: o.heading,
|
|
60
60
|
tilt: o.tilt,
|
|
61
61
|
position: l.toJSON()
|
|
62
62
|
};
|
|
63
|
-
console.log(
|
|
63
|
+
console.log(w), (y = navigator.clipboard) == null || y.writeText(JSON.stringify(w));
|
|
64
64
|
} else
|
|
65
65
|
console.log(o.toJSON());
|
|
66
66
|
} else {
|
|
@@ -72,62 +72,84 @@ class j {
|
|
|
72
72
|
zoom: this.view.zoom
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
const h = (
|
|
75
|
+
const h = (b = (await this.view.hitTest(i)).results) == null ? void 0 : b.filter(
|
|
76
76
|
(o) => o.type === "graphic"
|
|
77
77
|
);
|
|
78
78
|
h.length > 0 && h.forEach((o) => {
|
|
79
|
-
var
|
|
79
|
+
var w;
|
|
80
80
|
const l = o.graphic;
|
|
81
|
-
(
|
|
81
|
+
(w = l.attributes) != null && w.type && r && r(
|
|
82
82
|
l.attributes.type,
|
|
83
83
|
l.attributes.id,
|
|
84
84
|
l.attributes,
|
|
85
|
-
|
|
85
|
+
i
|
|
86
86
|
);
|
|
87
87
|
});
|
|
88
|
-
}), t != null && t.baseLayers ? t.baseLayers.forEach((
|
|
89
|
-
switch (
|
|
88
|
+
}), t != null && t.baseLayers ? t.baseLayers.forEach((i) => {
|
|
89
|
+
switch (i.type.toLowerCase()) {
|
|
90
90
|
case "webTile".toLowerCase(): {
|
|
91
|
-
const
|
|
92
|
-
urlTemplate:
|
|
93
|
-
...
|
|
91
|
+
const n = v(i.url, t.assetsRoot), h = new x({
|
|
92
|
+
urlTemplate: n,
|
|
93
|
+
...i.options
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
c.add(h);
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
case "tile": {
|
|
99
|
-
const
|
|
100
|
-
url:
|
|
101
|
-
...
|
|
99
|
+
const n = v(i.url, t.assetsRoot), h = new W({
|
|
100
|
+
url: n,
|
|
101
|
+
...i.options
|
|
102
102
|
});
|
|
103
|
-
|
|
103
|
+
c.add(h);
|
|
104
104
|
break;
|
|
105
105
|
}
|
|
106
106
|
case "arcgis": {
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const n = new M(i.options);
|
|
108
|
+
c.basemap = n;
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
}) :
|
|
112
|
+
}) : c.basemap = new M({
|
|
113
113
|
style: {
|
|
114
114
|
id: "arcgis/dark-gray",
|
|
115
115
|
language: "zh-CN"
|
|
116
116
|
}
|
|
117
117
|
}), t != null && t.hdLayers) {
|
|
118
|
-
const
|
|
119
|
-
(
|
|
118
|
+
const i = t.hdLayers.map(
|
|
119
|
+
(n) => (
|
|
120
120
|
// 图层文件为GeoJson格式, renderer和symbol使用autocast配置
|
|
121
|
-
new
|
|
122
|
-
url:
|
|
123
|
-
...
|
|
124
|
-
title:
|
|
121
|
+
new z({
|
|
122
|
+
url: v(n.url, t.assetsRoot),
|
|
123
|
+
...n.options,
|
|
124
|
+
title: n.options.id
|
|
125
125
|
})
|
|
126
126
|
)
|
|
127
127
|
);
|
|
128
|
-
|
|
128
|
+
c.addMany(i);
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
this.view.ui.remove("attribution"), this.view.ui.add("compass", "top-left"), await this.view.when();
|
|
131
|
+
const p = this.mapConfig.camera;
|
|
132
|
+
let u;
|
|
133
|
+
if (this.view.type === "2d") {
|
|
134
|
+
let i = this.view.center;
|
|
135
|
+
this.view.spatialReference.isWebMercator && (i = f.webMercatorToGeographic(
|
|
136
|
+
i
|
|
137
|
+
)), u = { center: [i.x, i.y], zoom: this.view.zoom };
|
|
138
|
+
} else {
|
|
139
|
+
let i = this.view.camera.position;
|
|
140
|
+
this.view.spatialReference.isWebMercator && (i = f.webMercatorToGeographic(
|
|
141
|
+
i
|
|
142
|
+
)), u = {
|
|
143
|
+
position: i,
|
|
144
|
+
heading: this.view.camera.heading,
|
|
145
|
+
tilt: this.view.camera.tilt
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return p ? p.home = u : this.mapConfig.camera = { home: u }, this.view;
|
|
149
|
+
}
|
|
150
|
+
setLayerVisibility(e) {
|
|
151
|
+
const { id: s, visible: t } = e, a = this.view.map.findLayerById(s);
|
|
152
|
+
return a ? (a.visible = t, { status: 0, message: "ok" }) : { status: -1, message: "未找到图层" };
|
|
131
153
|
}
|
|
132
154
|
/**
|
|
133
155
|
* 设置地图中心点
|
|
@@ -151,8 +173,8 @@ class j {
|
|
|
151
173
|
async lookAt(e) {
|
|
152
174
|
if (this.view.type === "2d")
|
|
153
175
|
return;
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
176
|
+
const s = e.tilt || 0, t = e.heading || 0;
|
|
177
|
+
if (s === 0)
|
|
156
178
|
await this.view.goTo(
|
|
157
179
|
{
|
|
158
180
|
position: {
|
|
@@ -166,8 +188,8 @@ class j {
|
|
|
166
188
|
{ duration: (e.duration || 2) * 1e3 }
|
|
167
189
|
);
|
|
168
190
|
else {
|
|
169
|
-
const a = Math.tan(
|
|
170
|
-
|
|
191
|
+
const a = Math.tan(s * Math.PI / 180) * e.height, r = S(
|
|
192
|
+
H.point(e.center),
|
|
171
193
|
a,
|
|
172
194
|
t + 180,
|
|
173
195
|
{
|
|
@@ -177,12 +199,12 @@ class j {
|
|
|
177
199
|
await this.view.goTo(
|
|
178
200
|
{
|
|
179
201
|
position: {
|
|
180
|
-
x:
|
|
181
|
-
y:
|
|
202
|
+
x: r.geometry.coordinates[0],
|
|
203
|
+
y: r.geometry.coordinates[1],
|
|
182
204
|
z: e.height
|
|
183
205
|
},
|
|
184
206
|
heading: t,
|
|
185
|
-
tilt:
|
|
207
|
+
tilt: s
|
|
186
208
|
},
|
|
187
209
|
{ duration: (e.duration || 2) * 1e3 }
|
|
188
210
|
);
|
|
@@ -191,34 +213,31 @@ class j {
|
|
|
191
213
|
async setMapCamera(e) {
|
|
192
214
|
if (!this.view)
|
|
193
215
|
return { status: -1, message: "未初始化" };
|
|
194
|
-
const {
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
{ duration: t * 1e3 }
|
|
201
|
-
), { status: 0, message: "成功" }) : { status: -1, message: "未配置camera" } : { status: -1, message: "未配置camera" };
|
|
216
|
+
const { name: s, duration: t = 0 } = e, { camera: a } = this.mapConfig;
|
|
217
|
+
if (!a)
|
|
218
|
+
return { status: -1, message: "未配置camera" };
|
|
219
|
+
const r = a[s];
|
|
220
|
+
return r ? (console.log("target:", r, t * 1e3), await this.view.goTo(r, { duration: t * 1e3 }), { status: 0, message: "成功" }) : { status: -1, message: "未配置camera" };
|
|
202
221
|
}
|
|
203
222
|
/**
|
|
204
223
|
* 经纬度转像素坐标,在地图移动时回调
|
|
205
224
|
* */
|
|
206
|
-
requestCoordinateTransform(e,
|
|
225
|
+
requestCoordinateTransform(e, s) {
|
|
207
226
|
let t = 0;
|
|
208
|
-
const
|
|
227
|
+
const r = 1e3 / 30, d = T.watch(
|
|
209
228
|
() => this.view.center,
|
|
210
229
|
() => {
|
|
211
|
-
const
|
|
212
|
-
|
|
230
|
+
const c = this.transformPoints(e), p = Date.now();
|
|
231
|
+
p - t > r && (s(c), t = p);
|
|
213
232
|
}
|
|
214
233
|
);
|
|
215
|
-
return this.handleIndex++, this.watchHandleMap.set(this.handleIndex,
|
|
234
|
+
return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, d), { handle: this.handleIndex, points: this.transformPoints(e) };
|
|
216
235
|
}
|
|
217
236
|
transformPoints(e) {
|
|
218
|
-
return e.map((
|
|
219
|
-
const t = new
|
|
220
|
-
x:
|
|
221
|
-
y:
|
|
237
|
+
return e.map((s) => {
|
|
238
|
+
const t = new k({
|
|
239
|
+
x: s[0],
|
|
240
|
+
y: s[1]
|
|
222
241
|
}), a = this.view.toScreen(t);
|
|
223
242
|
return [a.x, a.y];
|
|
224
243
|
});
|
|
@@ -227,22 +246,22 @@ class j {
|
|
|
227
246
|
* 停止坐标转换回调
|
|
228
247
|
* */
|
|
229
248
|
cancelCoordinateTransform(e) {
|
|
230
|
-
const
|
|
231
|
-
|
|
249
|
+
const s = this.watchHandleMap.get(e);
|
|
250
|
+
s && (s.remove(), this.watchHandleMap.delete(e));
|
|
232
251
|
}
|
|
233
252
|
/**
|
|
234
253
|
* 设置地图zoom范围
|
|
235
254
|
* */
|
|
236
255
|
setMapZoomRange(e) {
|
|
237
|
-
const { min:
|
|
238
|
-
!
|
|
256
|
+
const { min: s, max: t } = e;
|
|
257
|
+
!s && !t || (this.zoomWatchHandle && this.zoomWatchHandle.remove(), this.zoomWatchHandle = T.watch(
|
|
239
258
|
() => this.view.zoom,
|
|
240
259
|
(a) => {
|
|
241
|
-
|
|
260
|
+
s && a <= s && (this.view.zoom = s), t && a >= t && (this.view.zoom = t);
|
|
242
261
|
}
|
|
243
262
|
));
|
|
244
263
|
}
|
|
245
264
|
}
|
|
246
265
|
export {
|
|
247
|
-
|
|
266
|
+
D as default
|
|
248
267
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const GreenWavelineView: any;
|
|
2
|
+
export default GreenWavelineView;
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -49,6 +49,10 @@ export interface ISetMapCenterParams {
|
|
|
49
49
|
zoom?: number;
|
|
50
50
|
duration?: number;
|
|
51
51
|
}
|
|
52
|
+
export interface ILayerVisibleParams {
|
|
53
|
+
id: string;
|
|
54
|
+
visible: boolean;
|
|
55
|
+
}
|
|
52
56
|
export interface ILookAtParams {
|
|
53
57
|
center: number[];
|
|
54
58
|
height: number;
|
|
@@ -120,7 +124,7 @@ export interface IOverlayParam {
|
|
|
120
124
|
visible?: boolean;
|
|
121
125
|
}
|
|
122
126
|
export interface ISetMapCameraParams {
|
|
123
|
-
|
|
127
|
+
name: string;
|
|
124
128
|
zoom?: number;
|
|
125
129
|
duration?: number;
|
|
126
130
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
|
-
import { ILaneNumberParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IStartCrossBufferParam } from '../types';
|
|
3
|
+
import { ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IStartCrossBufferParam } from '../types';
|
|
4
4
|
import HoloFlow from './utils/holo-flow';
|
|
5
5
|
import MapInitializer from './utils/map-initializer';
|
|
6
6
|
import OpenDriveRenderer from './utils/open-drive-renderer';
|
|
@@ -31,6 +31,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
31
31
|
setMapCenter: (params: ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
32
32
|
setMapCamera: (params: ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
33
33
|
lookAt: (params: ILookAtParams) => Promise<void>;
|
|
34
|
+
setLayerVisibility: (params: ILayerVisibleParams) => import("../types").IResult;
|
|
34
35
|
requestCoordinateTransform: (points: number[][], callback: (points: number[][]) => void) => {
|
|
35
36
|
handle: number;
|
|
36
37
|
points: number[][];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),C=require("./stores/index.js");require("./style/index.css");const y=require("./utils/holo-flow/index.js"),ae=require("./utils/map-initializer.js"),ne=require("./utils/open-drive-renderer/index.js"),re=require("./utils/overlay.js"),se=require("./utils/queue-length.js"),h=require("./utils/road-config-tool/index.js"),oe=require("./utils/traffic-flow.js"),ce={class:"gis-viewer"},ie=i.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:O,emit:L}){const d=i.ref(null);let r,s,n,o,t,a,l,u;C.registerStore(),i.onMounted(async()=>{if(!d.value)return;const e=i.getCurrentInstance(),{$gisviewerAssetsRoot:c}=e.appContext.config.globalProperties,g=await(await fetch(v.config)).json();g.assetsRoot=v.assetsRoot||c;const ee=C.default.useAppDataStore;ee.mapConfig=g,s=new ae.default,r=await s.initialize({container:d.value,markerClickCallback:(p,f,w,te)=>{m("markerClick",p,f,w,te)},mapClickCallback:(p,f,w)=>{m("mapClick",p,f,w)}}),t=new y.default(r),m("mapLoaded")});const b=i.computed(()=>r),q=async e=>await s.setMapCenter(e),A=async e=>await s.setMapCamera(e),T=async e=>await s.lookAt(e),_=e=>s.setLayerVisibility(e),I=(e,c)=>s.requestCoordinateTransform(e,c),S=e=>{s.cancelCoordinateTransform(e)},D=e=>{s.setMapZoomRange(e)},M=e=>(n||(n=new h.default(r)),n.showLaneNumber(e)),x=()=>{n==null||n.clearLaneNumber()},V=async e=>(n||(n=new h.default(r)),await n.initializeSearch(e)),B=async()=>n==null?void 0:n.calCrossIndicatorArea(),H=async()=>{},R=async(e,c)=>{o||(o=new oe.default(r)),o.connectTrafficFlow(e,c)},z=()=>{o==null||o.disconnectTrafficFlow()},N=e=>{t||(t=new y.default(r)),t.handleVehicleTraceData(e)},P=()=>{t==null||t.clearHoloTrace()},Q=async e=>{t||(t=new y.default(r)),await t.handleSignalData(e)},j=()=>{t==null||t.clearHoloSignal()},E=e=>{switch(e.name.toLowerCase()){case"vehiclePlate".toLowerCase():o==null||o.toggleVehiclePlate(e.visible);break}},Z=e=>{t==null||t.updatePanelContent(e)},G=async e=>(a||(a=new re.default(r)),await a.addOverlays(e)),J=e=>a==null?void 0:a.removeOverlaysByType(e),K=e=>a==null?void 0:a.removeOverlaysById(e),U=()=>a==null?void 0:a.removeAllOverlays(),W=()=>{a==null||a.showAllOverlays()},X=e=>{l||(l=new se.default(r)),l.updateQueueLength(e)},Y=()=>{l==null||l.removeQueueLength()},F=async(e,c)=>{u||(u=new ne.default(r)),await u.showOpenDrive(e,c)},$=async()=>{await(u==null?void 0:u.hideOpenDrive())},v=k,m=L;return O({mapViewer:b,setLayerVisibility:_,setMapCenter:q,lookAt:T,setMapCamera:A,setMapZoomRange:D,requestCoordinateTransform:I,cancelCoordinateTransform:S,addOverlays:G,showAllOverlays:W,removeOverlaysByType:J,removeOverlaysById:K,removeAllOverlays:U,showLaneNumber:M,clearLaneNumber:x,initializeAreaTool:V,calCrossIndicatorArea:B,calRoadIndicatorArea:H,connectCarFlow:R,disconnectCarFlow:z,handleHoloVehicleTraceData:N,clearHoloTrace:P,handleHoloSignalData:Q,clearHoloSignal:j,toggleTrafficInfo:E,toggleVehicleInfo:Z,updateQueueLength:X,removeQueueLength:Y,showOpenDrive:F,hideOpenDrive:$}),(e,c)=>(i.openBlock(),i.createElementBlock("div",ce,[i.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:d},null,512)]))}});exports.default=ie;
|
|
@@ -21,6 +21,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
21
21
|
setMapCenter: (params: import("../types").ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
22
22
|
setMapCamera: (params: import("../types").ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
23
23
|
lookAt: (params: import("../types").ILookAtParams) => Promise<void>;
|
|
24
|
+
setLayerVisibility: (params: import("../types").ILayerVisibleParams) => import("../types").IResult;
|
|
24
25
|
requestCoordinateTransform: (points: number[][], callback: (points: number[][]) => void) => {
|
|
25
26
|
handle: number;
|
|
26
27
|
points: number[][];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),y=require("@arcgis/core/geometry"),u=require("@arcgis/core/geometry/Polyline"),p=require("@arcgis/core/geometry/support/webMercatorUtils.js"),b=require("@arcgis/core/layers/GraphicsLayer"),g=require("./renderer/greenWaveline.js");function f(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:()=>o[t]})}}return i.default=o,Object.freeze(i)}const l=f(p);function v(...o){const i={},t=e=>{for(const r in e)e.hasOwnProperty(r)&&(Object.prototype.toString.call(e[r])==="[object Object]"?i[r]=v(i[r],e[r]):i[r]=e[r])};for(let e=0;e<o.length;e++)t(o[e]);return i}class m{constructor(i){this.defaultAnimationOptions={isAnimation:!1,positive:!0,positiveColor:[0,255,0],negative:!0,negativeColor:[0,255,0]},this.viewer=i.viewer,this.overlayLayer=new b({...i.graphicsLayerOptions}),this.customGreenWaveLineView=new g.default({graphics:[]}),this.viewer.map.layers.add(this.overlayLayer),this.viewer.map.layers.add(this.customGreenWaveLineView)}addGreenWaveLine(i,t={isAnimation:!1,positive:!0,positiveColor:[0,255,0],negative:!0,negativeColor:[0,255,0]}){const e=[],r=[];t=v(this.defaultAnimationOptions,t),i.map(a=>{const s=a.visible==null?!0:a.visible;if(t.isAnimation){const n=[...a.paths];r.push(...this.getAnimationPath(n,t))}e.push(this.createLine(a.paths,a.symbol,a.attributes,s))}),this.overlayLayer.addMany(e),t.isAnimation&&this.customGreenWaveLineView.addMany(r)}getAnimationPath(i,t={isAnimation:!1,positive:!0,positiveColor:[0,255,0],negative:!0,negativeColor:[0,255,0]}){const e=[];return t.positive&&e.push({attributes:{color:t.positiveColor},geometry:l.geographicToWebMercator({paths:[i],type:"polyline"})}),t.negative&&e.push({attributes:{color:t.negativeColor},geometry:l.geographicToWebMercator({paths:[i.reverse()],type:"polyline"})}),e}createLine(i,t,e={},r){const a={type:"simple-line",color:[8,69,9,.8],width:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),y=require("@arcgis/core/geometry"),u=require("@arcgis/core/geometry/Polyline"),p=require("@arcgis/core/geometry/support/webMercatorUtils.js"),b=require("@arcgis/core/layers/GraphicsLayer"),g=require("./renderer/greenWaveline.js");function f(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:()=>o[t]})}}return i.default=o,Object.freeze(i)}const l=f(p);function v(...o){const i={},t=e=>{for(const r in e)e.hasOwnProperty(r)&&(Object.prototype.toString.call(e[r])==="[object Object]"?i[r]=v(i[r],e[r]):i[r]=e[r])};for(let e=0;e<o.length;e++)t(o[e]);return i}class m{constructor(i){this.defaultAnimationOptions={isAnimation:!1,positive:!0,positiveColor:[0,255,0],negative:!0,negativeColor:[0,255,0]},this.viewer=i.viewer,this.overlayLayer=new b({...i.graphicsLayerOptions}),this.customGreenWaveLineView=new g.default({graphics:[]}),this.viewer.map.layers.add(this.overlayLayer),this.viewer.map.layers.add(this.customGreenWaveLineView)}addGreenWaveLine(i,t={isAnimation:!1,positive:!0,positiveColor:[0,255,0],negative:!0,negativeColor:[0,255,0]}){const e=[],r=[];t=v(this.defaultAnimationOptions,t),i.map(a=>{const s=a.visible==null?!0:a.visible;if(t.isAnimation){const n=[...a.paths];r.push(...this.getAnimationPath(n,t))}e.push(this.createLine(a.paths,a.symbol,a.attributes,s))}),this.overlayLayer.addMany(e),t.isAnimation&&this.customGreenWaveLineView.addMany(r)}getAnimationPath(i,t={isAnimation:!1,positive:!0,positiveColor:[0,255,0],negative:!0,negativeColor:[0,255,0]}){const e=[];return t.positive&&e.push({attributes:{color:t.positiveColor},geometry:l.geographicToWebMercator({paths:[i],type:"polyline"})}),t.negative&&e.push({attributes:{color:t.negativeColor},geometry:l.geographicToWebMercator({paths:[i.reverse()],type:"polyline"})}),e}createLine(i,t,e={},r){const a={type:"simple-line",color:[8,69,9,.8],width:5,...t},s=new u({paths:i}),n=l.geographicToWebMercator(s);return new c({geometry:n,symbol:a,attributes:{type:"greenWaveLine",...e},visible:r})}addPointText(i){const t=[];i.map(e=>{const r=e.visible==null?!0:e.visible;t.push(this.createPointText(e.point,e.symbol,e.attributes,r))}),this.overlayLayer.addMany(t)}createPointText(i,t,e={},r){const a={type:"text",color:"white",haloColor:"black",haloSize:"1px",xoffset:3,yoffset:3,font:{size:12,family:"Josefin Slab",weight:"bold"},...t},s=new y.Point({x:i[0],y:i[1]}),n=l.geographicToWebMercator(s);return new c({geometry:n,symbol:a,attributes:{type:"greenWaveLine-Text",...e},visible:r})}hideWaveLine(i){i?this.overlayLayer.graphics.filter(e=>{const r=e.getAttribute("id");return i.includes(r)}).forEach(e=>{e.visible=!1}):this.overlayLayer.graphics.map(t=>{t.visible=!1})}showWaveLine(i){i?this.overlayLayer.graphics.filter(e=>{const r=e.getAttribute("id");return i.includes(r)}).forEach(e=>{e.visible=!0}):this.overlayLayer.graphics.map(t=>{t.visible=!0})}hideLayer(){this.overlayLayer.visible=!1,this.customGreenWaveLineView.visible=!1}showLayer(){this.overlayLayer.visible=!0,this.customGreenWaveLineView.visible=!0}clearGreenWaveLine(){this.overlayLayer.removeAll(),this.customGreenWaveLineView.removeAll()}destroy(){this.overlayLayer.removeAll(),this.customGreenWaveLineView.removeAll(),this.viewer.map.layers.remove(this.customGreenWaveLineView),this.viewer.map.layers.remove(this.overlayLayer)}}exports.default=m;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
|
-
import { ILookAtParams, IResult, ISetMapCameraParams, ISetMapCenterParams } from '../../types';
|
|
3
|
+
import { ILayerVisibleParams, ILookAtParams, IResult, ISetMapCameraParams, ISetMapCenterParams } from '../../types';
|
|
4
4
|
export default class MapInitializer {
|
|
5
5
|
private view;
|
|
6
6
|
private mapConfig;
|
|
@@ -14,6 +14,7 @@ export default class MapInitializer {
|
|
|
14
14
|
markerClickCallback?: (type: string, id: string, detail: any, event?: any) => void;
|
|
15
15
|
mapClickCallback?: (mapPoint: number[], screenPoint: number[], event?: any) => void;
|
|
16
16
|
}): Promise<MapView | SceneView>;
|
|
17
|
+
setLayerVisibility(params: ILayerVisibleParams): IResult;
|
|
17
18
|
/**
|
|
18
19
|
* 设置地图中心点
|
|
19
20
|
* @param params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),k=require("@arcgis/core/Map"),g=require("@arcgis/core/config"),z=require("@arcgis/core/core/reactiveUtils"),q=require("@arcgis/core/geometry"),O=require("@arcgis/core/geometry/support/webMercatorUtils"),S=require("@arcgis/core/layers/GeoJSONLayer"),W=require("@arcgis/core/layers/TileLayer"),x=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js");function v(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const e=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,e.get?e:{enumerable:!0,get:()=>r[i]})}}return t.default=r,Object.freeze(t)}const T=v(z),p=v(O),G=v(I);function b(r,t){return r.startsWith("http://")||r.startsWith("https://")?r:t+r}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(t){const i=_.default.useAppDataStore,e=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=e;const{container:o,markerClickCallback:n,mapClickCallback:m}=t;g.assetsPath=`${e.assetsRoot}/ArcgisAssets`,g.fontsUrl=`${e.assetsRoot}/fonts`,g.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const h=new k;if((e==null?void 0:e.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({map:h,container:o,...e.mapOptions}):this.view=new R({map:h,container:o,...e==null?void 0:e.mapOptions}),this.view.on("click",async s=>{var y,M;if(m){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),m([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(y=navigator.clipboard)==null||y.writeText(JSON.stringify(d))}else console.log(a.toJSON())}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),e!=null&&e.baseLayers?e.baseLayers.forEach(s=>{switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const c=b(s.url,e.assetsRoot),l=new x({urlTemplate:c,...s.options});h.add(l);break}case"tile":{const c=b(s.url,e.assetsRoot),l=new W({url:c,...s.options});h.add(l);break}case"arcgis":{const c=new P(s.options);h.basemap=c;break}}}):h.basemap=new P({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),e!=null&&e.hdLayers){const s=e.hdLayers.map(c=>new S({url:b(c.url,e.assetsRoot),...c.options,title:c.options.id}));h.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let f;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),f={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),f={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=f:this.mapConfig.camera={home:f},this.view}setLayerVisibility(t){const{id:i,visible:e}=t,o=this.view.map.findLayerById(i);return o?(o.visible=e,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(t){return this.view?(t.center?await this.view.goTo({target:t.center,zoom:t.zoom},{duration:(t.duration||0)*1e3}):t.camera&&await this.view.goTo(t.camera,{duration:(t.duration||0)*1e3}),{status:0,message:"成功"}):{status:-1,message:"未初始化"}}async lookAt(t){if(this.view.type==="2d")return;const i=t.tilt||0,e=t.heading||0;if(i===0)await this.view.goTo({position:{x:t.center[0],y:t.center[1],z:t.height},heading:e,tilt:0},{duration:(t.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*t.height,n=H(G.point(t.center),o,e+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:t.height},heading:e,tilt:i},{duration:(t.duration||2)*1e3})}}async setMapCamera(t){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:e=0}=t,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(console.log("target:",n,e*1e3),await this.view.goTo(n,{duration:e*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(t,i){let e=0;const n=1e3/30,m=T.watch(()=>this.view.center,()=>{const h=this.transformPoints(t),w=Date.now();w-e>n&&(i(h),e=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,m),{handle:this.handleIndex,points:this.transformPoints(t)}}transformPoints(t){return t.map(i=>{const e=new q.Point({x:i[0],y:i[1]}),o=this.view.toScreen(e);return[o.x,o.y]})}cancelCoordinateTransform(t){const i=this.watchHandleMap.get(t);i&&(i.remove(),this.watchHandleMap.delete(t))}setMapZoomRange(t){const{min:i,max:e}=t;!i&&!e||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),e&&o>=e&&(this.view.zoom=e)}))}}exports.default=N;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const GreenWavelineView: any;
|
|
2
|
+
export default GreenWavelineView;
|
package/lib/src/types/index.d.ts
CHANGED
|
@@ -49,6 +49,10 @@ export interface ISetMapCenterParams {
|
|
|
49
49
|
zoom?: number;
|
|
50
50
|
duration?: number;
|
|
51
51
|
}
|
|
52
|
+
export interface ILayerVisibleParams {
|
|
53
|
+
id: string;
|
|
54
|
+
visible: boolean;
|
|
55
|
+
}
|
|
52
56
|
export interface ILookAtParams {
|
|
53
57
|
center: number[];
|
|
54
58
|
height: number;
|
|
@@ -120,7 +124,7 @@ export interface IOverlayParam {
|
|
|
120
124
|
visible?: boolean;
|
|
121
125
|
}
|
|
122
126
|
export interface ISetMapCameraParams {
|
|
123
|
-
|
|
127
|
+
name: string;
|
|
124
128
|
zoom?: number;
|
|
125
129
|
duration?: number;
|
|
126
130
|
}
|