UNPKG

gisviewer-vue3-arcgis

Version:

在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:

85 lines (84 loc) 2.44 kB
import u from "ol/Feature"; import { LineString as g } from "ol/geom"; import m from "ol/layer/Vector"; import y from "ol/source/Vector"; import { Style as d, Stroke as h } from "ol/style"; class I { constructor(e) { this.map = e, this.roadSource = new y(), this.roadLayer = new m({ source: this.roadSource }), this.roadLayer.set("id", "sub-district-road-layer"), this.map.addLayer(this.roadLayer); } async addSubDistricts(e) { this.roadSource.clear(); const s = []; e.forEach((r) => { s.push(...r.roadConnections), r.subDistricts.forEach((o) => { s.push(...o.roadConnections); }); }), s.forEach((r) => { const o = r.color || [111, 100, 255], c = `rgb(${o[0]}, ${o[1]}, ${o[2]})`, t = new u({ geometry: new g(r.coordinates) }); t.setStyle( new d({ stroke: new h({ color: c, width: 2 }) }) ), t.setId(r.id), t.set("type", "sub-district-road"), t.set("subDistrictId", r.subDistrictId), t.set("districtId", r.districtId), t.set("originalColor", c), this.roadSource.addFeature(t); }); } setVisible(e) { this.roadLayer.setVisible(e); } clear() { this.roadSource.clear(); } highlight(e) { var c; const s = e.id, r = e.type === "district" ? "districtId" : "subDistrictId", o = []; if (this.roadSource.getFeatures().forEach((t) => { if (t.get(r) === s) { const a = t.get("originalColor"); a && t.setStyle( new d({ stroke: new h({ color: a, width: 2 }) }) ), o.push(t); } else t.setStyle(new d({})); }), o.length > 0) { const t = (c = o[0].getGeometry()) == null ? void 0 : c.getExtent(); if (t) { const i = [...t]; return o.slice(1).forEach((a) => { var l; const n = (l = a.getGeometry()) == null ? void 0 : l.getExtent(); n && (i[0] = Math.min(i[0], n[0]), i[1] = Math.min(i[1], n[1]), i[2] = Math.max(i[2], n[2]), i[3] = Math.max(i[3], n[3])); }), i; } } return null; } clearHighlight() { this.roadSource.getFeatures().forEach((e) => { const s = e.get("originalColor"); s && e.setStyle( new d({ stroke: new h({ color: s, width: 2 }) }) ); }); } } export { I as default };