|
@@ -35,42 +35,43 @@ import mapIconCamera from "../assets/images/map-icon-camera.png";
|
|
import mapIconMicstation from "../assets/images/map-icon-micstation.png";
|
|
import mapIconMicstation from "../assets/images/map-icon-micstation.png";
|
|
import mapIconStation from "../assets/images/map-icon-119.png";
|
|
import mapIconStation from "../assets/images/map-icon-119.png";
|
|
import mapIconFire from "../assets/images/map-icon-fire.png";
|
|
import mapIconFire from "../assets/images/map-icon-fire.png";
|
|
-
|
|
|
|
|
|
+import { getZy } from "@/api/map.js";
|
|
export default {
|
|
export default {
|
|
name: "MapContainer",
|
|
name: "MapContainer",
|
|
components: {},
|
|
components: {},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ radius: 500,
|
|
center: [],
|
|
center: [],
|
|
markers: [],
|
|
markers: [],
|
|
firePoint: null,
|
|
firePoint: null,
|
|
icons: {
|
|
icons: {
|
|
- build: {
|
|
|
|
|
|
+ jzKey: {
|
|
image: mapIconBuild,
|
|
image: mapIconBuild,
|
|
size: [43, 60],
|
|
size: [43, 60],
|
|
imageSize: [43, 60],
|
|
imageSize: [43, 60],
|
|
},
|
|
},
|
|
- pressure: {
|
|
|
|
|
|
+ waterKey: {
|
|
image: mapIconPressure,
|
|
image: mapIconPressure,
|
|
size: [43, 60],
|
|
size: [43, 60],
|
|
imageSize: [43, 60],
|
|
imageSize: [43, 60],
|
|
},
|
|
},
|
|
- car: {
|
|
|
|
|
|
+ xfcKey: {
|
|
image: mapIconCar,
|
|
image: mapIconCar,
|
|
size: [70, 46],
|
|
size: [70, 46],
|
|
imageSize: [70, 46],
|
|
imageSize: [70, 46],
|
|
},
|
|
},
|
|
- camera: {
|
|
|
|
|
|
+ lldKey: {
|
|
image: mapIconCamera,
|
|
image: mapIconCamera,
|
|
size: [69, 69],
|
|
size: [69, 69],
|
|
imageSize: [69, 69],
|
|
imageSize: [69, 69],
|
|
},
|
|
},
|
|
- micstation: {
|
|
|
|
|
|
+ xfzKey: {
|
|
image: mapIconMicstation,
|
|
image: mapIconMicstation,
|
|
size: [99, 107],
|
|
size: [99, 107],
|
|
imageSize: [99, 107],
|
|
imageSize: [99, 107],
|
|
},
|
|
},
|
|
- station: {
|
|
|
|
|
|
+ jgKey: {
|
|
image: mapIconStation,
|
|
image: mapIconStation,
|
|
size: [99, 107],
|
|
size: [99, 107],
|
|
imageSize: [99, 107],
|
|
imageSize: [99, 107],
|
|
@@ -83,61 +84,83 @@ export default {
|
|
type: Number,
|
|
type: Number,
|
|
default: 1,
|
|
default: 1,
|
|
},
|
|
},
|
|
|
|
+ data: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: null,
|
|
|
|
+ },
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
this.getData();
|
|
this.getData();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- getData() {
|
|
|
|
- console.log(this.id);
|
|
|
|
|
|
+ async getData() {
|
|
// to-do
|
|
// to-do
|
|
// 通过id调用接口获取数据
|
|
// 通过id调用接口获取数据
|
|
- // 地图中心
|
|
|
|
- this.center = [105.602725, 37.076636];
|
|
|
|
- // 标志物
|
|
|
|
- this.markers = [
|
|
|
|
- {
|
|
|
|
- icon: "build",
|
|
|
|
- position: [105.582725, 37.076636],
|
|
|
|
- anchor: "bottom-center",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- icon: "pressure",
|
|
|
|
- position: [105.612725, 37.06636],
|
|
|
|
- anchor: "bottom-center",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- icon: "car",
|
|
|
|
- position: [105.602725, 37.079636],
|
|
|
|
- anchor: "bottom-center",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- icon: "camera",
|
|
|
|
- position: [105.604725, 37.089636],
|
|
|
|
- anchor: "bottom-center",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- icon: "micstation",
|
|
|
|
- position: [105.605725, 37.069636],
|
|
|
|
- anchor: "bottom-center",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- icon: "station",
|
|
|
|
- position: [105.606725, 37.079636],
|
|
|
|
- anchor: "bottom-center",
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
// 着火点
|
|
// 着火点
|
|
this.firePoint = {
|
|
this.firePoint = {
|
|
- position: [105.602725, 37.076636],
|
|
|
|
- buildName: "地矿大厦1栋",
|
|
|
|
- depts: ["1楼:存在大量氧气罐", "2楼:存在乙醇、乙丙等可燃物品"],
|
|
|
|
|
|
+ position: [this.data.jd, this.data.wd],
|
|
|
|
+ buildName: this.data.jzmc,
|
|
|
|
+ depts: this.data.zl ? this.data.zl.split(",") : [],
|
|
};
|
|
};
|
|
|
|
|
|
if (this.firePoint) {
|
|
if (this.firePoint) {
|
|
this.center = this.firePoint.position;
|
|
this.center = this.firePoint.position;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 标志物
|
|
|
|
+ const markers = [];
|
|
|
|
+ const res = await getZy({
|
|
|
|
+ lon: this.data.jd,
|
|
|
|
+ lat: this.data.wd,
|
|
|
|
+ mi: this.radius,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // console.log(res);
|
|
|
|
+ if (res.data) {
|
|
|
|
+ res.data.forEach((p) => {
|
|
|
|
+ if (p.lon && p.lat) {
|
|
|
|
+ markers.push({
|
|
|
|
+ icon: p.type,
|
|
|
|
+ position: [p.lon, p.lat],
|
|
|
|
+ anchor: "bottom-center",
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ this.markers = markers;
|
|
|
|
+
|
|
|
|
+ // this.markers = [
|
|
|
|
+ // {
|
|
|
|
+ // icon: "jzKey",
|
|
|
|
+ // position: [106.43885760313785, 29.829438307353094],
|
|
|
|
+ // anchor: "bottom-center",
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // icon: "waterKey",
|
|
|
|
+ // position: [105.612725, 37.06636],
|
|
|
|
+ // anchor: "bottom-center",
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // icon: "xfcKey",
|
|
|
|
+ // position: [105.602725, 37.079636],
|
|
|
|
+ // anchor: "bottom-center",
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // icon: "lldKey",
|
|
|
|
+ // position: [105.604725, 37.089636],
|
|
|
|
+ // anchor: "bottom-center",
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // icon: "xfzKey",
|
|
|
|
+ // position: [105.605725, 37.069636],
|
|
|
|
+ // anchor: "bottom-center",
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // icon: "jgKey",
|
|
|
|
+ // position: [105.606725, 37.079636],
|
|
|
|
+ // anchor: "bottom-center",
|
|
|
|
+ // },
|
|
|
|
+ // ];
|
|
this.initMap();
|
|
this.initMap();
|
|
},
|
|
},
|
|
initMap() {
|
|
initMap() {
|
|
@@ -150,15 +173,18 @@ export default {
|
|
this.map = new AMap.Map("map-container", {
|
|
this.map = new AMap.Map("map-container", {
|
|
//设置地图容器id
|
|
//设置地图容器id
|
|
// viewMode: "3D", //是否为3D地图模式
|
|
// viewMode: "3D", //是否为3D地图模式
|
|
- zoom: 15, //初始化地图级别
|
|
|
|
|
|
+ zoom: 17, //初始化地图级别
|
|
center: this.center, //初始化地图中心点位置
|
|
center: this.center, //初始化地图中心点位置
|
|
mapStyle: "amap://styles/grey",
|
|
mapStyle: "amap://styles/grey",
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // console.log(this.markers)
|
|
|
|
+
|
|
// 设置覆盖物
|
|
// 设置覆盖物
|
|
if (this.markers && this.markers.length > 0) {
|
|
if (this.markers && this.markers.length > 0) {
|
|
- this.markers.forEach((p) => {
|
|
|
|
- const icon = this.icons[p.icon];
|
|
|
|
|
|
+ const markers = [];
|
|
|
|
+ this.markers.forEach((p, i) => {
|
|
|
|
+ const icon = JSON.parse(JSON.stringify(this.icons[p.icon]));
|
|
icon.size = new AMap.Size(icon.size[0], icon.size[1]);
|
|
icon.size = new AMap.Size(icon.size[0], icon.size[1]);
|
|
icon.imageSize = new AMap.Size(
|
|
icon.imageSize = new AMap.Size(
|
|
icon.imageSize[0],
|
|
icon.imageSize[0],
|
|
@@ -166,14 +192,18 @@ export default {
|
|
);
|
|
);
|
|
p.icon = new AMap.Icon(icon);
|
|
p.icon = new AMap.Icon(icon);
|
|
var marker = new AMap.Marker(p);
|
|
var marker = new AMap.Marker(p);
|
|
- this.map.add(marker);
|
|
|
|
|
|
+ // // this.map.add(marker);
|
|
|
|
+ markers.push(marker);
|
|
});
|
|
});
|
|
|
|
+ this.map.add(markers);
|
|
}
|
|
}
|
|
|
|
|
|
// 设置着火点
|
|
// 设置着火点
|
|
if (this.firePoint) {
|
|
if (this.firePoint) {
|
|
this.addFirePoint();
|
|
this.addFirePoint();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this.map.setFitView();
|
|
})
|
|
})
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
console.log(e);
|
|
console.log(e);
|
|
@@ -201,7 +231,7 @@ export default {
|
|
this.firePoint.position[0],
|
|
this.firePoint.position[0],
|
|
this.firePoint.position[1]
|
|
this.firePoint.position[1]
|
|
), // 圆心位置
|
|
), // 圆心位置
|
|
- radius: 800, // 半径
|
|
|
|
|
|
+ radius: this.radius, // 半径
|
|
strokeColor: "rgba(255, 0, 61)", // 线颜色
|
|
strokeColor: "rgba(255, 0, 61)", // 线颜色
|
|
strokeOpacity: 0.6, // 线透明度
|
|
strokeOpacity: 0.6, // 线透明度
|
|
strokeWeight: 1, // 线粗细度
|
|
strokeWeight: 1, // 线粗细度
|
|
@@ -233,6 +263,17 @@ export default {
|
|
this.map.clearInfoWindow();
|
|
this.map.clearInfoWindow();
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ watch: {
|
|
|
|
+ data: {
|
|
|
|
+ handler() {
|
|
|
|
+ if (this.map) {
|
|
|
|
+ this.map.clearInfoWindow();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ immediate: true,
|
|
|
|
+ deep: true,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
@@ -245,7 +286,7 @@ export default {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|
|
padding: 0;
|
|
padding: 0;
|
|
- margin: 0;
|
|
|
|
|
|
+ margin: 0;
|
|
background-color: #070b13 !important;
|
|
background-color: #070b13 !important;
|
|
background-image: none;
|
|
background-image: none;
|
|
}
|
|
}
|