Browse Source

[完善]gismap页面优化

beijing
邵佳豪 1 year ago
parent
commit
eac4dd4613
  1. 15
      src/app/pages/gis-home/gis-home.component.html
  2. 245
      src/app/pages/gis-home/gis-home.component.ts
  3. 2
      src/app/pages/gis-home/unit-title/unit-title.component.html
  4. 25
      src/styles.scss

15
src/app/pages/gis-home/gis-home.component.html

@ -5,19 +5,19 @@
<div class="left1 cardItem"
(click)="urlTo('http://121.36.37.70:8201/planManagement/entryPlan?singleSignOn=true')">
<app-card-title [title]="'预案统计'" [subtitle]="'Plan statistics'"></app-card-title>
<app-unit-title [num]="33" (childEvent)="handleChildData($event)"></app-unit-title>
<app-unit-title [num]="21250" (childEvent)="handleChildData($event)"></app-unit-title>
<div class="content">
<div id="echartleft1"></div>
</div>
</div>
<div class="left2 cardItem">
<div class="left2 cardItem" (click)="aHref($event,'ax://startup')">
<app-card-title [title]="'演练统计'" [subtitle]="'Exercise statistics'"></app-card-title>
<app-unit-title [num]="33"></app-unit-title>
<app-unit-title [num]="126"></app-unit-title>
<div class="content">
<div id="echartleft2"></div>
</div>
</div>
<div class="left3 cardItem">
<div class="left3 cardItem" (click)="aHref($event,'ax2://startup')">
<app-card-title [title]="'风险管控平台统计'" [subtitle]="'Risk management'"></app-card-title>
<app-unit-title [num]="33"></app-unit-title>
<div class="content">
@ -26,8 +26,7 @@
</div>
</div>
<div class="rightBox">
<div class="right1 cardItem" (click)="urlTo('http://localhost:1119/homepage?singleSignOn=true')">
<div class="right1 cardItem" (click)="urlTo('http://121.36.37.70:8906/homepage?singleSignOn=true')">
<app-card-title [title]="'接入类型'" [subtitle]="'Intervention type'"></app-card-title>
<div class="content">
<div class="accessList">
@ -43,14 +42,14 @@
</div>
</div>
</div>
<div class="right2 cardItem" (click)="urlTo('http://localhost:1119/todaywarning?singleSignOn=true')">
<div class="right2 cardItem" (click)="urlTo('http://121.36.37.70:8906/todaywarning?singleSignOn=true')">
<app-card-title [title]="'预警统计'" [subtitle]="'Warning statistics'"></app-card-title>
<div class="content">
<div id="echartright1"></div>
</div>
</div>
<div class="right3 cardItem"
(click)="urlTo('http://localhost:1119/records_nav/oliunloadinglist?singleSignOn=true')">
(click)="urlTo('http://121.36.37.70:8906/records_nav/oliunloadinglist?singleSignOn=true')">
<app-card-title [title]="'卸油事件'" [subtitle]="'Oil unloading event'"></app-card-title>
<div class="content">
<div id="echartright2"></div>

245
src/app/pages/gis-home/gis-home.component.ts

