gisviewer-vue3-arcgis
Version:
在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:
194 lines (193 loc) • 4.98 kB
JavaScript
import c from "@arcgis/core/Graphic";
import { Point as y } from "@arcgis/core/geometry";
import p from "@arcgis/core/geometry/Polyline";
import * as n from "@arcgis/core/geometry/support/webMercatorUtils.js";
import m from "@arcgis/core/layers/GraphicsLayer";
import u from "./renderer/greenWaveline.mjs";
function h(...l) {
const i = {}, t = (e) => {
for (const r in e)
e.hasOwnProperty(r) && (Object.prototype.toString.call(e[r]) === "[object Object]" ? i[r] = h(i[r], e[r]) : i[r] = e[r]);
};
for (let e = 0; e < l.length; e++)
t(l[e]);
return i;
}
class d {
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 m({
...i.graphicsLayerOptions
}), this.customGreenWaveLineView = new u({
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 = h(this.defaultAnimationOptions, t), i.map((a) => {
const o = a.visible == null ? !0 : a.visible;
if (t.isAnimation) {
const s = [...a.paths];
r.push(...this.getAnimationPath(s, t));
}
e.push(this.createLine(a.paths, a.symbol, a.attributes, o));
}), 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: n.geographicToWebMercator({
//@ts-ignore
paths: [i],
type: "polyline"
})
}), t.negative && e.push({
attributes: {
color: t.negativeColor
},
geometry: n.geographicToWebMercator({
//@ts-ignore
paths: [i.reverse()],
type: "polyline"
})
}), e;
}
createLine(i, t, e = {}, r) {
const a = {
type: "simple-line",
color: [8, 69, 9, 0.8],
width: 5,
...t
}, o = new p({
paths: i
}), s = n.geographicToWebMercator(o);
return new c({
geometry: s,
// Add the geometry created in step 3
symbol: a,
// Add the symbol created in step 4
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",
// autocasts as new TextSymbol()
color: "white",
haloColor: "black",
haloSize: "1px",
xoffset: 3,
yoffset: 3,
font: {
size: 12,
family: "Josefin Slab",
weight: "bold"
},
...t
}, o = new y({
x: i[0],
y: i[1]
}), s = n.geographicToWebMercator(o);
return new c({
geometry: s,
// Add the geometry created in step 3
symbol: a,
// Add the symbol created in step 4
attributes: {
type: "greenWaveLine-Text",
...e
},
visible: r
});
}
/**
* 隐藏覆盖物
*
* @param {string[]} [ids]
* @memberof GreenWaveLine
*/
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;
});
}
/**
* 显示覆盖物
*
* @param {string[]} [ids]
* @memberof GreenWaveLine
*/
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;
});
}
/**
* 隐藏图层
*
* @memberof GreenWaveLine
*/
hideLayer() {
this.overlayLayer.visible = !1, this.customGreenWaveLineView.visible = !1;
}
/**
* 显示图层
*
* @memberof Overlay
*/
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);
}
}
export {
d as default
};