|
|
@@ -1,18 +1,10 @@
|
|
|
-<!-- -->
|
|
|
+<!-- 设备分布列表 -->
|
|
|
<template>
|
|
|
<div class="inner">
|
|
|
<div class="mapCover">
|
|
|
- <el-amap
|
|
|
- class="bm-view"
|
|
|
- vid="amapDemo"
|
|
|
- :center="center"
|
|
|
- :amap-manager="amapManager"
|
|
|
- :zoom="zoom"
|
|
|
- :plugin="plugin"
|
|
|
- :events="mapEvents"
|
|
|
- >
|
|
|
- <el-amap-marker vid="component-marker" v-if="componentMarker.position.length" :position="componentMarker.position" ></el-amap-marker>
|
|
|
- </el-amap>
|
|
|
+ <div id="map">地图</div>
|
|
|
+ <!-- 弹框关键代码 -->
|
|
|
+ <infoWindowComponent ref="infoWindowComponent"></infoWindowComponent>
|
|
|
</div>
|
|
|
<div class="mapTypebox">
|
|
|
<el-radio-group v-model="mapType" @change="changeMapType">
|
|
|
@@ -83,7 +75,7 @@
|
|
|
<template v-solt:equipStateInner></template>
|
|
|
</equip-info>
|
|
|
<div class="equipData">
|
|
|
- <div class="more" @click="lookmore()">查看更多</div>
|
|
|
+ <div class="more" @click="lookmore()">设备控制</div>
|
|
|
<template>
|
|
|
<el-tabs v-model="activeName" @tab-click="tabshandleClick">
|
|
|
<el-tab-pane
|
|
|
@@ -119,7 +111,7 @@
|
|
|
<template v-solt:equipStateInner></template>
|
|
|
</equip-info>
|
|
|
<div class="equipData">
|
|
|
- <div class="more" @click="lookmore()">查看更多</div>
|
|
|
+ <div class="more" @click="lookmore()">设备控制</div>
|
|
|
<template>
|
|
|
<el-tabs v-model="activeName" @tab-click="tabshandleClick">
|
|
|
<el-tab-pane
|
|
|
@@ -155,7 +147,7 @@
|
|
|
<template v-solt:equipStateInner></template>
|
|
|
</equip-info>
|
|
|
<div class="equipData">
|
|
|
- <div class="more" @click="lookmore()">查看更多</div>
|
|
|
+ <div class="more" @click="lookmore()">设备控制</div>
|
|
|
<template>
|
|
|
<el-tabs v-model="activeName" @tab-click="tabshandleClick">
|
|
|
<el-tab-pane
|
|
|
@@ -191,7 +183,7 @@
|
|
|
<template v-solt:equipStateInner></template>
|
|
|
</equip-info>
|
|
|
<div class="equipData">
|
|
|
- <div class="more" @click="lookmore()">查看更多</div>
|
|
|
+ <div class="more" @click="lookmore()">设备控制</div>
|
|
|
<template>
|
|
|
<el-tabs v-model="activeName" @tab-click="tabshandleClick">
|
|
|
<el-tab-pane
|
|
|
@@ -270,7 +262,7 @@
|
|
|
<template v-solt:equipStateInner></template>
|
|
|
</equip-info>
|
|
|
<div class="equipData">
|
|
|
- <div class="more" @click="lookmore()">查看更多</div>
|
|
|
+ <div class="more" @click="lookmore()">设备控制</div>
|
|
|
<template>
|
|
|
<el-tabs v-model="activeName" @tab-click="tabshandleClick">
|
|
|
<el-tab-pane
|
|
|
@@ -322,8 +314,8 @@
|
|
|
<script>
|
|
|
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
//例如:import 《组件名称》 from '《组件路径》';
|
|
|
-import VueAMap from "vue-amap";
|
|
|
-let amapManager = new VueAMap.AMapManager();
|
|
|
+import AMap from 'AMap';
|
|
|
+import infoWindowComponent from './MapInfoWindow.vue'
|
|
|
import sidebar from "@/components/highStand/sidebar"
|
|
|
import equipList from "@/components/highStand/equipList"
|
|
|
import { bd09togcj02,gcj02tobd09,wgs84togcj02,gcj02towgs84 } from "@/components/home/coordtransform_utils.js"; //纠偏方法
|
|
|
@@ -339,6 +331,7 @@ import cbdTabPestStat from './cbdTabPestStat' //测报灯害虫统计
|
|
|
export default {
|
|
|
//import引入的组件需要注入到对象中才能使用
|
|
|
components: {
|
|
|
+ infoWindowComponent,
|
|
|
sidebar,
|
|
|
equipList,
|
|
|
dialogBox,
|
|
|
@@ -354,63 +347,13 @@ export default {
|
|
|
data() {
|
|
|
//这里存放数据
|
|
|
return {
|
|
|
+ map:null,
|
|
|
+ center:[120.298433, 31.680335],
|
|
|
+ tileLayer1:null,
|
|
|
+ tileLayer2:null,
|
|
|
user_id:'',
|
|
|
sidebarComponents:'',
|
|
|
- amapManager,
|
|
|
- center: [106.323527,29.541514],
|
|
|
- zoom: 5,
|
|
|
mapType: 1,
|
|
|
- plugin: [
|
|
|
- // {
|
|
|
- // pName: "ToolBar",
|
|
|
- // events: {
|
|
|
- // init(instance) {
|
|
|
- // console.log(instance);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
- {
|
|
|
- pName: "Scale",
|
|
|
- events: {
|
|
|
- init(instance) {
|
|
|
- console.log(instance);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // {
|
|
|
- // pName: 'MapType',
|
|
|
- // defaultType: 0,
|
|
|
- // events: {
|
|
|
- // init(instance) {
|
|
|
- // console.log(instance);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- ],
|
|
|
- componentMarker: {
|
|
|
- position: []
|
|
|
- },
|
|
|
- infoWindow: null,
|
|
|
- xyzTileLayer: null,
|
|
|
- xyzTileLayer2: null,
|
|
|
- mapEvents: {
|
|
|
- init: o => {
|
|
|
- this.xyzTileLayer = new AMap.TileLayer({
|
|
|
- // 图块取图地址
|
|
|
- getTileUrl:
|
|
|
- "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=img_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
|
|
|
- zIndex: 100
|
|
|
- });
|
|
|
- this.xyzTileLayer2 = new AMap.TileLayer({
|
|
|
- // 图块取图地址
|
|
|
- getTileUrl:
|
|
|
- "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=cta_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
|
|
|
- zIndex: 101
|
|
|
- });
|
|
|
- o.add(this.xyzTileLayer);
|
|
|
- o.add(this.xyzTileLayer2);
|
|
|
- }
|
|
|
- },
|
|
|
// tabs导航
|
|
|
equipType:[
|
|
|
{
|
|
|
@@ -602,6 +545,47 @@ export default {
|
|
|
},
|
|
|
//方法集合
|
|
|
methods: {
|
|
|
+ // 初始化地图
|
|
|
+ infoMap(){
|
|
|
+ this.map = new AMap.Map("map", {
|
|
|
+ center: this.center,
|
|
|
+ resizeEnable: true,
|
|
|
+ zoom: 4,
|
|
|
+ lang: "en",
|
|
|
+ });
|
|
|
+ AMap.plugin(
|
|
|
+ [
|
|
|
+ "AMap.ToolBar",
|
|
|
+ "AMap.Scale",
|
|
|
+ "AMap.MouseTool",
|
|
|
+ "AMap.Geocoder",
|
|
|
+ "AMap.PolyEditor",
|
|
|
+ ],
|
|
|
+ () => {
|
|
|
+ this.map.addControl(new AMap.ToolBar());
|
|
|
+ this.map.addControl(new AMap.Scale());
|
|
|
+
|
|
|
+ this.geocoder = new AMap.Geocoder({
|
|
|
+ city: "全国",
|
|
|
+ radius: 1000,
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ );
|
|
|
+ this.tileLayer1 = new AMap.TileLayer({
|
|
|
+ tileUrl:
|
|
|
+ "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=img_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
|
|
|
+ zIndex: 10,
|
|
|
+ }); //卫星图层
|
|
|
+ this.tileLayer2 = new AMap.TileLayer({
|
|
|
+ // 图块取图地址
|
|
|
+ tileUrl:
|
|
|
+ "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=cta_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
|
|
|
+ zIndex: 101,
|
|
|
+ });
|
|
|
+ this.map.add(this.tileLayer1);
|
|
|
+ this.map.add(this.tileLayer2);
|
|
|
+ },
|
|
|
getUserEquipType(){
|
|
|
this.$axios({
|
|
|
method: "POST",
|
|
|
@@ -673,14 +657,13 @@ export default {
|
|
|
break;
|
|
|
}
|
|
|
},
|
|
|
- changeMapType(val){
|
|
|
- let o = amapManager.getMap();
|
|
|
+ changeMapType(val){
|
|
|
if(val==0){
|
|
|
- this.xyzTileLayer.hide()
|
|
|
- this.xyzTileLayer2.hide()
|
|
|
+ this.tileLayer1.hide()
|
|
|
+ this.tileLayer2.hide()
|
|
|
}else{
|
|
|
- this.xyzTileLayer.show()
|
|
|
- this.xyzTileLayer2.show()
|
|
|
+ this.tileLayer1.show()
|
|
|
+ this.tileLayer2.show()
|
|
|
}
|
|
|
},
|
|
|
changeEquip(index,item){
|
|
|
@@ -688,7 +671,7 @@ export default {
|
|
|
this.currSelectSite = index;
|
|
|
this.detailsShow = ''
|
|
|
this.searchEquipVal = ''
|
|
|
- this.getEquipList()
|
|
|
+ this.getEquipList(item.type)
|
|
|
},
|
|
|
mouseOve(index,item){
|
|
|
this.equipStyleLeft = 80*index
|
|
|
@@ -723,61 +706,42 @@ export default {
|
|
|
break;
|
|
|
}
|
|
|
},
|
|
|
- getEquipList() {
|
|
|
- this.equipListloading = true;
|
|
|
- this.componentMarker.position = []
|
|
|
- // if(this.infoWindow){
|
|
|
- // this.infoWindow.close()
|
|
|
- // }
|
|
|
- var equip_type = this.currSelectType || '';
|
|
|
- this.setZoom = 4;
|
|
|
+ getEquipList(type) {
|
|
|
this.$axios({
|
|
|
method: "POST",
|
|
|
url: "/api/api_gateway?method=home.homes.equip_map_location",
|
|
|
data: this.qs.stringify({
|
|
|
- equip_type: equip_type,
|
|
|
- device_id:this.searchEquipVal,
|
|
|
+ equip_type: type,
|
|
|
+ device_id: this.searchEquipVal,
|
|
|
user_id:this.user_id
|
|
|
- })
|
|
|
- }).then(res => {
|
|
|
+ }),
|
|
|
+ }).then((res) => {
|
|
|
if (res.data.message == "") {
|
|
|
let data = res.data.data;
|
|
|
- this.equipShow = false;
|
|
|
- this.equips = data.map((item,index) => {
|
|
|
+ this.equipListCurr = data.map((item) => {
|
|
|
this.iconFormat(item.device_type_id, item);
|
|
|
- item.style = item.device_type_id
|
|
|
- if(item.gps_type == 1){ //GPS
|
|
|
- item.lnglat = wgs84togcj02(item.lng,item.lat)
|
|
|
- }else{
|
|
|
- // this.lnglatFormat(item);
|
|
|
+ item.style = item.device_type_id; //设备类型 2杀虫灯,3测报灯,4智能性诱,5气象站,6监控设备,7孢子仪,8性诱设备
|
|
|
+ if (item.gps_type == 1) {
|
|
|
+ //GPS
|
|
|
+ item.lnglat = wgs84togcj02(item.lng, item.lat);
|
|
|
}
|
|
|
- item.index = index
|
|
|
return item;
|
|
|
});
|
|
|
-
|
|
|
- if(this.massMarks){
|
|
|
- this.massMarks.clear()
|
|
|
+ if (this.massMarks) {
|
|
|
+ console.log(this.massMarks);
|
|
|
+
|
|
|
+ this.massMarks.clear();
|
|
|
}
|
|
|
- this.$nextTick(()=>{
|
|
|
- console.log(this.equips)
|
|
|
- this.equipList = this.equips;
|
|
|
- this.equipListloading = false;
|
|
|
- this.equipListCurr = this.equips;
|
|
|
- this.massMarks = new AMap.MassMarks(this.equips, {
|
|
|
- zIndex: 199, // 海量点图层叠加的顺序
|
|
|
- zooms: [3, 19], // 在指定地图缩放级别范围内展示海量点图层
|
|
|
- style: this.equipStyleObject // 设置样式对象
|
|
|
- });
|
|
|
- var o = amapManager.getMap();
|
|
|
- this.massMarks.setMap(o)
|
|
|
- this.massMarks.on('click',e =>{
|
|
|
- this.$nextTick(()=>{
|
|
|
- document.getElementById("equipListBox").scrollTop = 87*e.data.index;
|
|
|
-
|
|
|
- this.equipMarkerClick(e.data)
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
+ this.massMarks = new AMap.MassMarks(this.equipListCurr, {
|
|
|
+ zIndex: 199, // 海量点图层叠加的顺序
|
|
|
+ zooms: [3, 19], // 在指定地图缩放级别范围内展示海量点图层
|
|
|
+ style: this.equipStyleObject, // 设置样式对象
|
|
|
+ });
|
|
|
+ this.massMarks.setMap(this.map);
|
|
|
+ this.massMarks.on("click", (e) => {
|
|
|
+ this.equipMarkerClick(e.data);
|
|
|
+ // this.openInfo(e.data);
|
|
|
+ });
|
|
|
} else {
|
|
|
this.$message.error(res.data.message);
|
|
|
}
|
|
|
@@ -852,6 +816,27 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ 打开消息窗体
|
|
|
+ 我这边实现的是点击marker事件后,弹出消息框
|
|
|
+ 注:positionResult 为marker点击事件的 event
|
|
|
+ */
|
|
|
+ openInfo(positionResult) {
|
|
|
+ var that = this;
|
|
|
+ let infoWindow = new AMap.InfoWindow({
|
|
|
+ isCustom: true,
|
|
|
+ content: that.$refs.infoWindowComponent.$el,
|
|
|
+ offset: new AMap.Pixel(5, -11),
|
|
|
+ });
|
|
|
+ infoWindow.open(this.map, positionResult.lnglat);
|
|
|
+ this.infoWindow = infoWindow;
|
|
|
+ // 调用组件方法,初始化组件页面的infoWindow等数据
|
|
|
+ that.$refs.infoWindowComponent.initialize({
|
|
|
+ currEquip: positionResult,
|
|
|
+ visible: true,
|
|
|
+ infoWindow: infoWindow,
|
|
|
+ });
|
|
|
+ },
|
|
|
//关闭方向
|
|
|
stopConfigCamera() {
|
|
|
this.$axios({
|
|
|
@@ -951,7 +936,7 @@ export default {
|
|
|
this.nowPage = tab.name;
|
|
|
|
|
|
},
|
|
|
- // 查看更多控制
|
|
|
+ // 设备控制控制
|
|
|
lookmore(){
|
|
|
this.sidebarComponents = 'sidebar'
|
|
|
this.detailsShow=""
|
|
|
@@ -968,6 +953,8 @@ export default {
|
|
|
this.user_id = this.$store.state.user_id || sessionStorage.getItem("myuid");
|
|
|
this.getUserEquipType()
|
|
|
this.changeEquip(0,this.equipType[0])
|
|
|
+ this.infoMap()
|
|
|
+
|
|
|
},
|
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
|
beforeMount() {}, //生命周期 - 挂载之前
|
|
|
@@ -986,6 +973,10 @@ export default {
|
|
|
position: relative;
|
|
|
.mapCover{
|
|
|
height: 100%;
|
|
|
+ #map{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
}
|
|
|
.mapTypebox{
|
|
|
position: absolute;
|