@ -1,4 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import * as echarts from "echarts";
declare var T: any;
@Component({
@ -7,29 +8,32 @@ declare var T: any;
styleUrls: ["./gis-home.component.scss"],
})
export class GisHomeComponent implements OnInit {
constructor() {}
constructor(private sanitizer: DomSanitizer) {}
ngOnInit(): void {
this.createLabelSContent(this.markerList);
this.initMap();
this.initEcharts();
console.log(this.markerList);
}
echartleft1;
echartleft1Data = [
{ value: 1312, name: "综合应急预案" },
{ value: 1583, name: "专项应急预案" },
{ value: 1235, name: "现场处置方案" },
{ value: 1852, name: "应急处置卡" },
{ value: 3152, name: "现场处置方案" },
{ value: 5421, name: "应急处置卡" },
{ value: 1735, name: "应急预案" },
{ value: 1258, name: "类型预案" },
{ value: 600, name: "I-V级预案" },
{ value: 19150, name: "I-V级预案" },
];
echartleft1Option = {
tooltip: {
trigger: "item",
},
title: {
text: "9,333",
text: "33,611",
subtext: "预案总数",
left: "28.5%",
x: "center",
@ -227,17 +231,17 @@ export class GisHomeComponent implements OnInit {
};
echartleft2;
echartleft2Data = [
{ value: 3523, name: "综合演练" },
{ value: 2560, name: "跨区域演练" },
{ value: 345, name: "综合演练" },
{ value: 21, name: "跨区域演练" },
{ value: 853, name: "单项演练" },
{ value: 1237, name: "研究性演练" },
{ value: 12, name: "研究性演练" },
];
echartleft2Option = {
tooltip: {
trigger: "item",
},
title: {
text: "8,173",
text: "1,231",
subtext: "演练总数",
left: "28.5%",
x: "center",
@ -445,7 +449,7 @@ export class GisHomeComponent implements OnInit {
trigger: "item",
},
title: {
text: "9,173",
text: "8,173",
subtext: "隐患总数",
left: "28.5%",
x: "center",
@ -1133,17 +1137,157 @@ export class GisHomeComponent implements OnInit {
map;
zoom = 5;
markerList = [
{ marker: null, coordinate: [98.56934, 38.93555] },
{ marker: null, coordinate: [97.0752, 32.95898] },
{ marker: null, coordinate: [103.88672, 22.89551] },
{ marker: null, coordinate: [108.41309, 29.79492] },
markerList: any = [
{
id: 0,
name: "天津",
marker: null,
label: null,
coordinate: [117.42188, 38.14453],
data: {
station: 5,
oilDepot: 5,
chemical: 22,
enterprise: 74,
},
},
{
id: 1,
name: "北京",
marker: null,
label: null,
coordinate: [116.39465, 39.88586],
data: {
station: 9,
oilDepot: 1,
chemical: 1,
enterprise: 116,
},
},
{
id: 2,
name: "上海",
marker: null,
label: null,
coordinate: [121.46759, 31.20392],
data: {
station: 131,
oilDepot: 99,
chemical: 172,
enterprise: 19191,
},
},
{
id: 3,
name: "湖北",
marker: null,
label: null,
coordinate: [112.45605, 30.27832],
data: {
station: 0,
oilDepot: 2,
chemical: 6,
enterprise: 34,
},
},
{
id: 4,
name: "湖南",
marker: null,
label: null,
coordinate: [111.62109, 26.93848],
data: {
station: 30,
oilDepot: 2,
chemical: 3,
enterprise: 44,
},
},
{
id: 5,
name: "广东",
marker: null,
label: null,
coordinate: [113.37891, 22.76367],
data: {
station: 42,
oilDepot: 0,
chemical: 1,
enterprise: 23,
},
},
{
id: 6,
name: "广西",
marker: null,
label: null,
coordinate: [108.76465, 22.71973],
data: {
station: 4,
oilDepot: 5,
chemical: 29,
enterprise: 91,
},
},
{
id: 7,
name: "福建",
marker: null,
label: null,
coordinate: [118.21289, 25.22461],
data: {
station: 108,
oilDepot: 0,
chemical: 0,
enterprise: 0,
},
},
];
createLabelSContent(list) {
list.forEach((element) => {
let totalString = this.numberProcess(this.sumValues(element.data));
element.sContent1 = `<div class='markerTotal'> ${totalString} </div>`;
element.sContent2 = "<div class='markerInfoWin'>";
for (const key in element.data) {
if (Object.prototype.hasOwnProperty.call(element.data, key)) {
const item = element.data[key];
if (item !== 0) {
switch (key) {
case "station":
element.sContent2 += `<div class='icon icon1'><img src='../../../assets/gismap/gis/1.png' alt=''></div><div class='num'> ${item} </div>`;
break;
case "oilDepot":
element.sContent2 += `<div class='icon icon2'><img src='../../../assets/gismap/gis/2.png' alt=''></div><div class='num'> ${item} </div>`;
break;
case "chemical":
element.sContent2 += `<div class='icon icon3'><img src='../../../assets/gismap/gis/3.png' alt=''></div><div class='num'> ${item} </div>`;
break;
case "enterprise":
element.sContent2 += `<div class='icon icon4'><img src='../../../assets/gismap/gis/4.png' alt=''></div><div class='num'> ${item} </div>`;
break;
default:
break;
}
}
}
}
element.sContent2 += "</div>";
});
}
selectedMarker = null;
PointOffset1 = [-25, -53]; //markerlabel偏移量
PointOffset2 = [-28, -65];
initMap() {
this.map = new T.Map("mapDiv", {
projection: "EPSG:4326",
});
this.map.centerAndZoom(new T.LngLat(107.79785, 35.77148), this.zoom);
this.map.centerAndZoom(new T.LngLat(116.2793, 32.95898), this.zoom);
//创建图片对象
var icon = new T.Icon({
iconUrl: "../../../assets/gismap/gis/marker.png",
@ -1160,34 +1304,75 @@ export class GisHomeComponent implements OnInit {
);
//向地图上添加标注
this.map.addOverLay(element.marker);
let sContent =
"<div class='markerInfoWin'><div class='icon icon1'><img src='../../../assets/gismap/gis/1.png' alt=''></div><div class='num'> 36 </div><div class='icon icon2'><img src='../../../assets/gismap/gis/2.png' alt=''></div><div class='num'> 36 </div><div class='icon icon3'><img src='../../../assets/gismap/gis/3.png' alt=''></div><div class='num'> 36 </div><div class='icon icon4'><img src='../../../assets/gismap/gis/4.png' alt=''></div><div class='num'> 36 </div></div>";
// infoWin1.setContent(sContent);
// let infoWin1 = new T.InfoWindow(sContent, {
// closeButton: false,
// });
// element.marker.openInfoWindow(infoWin1);s
let label = new T.Label({
text: sContent,
element.marker.addEventListener("click", (event) => {
this.markerClick(element);
});
element.label = new T.Label({
text: element.sContent1,
position: element.marker.getLngLat(),
offset: new T.Point(-28, -65),
offset: new T.Point(this.PointOffset1[0], this.PointOffset1[1]),
});
this.map.addOverLay(label);
this.map.addOverLay(element.label);
});
this.map.addEventListener("click", (e) => {
this.MapClick(e);
});
}
//数字加工 ,
numberProcess(num) {
if (num.toString().length > 3) {
return num.toLocaleString();
}
return num.toString();
}
//对象求和
sumValues(obj) {
let sum = 0;
for (let key in obj) {
if (typeof obj[key] === "number") {
sum += obj[key];
}
}
return sum;
}
//地图点击事件
MapClick(e) {
console.log("点击坐标:", e.lnglat.getLng() + "," + e.lnglat.getLat());
this.markerList.forEach((element) => {
element.label.setLabel(element.sContent1);
element.label.setOffset(
new T.Point(this.PointOffset1[0], this.PointOffset1[1])
);
});
}
//标注点 点击事件
markerClick(item) {
console.log("标注点击", item);
// // this.selectedMarker = element;
// // this.selectedMarker.label.setLabel("");
this.markerList.forEach((element) => {
element.label.setLabel(element.sContent1);
element.label.setOffset(
new T.Point(this.PointOffset1[0], this.PointOffset1[1])
);
});
item.label.setLabel(item.sContent2);
item.label.setOffset(
new T.Point(this.PointOffset2[0], this.PointOffset2[1])
);
}
urlTo(url) {
window.open(url);
}
aHref(e, url) {
e.preventDefault(); // 阻止默认行为
let aHrefUnsafe = this.sanitizer.bypassSecurityTrustUrl(url);
// console.log("aHrefUnsafe", aHrefUnsafe);
window.location.href = url; // 执行链接的跳转行为
}
unitList1 = ["广西有限公司", "重庆有限公司", "柳州有限公司"];
unitList2 = [
"芯恩集成电路有限公司",

2
src/app/pages/gis-home/unit-title/unit-title.component.html

@ -2,5 +2,5 @@
<div class="numbox">
截至{{time}} , 已接入单位数 : <div class="num" *ngFor="let item of numArr">{{item}}</div>
</div>
<button class="btn" (click)="select($event)">选择</button>
<!-- <button class="btn" (click)="select($event)">选择</button> -->
</div>

25
src/styles.scss

@ -400,9 +400,7 @@ ul {
.markerInfoWin {
position: absolute;
left: 50%;
top: 50%;
z-index: 500;
z-index: 999;
display: flex;
overflow: hidden;
border-radius: 4px;
@ -446,8 +444,27 @@ ul {
}
.num {
height: 36px;
width: 40px;
// width: 40px;
box-sizing: border-box;
padding: 0 13px;
font-size: 16px;
background: RGBA(44, 60, 103, 0.9);
}
}
.markerTotal {
color: #00f6ff;
border: 1px solid #43b0d5;
background: rgba(67, 86, 91, 0.8);
position: absolute;
left: 50%;
z-index: 100;
top: 50%;
font-size: 15px;
line-height: 25px;
box-sizing: border-box;
padding: 0px 5px;
border-radius: 3px;
}
.tdt-marker-pane {
z-index: 399 !important;
}

Loading…
Cancel
Save