Commit 2917f8e2 by wangzhihui

高德地图切换成百度地图

1 parent 2df36f38
......@@ -10,8 +10,8 @@ function request (data = {} , url, method = 'GET') {
url: url,
data: data,
success(data) {
console.log(data)
console.log('结束请求:',new Date().getTime())
// console.log(data)
// console.log('结束请求:',new Date().getTime())
resolve(data)
},
error(error) {
......
<!--
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-09 22:18:27
* @FilePath: \oEshield\src\pages\monitor\MapControll.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div>
<div :class="isTreeToright ? 'map-controll toleft' : 'map-controll'">
......@@ -19,7 +27,7 @@
</template>
<script>
import store from '../../vuex/store.js'
import mapService from 'utils/mapService.js'
import mapService from 'utils/mapBService.js'
export default{
props: ['isShowFullsize', 'isTreeToright'],
data(){
......@@ -43,7 +51,7 @@
},
toggleMap(ifSetTypeIsMap){
if(ifSetTypeIsMap != this.isMapType){
mapService.toggleMapType();
mapService.toggleMapType(ifSetTypeIsMap);
this.isMapType = !this.isMapType;
}
},
......
......@@ -39,7 +39,8 @@
</v-full-layout>
</template>
<script>
import mapService from "@/utils/mapService.js";
// import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js";
import EventBus from "@/event-bus";
import remoteLoad from "@/utils/remoteLoad.js";
......@@ -59,57 +60,41 @@ export default {
};
},
created() {
console.log(history.state);
let _this = this;
_this.$mapInit({ }).then((AMap) => {
_this.initMap();
});
// let _this = this;
// _this.$mapInit({ }).then((AMap) => {
// _this.initMap();
// });
this.initBMap();
},
methods: {
// 初始化地图
initMap() {
let check = () => {
if (this.checkLoadedTimeoutId) {
window.clearTimeout(this.checkLoadedTimeoutId);
}
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
this.isInitMap = true;
let query = this.$route.query;
let o = history.state;
async initBMap() {
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.isInitMap = true;
let query = this.$route.query;
let o = history.state;
// 假性离线报警查看位置点
if (query.sns) {
this.getLocation(query.sns);
return false;
}
console.log(query);
// 假性离线报警查看位置点
if (query.sns) {
this.getLocation(query.sns);
return false;
}
// 兼容其他页面的跳转
if (query && query.sn) {
query.elat = query.lat;
query.elng = query.lng;
this.addLocation(query, true);
return false;
}
// 兼容其他页面的跳转
if (query && query.sn) {
query.elat = query.lat;
query.elng = query.lng;
this.addLocation(query, true);
return false;
}
console.log(o);
if (o.lng || o.bsLng) {
o.elat = o.lat;
o.elng = o.lng;
this.addLocation(o, true);
}
} else {
this.checkLoadedTimeoutId = check();
}
}, 100);
};
this.checkLoadedTimeoutId = check();
console.log(o);
if (o.lng || o.bsLng) {
o.elat = o.lat;
o.elng = o.lng;
this.addLocation(o, true);
}
},
// 添加位置点
......@@ -125,7 +110,6 @@ export default {
oParams.deviceCode = "gps";
GET_DEVICEINFO_BYSNS(oParams).then((res) => {
let list = res.data || [];
// 循环标记车辆
list.map((k) => {
let o = this.getMapInfo(k);
......
<template>
<div>
<!-- 围栏调用地图弹框 -->
<div class="ibox-content" style="height: 500px; padding:0 10px;z-index: 100">
<fence-map :mapData="mapData" @onUpdateMapData="updateMapData" :readonlyStatus="readonlyStatus" ref="fenceMap">
<div
class="ibox-content"
style="height: 500px; padding: 0 10px; z-index: 100"
>
<fence-map
:mapData="mapData"
@onUpdateMapData="updateMapData"
:readonlyStatus="readonlyStatus"
ref="fenceMap"
>
</fence-map>
</div>
<!-- 围栏调用地图弹框 /-->
......@@ -12,7 +20,7 @@
<div class="fold_btn" @click="foldEvent">
<i class="el-icon-arrow-down" v-if="showContent"></i>
<i class="el-icon-arrow-up" v-else></i>
<span>{{showContent?'收起':'展开'}}</span>
<span>{{ showContent ? "收起" : "展开" }}</span>
</div>
</div>
<el-collapse-transition>
......@@ -20,66 +28,157 @@
<div class="tab_wrap">
<el-tabs type="card" v-show="hideTab">
<el-tab-pane label="围栏基础信息">
<div class="ibox-content scrollbar" style="padding: 30px 20px;">
<el-form ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px" class="fence_form" align="left">
<div class="ibox-content scrollbar" style="padding: 30px 20px">
<el-form
ref="fenceForm"
:model="form"
:rules="rules"
:inline="false"
size="mini"
label-width="100px"
class="fence_form"
align="left"
>
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" minlength="2" maxlength="200" show-word-limit :disabled="readonlyStatus"></el-input>
<el-input
v-model.trim="form.fenceName"
placeholder="请输入围栏名称"
minlength="2"
maxlength="200"
show-word-limit
:disabled="readonlyStatus"
></el-input>
</el-form-item>
<el-form-item label="监控类型" prop="triggerType">
<el-select v-model="form.triggerType" placeholder="请选择" size="small">
<el-select
v-model="form.triggerType"
placeholder="请选择"
size="small"
>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入驶出" :value="3" v-if="form.source == 1"></el-option>
<el-option
label="驶入驶出"
:value="3"
v-if="form.source == 1"
></el-option>
<!-- v1.25.0版本需求,驶入驶出监控类型只有有线设备才有 -->
</el-select>
</el-form-item>
<el-form-item label="围栏类型" prop="bizFenceType">
<el-radio :label="14" v-model="form.bizFenceType">报警型</el-radio>
<el-radio :label="14" v-model="form.bizFenceType"
>报警型</el-radio
>
</el-form-item>
<el-form-item label="监控周期" prop="timeType">
<el-radio-group v-model="form.timeType" @change="changeTimeType">
<el-radio-group
v-model="form.timeType"
@change="changeTimeType"
>
<el-radio :label="1">永久有效</el-radio>
<el-radio :label="2">指定区间</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="指定区间" class="is-required" prop="dateRange" v-if="form.timeType == 2">
<el-date-picker v-model="form.dateRange" type="daterange" size="small" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
<el-form-item
label="指定区间"
class="is-required"
prop="dateRange"
v-if="form.timeType == 2"
>
<el-date-picker
v-model="form.dateRange"
type="daterange"
size="small"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<el-form-item label="区域类型" class="is-required">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange">
<el-radio-group
v-model="form.shapeType"
@change="shapeTypeChange"
>
<el-radio-button label="1">圆形</el-radio-button>
<el-radio-button label="3">多边形</el-radio-button>
<el-radio-button label="4">行政区域</el-radio-button>
</el-radio-group>
<div class="shape_tip" v-show="form.shapeType==3">*注:地图任意位置,单击新增双击结束绘制。</div>
<div class="shape_tip" v-show="form.shapeType == 3">
*注:地图任意位置,单击新增双击结束绘制。
</div>
</el-form-item>
<el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
<el-input
v-model.trim="form.telNumbers"
maxlength="100"
placeholder="输入格式:手机号码,手机号码(支持双号)"
></el-input>
</el-form-item>
<el-form-item label="围栏半径" prop="radius" v-if="form.shapeType == 1">
<el-form-item
label="围栏半径"
prop="radius"
v-if="form.shapeType == 1"
>
<div class="radius_box">
<el-input placeholder="请输入围栏半径" v-model.trim="form.radius">
<el-input
placeholder="请输入围栏半径"
v-model.trim="form.radius"
>
<template slot="append">米</template>
</el-input>
<el-button type="primary" class="btn" :disabled="!form.radius" @click="changeRadius">更新围栏</el-button>
<el-button
type="primary"
class="btn"
:disabled="!form.radius"
@click="changeRadius"
>更新围栏</el-button
>
</div>
</el-form-item>
<el-form-item label="" label-width="0" v-if="form.shapeType == 1">
<el-form-item
label=""
label-width="0"
v-if="form.shapeType == 1"
>
<div class="lnglat_box">
<el-form-item label="经度" prop="lng" class="is-required">
<el-input placeholder="请输入围栏经度" v-model="form.lng"></el-input>
<el-input
placeholder="请输入围栏经度"
v-model="form.lng"
></el-input>
</el-form-item>
<el-form-item label="纬度" prop="lat" class="is-required">
<el-input placeholder="请输入围栏纬度" v-model="form.lat"></el-input>
<el-input
placeholder="请输入围栏纬度"
v-model="form.lat"
></el-input>
</el-form-item>
</div>
</el-form-item>
<el-form-item label="经纬度解析" prop="analysisAddress" class="is-required" v-if="form.shapeType == 1">
<el-input v-model="form.analysisAddress" readonly></el-input>
<el-form-item
label="经纬度解析"
prop="analysisAddress"
class="is-required"
v-if="form.shapeType == 1"
>
<el-input
v-model="form.analysisAddress"
readonly
></el-input>
</el-form-item>
<el-form-item label="省市区" class="is-required" v-if="form.shapeType==4" prop="areaCode">
<city-select v-model="form.areaCode" :checkStrictly="true" @change="changeArea"></city-select>
<el-form-item
label="省市区"
class="is-required"
v-if="form.shapeType == 4"
prop="areaCode"
>
<city-select
v-model="form.areaCode"
:checkStrictly="true"
@change="changeArea"
></city-select>
</el-form-item>
<el-form-item label="状态" prop="enableStatus">
......@@ -90,9 +189,20 @@
</el-form-item>
<el-form-item label="描述" class="el_long_form_item">
<el-input type="textarea" v-model.trim="form.remark" resize="none" maxlength="500" show-word-limit placeholder="请输入围栏描述"></el-input>
<el-input
type="textarea"
v-model.trim="form.remark"
resize="none"
maxlength="500"
show-word-limit
placeholder="请输入围栏描述"
></el-input>
</el-form-item>
<el-form-item label="操作记录" class="el_long_form_item" v-show="isEditMode">
<el-form-item
label="操作记录"
class="el_long_form_item"
v-show="isEditMode"
>
<div class="record-list" v-html="form.record"></div>
</el-form-item>
</el-form>
......@@ -100,53 +210,98 @@
</el-tab-pane>
<el-tab-pane label="监控对象">
<div class="links_group">
<div>已关联{{tableData.length}}个设备</div>
<div>已关联{{ tableData.length }}个设备</div>
<div>
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联设备</el-button>
<el-button size="small" :disabled="!selectedIds || selectedIds.length<=0" @click="batchRemove">批量删除</el-button>
<el-button
v-if="!readonlyStatus"
type="primary"
@click="userDate"
size="small"
:loading="submitting"
>关联设备</el-button
>
<el-button
size="small"
:disabled="!selectedIds || selectedIds.length <= 0"
@click="batchRemove"
>批量删除</el-button
>
</div>
</div>
<!-- <el-table class="el_table" :data="tableData" border height="300" size="small" v-loading="loading" @selection-change="selectChange" style="width: 100%;margin-bottom:40px">
<el-table-column :disabled="readonlyStatus" type="selection" width="40"></el-table-column>
<el-table-column fixed type="index" label="序号" :index="getIndex" width="70"></el-table-column>
<el-table-column fixed prop="name" label="姓名" show-overflow-tooltip></el-table-column>
<el-table-column fixed prop="vin" label="车架号" show-overflow-tooltip></el-table-column>
<el-table-column prop="sn" label="设备号" show-overflow-tooltip></el-table-column>
<el-table-column prop="time" label="GPS时间" show-overflow-tooltip></el-table-column>
<el-table-column prop="address" label="位置" show-overflow-tooltip></el-table-column>
<el-table-column prop="userTel" label="联系方式" show-overflow-tooltip></el-table-column>
</el-table> -->
<vxe-table :data="tableData" border show-overflow ref="xTableComponent" max-height="300" :row-config="{isHover: true}" :sort-config="{trigger: 'cell'}" @checkbox-change="selectChange" @checkbox-all="selectChange">
<vxe-table
:data="tableData"
border
show-overflow
ref="xTableComponent"
max-height="300"
:row-config="{ isHover: true }"
:sort-config="{ trigger: 'cell' }"
@checkbox-change="selectChange"
@checkbox-all="selectChange"
>
<vxe-column type="checkbox" width="60"></vxe-column>
<vxe-column type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="name" title="姓名"></vxe-column>
<vxe-column field="vin" title="车架号"></vxe-column>
<vxe-column field="sn" title="设备号" show-overflow></vxe-column>
<vxe-column field="time" title="GPS时间" show-overflow></vxe-column>
<vxe-column field="address" title="位置" show-overflow></vxe-column>
<vxe-column field="userTel" title="联系方式" show-overflow></vxe-column>
<vxe-column
field="sn"
title="设备号"
show-overflow
></vxe-column>
<vxe-column
field="time"
title="GPS时间"
show-overflow
></vxe-column>
<vxe-column
field="address"
title="位置"
show-overflow
></vxe-column>
<vxe-column
field="userTel"
title="联系方式"
show-overflow
></vxe-column>
</vxe-table>
</el-tab-pane>
</el-tabs>
</div>
<div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">保存</el-button>
<el-button
v-if="!readonlyStatus"
type="primary"
@click="saveFence"
size="small"
:loading="submitting"
>保存</el-button
>
<el-button @click="cancel" size="small">取消</el-button>
</div>
</div>
</el-collapse-transition>
<!-- 围栏内容 end -->
<user-list v-if="userListModalVisible" @onUserListInit="(res)=>userListInit=res" :userData="tableData" @onUpdateUserData="updateUserData" :userListModalVisible="userListModalVisible" :shopId="form.specialShopId" :source="form.source" @onUserListModalChange="userListModalChange" ref="userList">
<user-list
v-if="userListModalVisible"
@onUserListInit="(res) => (userListInit = res)"
:userData="tableData"
@onUpdateUserData="updateUserData"
:userListModalVisible="userListModalVisible"
:shopId="form.specialShopId"
:source="form.source"
@onUserListModalChange="userListModalChange"
ref="userList"
>
</user-list>
</div>
</template>
<script>
import mapService from "@/utils/mapService.js";
// import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import fenceMap from "./fenceMap.vue";
import userList from "./fence_userlist.vue";
import InfiniteLoading from "vue-infinite-loading";
import InfiniteLoading, { nextTick } from "vue-infinite-loading";
import CitySelect from "@/components/area/index";
import { deepClone, showToast, showModal } from "@/utils/utils";
import {
......@@ -245,7 +400,7 @@ export default {
// 校验经度
let checkLng = (rule, vaule, cb) => {
let reg =
/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/;
/^(-?180(?:\.\d{1,15})?|1[0-7]\d(?:\.\d{1,15})?|\d{1,2}(?:\.\d{1,15})?)$/;
if (this.form.shapeType == 1 && !reg.test(this.form.lng)) {
cb(new Error("请输入正确的格式"));
} else {
......@@ -254,8 +409,7 @@ export default {
};
// 校验纬度
let checkLat = (rule, vaule, cb) => {
let reg =
/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/;
let reg = /^(-?90(?:\.\d{1,15})?|[0-8]\d(?:\.\d{1,15})?)$/;
if (this.form.shapeType == 1 && !reg.test(this.form.lat)) {
cb(new Error("请输入正确的格式"));
} else {
......@@ -282,7 +436,7 @@ export default {
timeType: 2,
enableStatus: 1,
radius: 1000,
source:1
source: 1,
},
restainFenceName: "",
rules: {
......@@ -349,23 +503,37 @@ export default {
});
},
});
},
mounted() {
//this.listener();
let _this = this;
let query = this.$route.query;
this.$set(this.form,'source',query.source);
if (query.id) {
_this.fenceId = query.id;
_this.getFenceInfo(query.id);
_this.getList();
} else {
//this.$refs.fenceForm.clearValidate();
_this.$refs.fenceMap.updateFence({
fenceType: "circle",
});
}
this.$nextTick(() => {
let check = () => {
this.checkLoadedTimeoutId &&
window.clearTimeout(this.checkLoadedTimeoutId);
return setTimeout(() => {
if ("AMap" in window) {
window.AMap = AMap;
let _this = this;
let query = this.$route.query;
this.$set(this.form, "source", query.source);
if (query.id) {
_this.fenceId = query.id;
_this.getFenceInfo(query.id);
_this.getList();
} else {
//this.$refs.fenceForm.clearValidate();
_this.$refs.fenceMap.updateFence({
fenceType: "circle",
});
}
} else {
this.checkLoadedTimeoutId = check();
}
}, 100);
};
this.checkLoadedTimeoutId = check();
});
},
methods: {
// 监听围栏类型变化
......@@ -389,7 +557,6 @@ export default {
// 监听表格选择
selectChange() {
const records = this.$refs.xTableComponent.getCheckboxRecords();
console.log(records);
this.selectedIds = records;
},
......@@ -402,10 +569,8 @@ export default {
updateUserData(data) {
this.userArr = data;
this.tableData = data;
console.log(data);
},
updateMapData(data) {
console.log(data);
if (data.radius) {
this.$set(this.form, "radius", data.radius);
}
......@@ -538,8 +703,10 @@ export default {
// 多边形围栏
if (form.shapeType == 3) {
//oParams.lnglat = this.polygonPath;
oParams.lnglat = this.polygonPath.join("|");
let lnglats = this.polygonPath.map((item) => {
return item.lng + "," + item.lat;
});
oParams.lnglat = lnglats.join("|");
}
// 行政区域围栏
......@@ -596,18 +763,14 @@ export default {
// 解析经纬度地址
getAddress(flag) {
let _this = this;
const lnglatXY = [this.form.lng, this.form.lat];
const lnglatXY = mapService.getLngLat(this.form.lng, this.form.lat);
_this.$set(_this.form, "analysisAddress", "");
_this.geocoder.getAddress(lnglatXY, (status, result) => {
_this.geocoder.getLocation(lnglatXY, (result) => {
if (flag == _this.transferFlag) {
if (status === "complete" && result.info === "OK") {
if (result) {
//获取地址成功
console.log(result.regeocode.formattedAddress);
_this.$set(
_this.form,
"analysisAddress",
result.regeocode.formattedAddress
);
_this.$set(_this.form, "analysisAddress", result.address);
_this.transferError = false;
_this.$refs.fenceForm.validateField("analysisAddress");
//this.$refs.fenceMap.updateMap(this.form)
......@@ -642,12 +805,11 @@ export default {
// 监听省市区改变
changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.form.areaText = e.name[e.name.length - 1];
this.$refs.fenceMap.updateFence({
fenceType: "area",
areaCode: e.code[e.code.length - 1],
areaText: e.name[e.name.length - 1],
});
},
......@@ -694,7 +856,6 @@ export default {
}
if (obj.lnglat) {
let lnglat = obj.lnglat.split(",");
console.log(lnglat);
obj.lng = lnglat[0];
obj.lat = lnglat[1];
}
......@@ -704,18 +865,21 @@ export default {
_this.form = obj;
mapData.fenceType = _typeList[obj.shapeType];
// 地图画围栏
switch (obj.shapeType) {
case 3:
let path = obj.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
let arr = item.split(",");
console.log(arr);
return mapService.getLngLat(arr[0], arr[1]);
});
console.log(path);
mapData.polygonPath = path;
_this.polygonPath = path;
break;
case 4:
mapData.areaCode = obj.areaCode;
mapData.areaText = obj.areaText;
break;
default:
let lnglat = obj.lnglat ? obj.lnglat.split(",") : [];
......
......@@ -3,14 +3,24 @@
<div id="alarmMap" class="map-container"></div>
<div class="left-box" v-show="boxShow">
<!-- 饼图组件 -->
<ParCharts class="pie" ref="pieChartsRef" id="pie-chart" height="220px" :list="pieList" />
<ParCharts
class="pie"
ref="pieChartsRef"
id="pie-chart"
height="220px"
:list="pieList"
/>
<!-- 风险分析 -->
<div class="analy-box">
<div class="top-box">
<template v-if="alarmData.data.length">
<div v-for="item in alarmData.data" :key="item" class="top-box-item">
<div
v-for="item in alarmData.data"
:key="item"
class="top-box-item"
>
<div class="top-box-item-left">{{ item.alarmName }}</div>
<div :class="['top-box-item-right', 'item'+item.alarmLevel]">
<div :class="['top-box-item-right', 'item' + item.alarmLevel]">
<!-- <div :class="['item', item.alarmLevel <= 5 ? 'item1' : 'item1-grey']"></div>
<div :class="['item', item.alarmLevel <= 4 ? 'item2' : 'item-grey']"></div>
<div :class="['item', item.alarmLevel <= 3 ? 'item3' : 'item-grey']"></div>
......@@ -53,30 +63,58 @@
<div class="bottom-box">
<div class="bottom-box-item">
<div class="bottom-box-item-left">常驻地:</div>
<div class="bottom-box-item-right">{{ alarmData.residence || '-' }}</div>
<div class="bottom-box-item-right">
{{ alarmData.residence || "-" }}
</div>
</div>
<div class="bottom-box-item">
<div class="bottom-box-item-left">预测家庭地址:</div>
<div class="bottom-box-item-right">{{ alarmData.homeAddress || '-' }}</div>
<div class="bottom-box-item-right">
{{ alarmData.homeAddress || "-" }}
</div>
</div>
<div class="bottom-box-item">
<div class="bottom-box-item-left">预测工作地址:</div>
<div class="bottom-box-item-right">{{ alarmData.workAddress || '-' }}</div>
<div class="bottom-box-item-right">
{{ alarmData.workAddress || "-" }}
</div>
</div>
</div>
</div>
</div>
<div class="right-box" v-show="boxShow">
<!-- 用车行为分析 -->
<div class="use-car-box">
<div class="title">用车行为分析<div class="detail-btn" v-if="pieList && pieList.length" @click="goDetailPage()">风险评估详情</div></div>
<div class="x-name" v-if="xAxisDataList.length"><span>{{ linetype== 1 ? '周' : '天' }}</span><span v-if="lineChartsYear">-{{ lineChartsYear }}年</span></div>
<!-- 用车行为分析 -->
<div class="use-car-box">
<div class="title">
用车行为分析
<div
class="detail-btn"
v-if="pieList && pieList.length"
@click="goDetailPage()"
>
风险评估详情
</div>
</div>
<div class="x-name" v-if="xAxisDataList.length">
<span>{{ linetype == 1 ? "周" : "天" }}</span
><span v-if="lineChartsYear">-{{ lineChartsYear }}年</span>
</div>
<div class="line-charts" v-if="xAxisDataList.length">
<LineCharts id="useCarCharts" ref="useCarChartsRef" height="250px" :linetype="linetype" :dataList="useCarData"
:xAxisData="xAxisDataList" :lineChartsYear="lineChartsYear"></LineCharts>
<LineCharts
id="useCarCharts"
ref="useCarChartsRef"
height="250px"
:linetype="linetype"
:dataList="useCarData"
:xAxisData="xAxisDataList"
:lineChartsYear="lineChartsYear"
></LineCharts>
</div>
<div v-else class="empty-box">
<img src="https://wx.glsx.com.cn/upload/biz/501829f0-6c34-443c-bf56-ae94072a6619.png" alt="">
<img
src="https://wx.glsx.com.cn/upload/biz/501829f0-6c34-443c-bf56-ae94072a6619.png"
alt=""
/>
<div>暂无里程数据</div>
</div>
</div>
......@@ -86,36 +124,52 @@
<div>
<div class="detail-msg">
<div class="detail-msg-left">承租人姓名:</div>
<div class="detail-msg-right"> {{ basicData.lesseeName || '-' }}</div>
<div class="detail-msg-right">
{{ basicData.lesseeName || "-" }}
</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">店面名称:</div>
<div class="detail-msg-right"> {{ basicData.shopName || '-' }}</div>
<div class="detail-msg-right">{{ basicData.shopName || "-" }}</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">客户姓名:</div>
<div class="detail-msg-right"> {{ basicData.userName || '-' }}</div>
<div class="detail-msg-right">{{ basicData.userName || "-" }}</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">业务工单号:</div>
<div class="detail-msg-right"> {{ basicData.workOrderNo || '-' }}</div>
<div class="detail-msg-right">
{{ basicData.workOrderNo || "-" }}
</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">车架号:</div>
<div class="detail-msg-right">{{ basicData.vin || '-' }} </div>
<div class="detail-msg-right">{{ basicData.vin || "-" }}</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">创建时间:</div>
<div class="detail-msg-right">{{ basicData.createTime || '-' }} </div>
<div class="detail-msg-right">
{{ basicData.createTime || "-" }}
</div>
</div>
<div class="detail-msg">
<div class="detail-msg-left">设备状态:</div>
<template v-if="basicData.deviceInformationVOList&&basicData.deviceInformationVOList.length">
<template
v-if="
basicData.deviceInformationVOList &&
basicData.deviceInformationVOList.length
"
>
<div class="detail-msg-right">
<div class="detail-msg-desc" v-for="item in basicData.deviceInformationVOList">
<div
class="detail-msg-desc"
v-for="item in basicData.deviceInformationVOList"
>
<div class="sn">{{ item.sourceStr }}-{{ item.sn }}</div>
<div v-show="item.deviceStateStr">{{ item.deviceStateStr }}</div>
<div>定位-{{ item.address || ' --' }}</div>
<div v-show="item.deviceStateStr">
{{ item.deviceStateStr }}
</div>
<div>定位-{{ item.address || " --" }}</div>
</div>
</div>
</template>
......@@ -125,7 +179,6 @@
</div>
</div>
</div>
</div>
<!-- 热力图 -->
<div class="hot-box">“历史停留”热力图</div>
......@@ -133,16 +186,23 @@
</template>
<script>
import ParCharts from './ParCharts.vue';
import mapService from "@/utils/mapService.js";
import LineCharts from './LineCharts.vue';
import ParCharts from "./ParCharts.vue";
import mapService from "@/utils/mapBService.js";
import LineCharts from "./LineCharts.vue";
import { services } from "@/api";
import "utils/mapEvent.js";
import EventBus from "../../event-bus";
import { GET_STAY_POINTLIST, GET_BASIC_INFORMATION, GET_RESIDENT_INFORMATION, GET_ALARM_POINTLIST, GET_USER_BEHAVIOR_INFORMATION, GET_HISTORY_LOCATION } from "@/api/services/monitor";
import {
GET_STAY_POINTLIST,
GET_BASIC_INFORMATION,
GET_RESIDENT_INFORMATION,
GET_ALARM_POINTLIST,
GET_USER_BEHAVIOR_INFORMATION,
GET_HISTORY_LOCATION,
} from "@/api/services/monitor";
const MONITOR_SERVICE = services.monitor;
export default {
name: 'OEshieldAlarmAnalysis',
name: "OEshieldAlarmAnalysis",
components: { ParCharts, LineCharts },
data() {
return {
......@@ -155,9 +215,9 @@ export default {
basicData: {},
alarmData: {
data: [],
residence: '',
homeAddress: '',
workAddress: '',
residence: "",
homeAddress: "",
workAddress: "",
},
useCarData: [],
xAxisDataList: [],
......@@ -165,94 +225,78 @@ export default {
resultList: [],
linetype: 1,
boxShow: false,
lineChartsYear: ''
lineChartsYear: "",
};
},
mounted() {
let _this = this;
const _vehicleId = _this.$route.query.vehicleId
const _vehicleId = this.$route.query.vehicleId
this.vehicleId = _vehicleId
_this.$mapInit({ version: '1.4.2' }).then(AMap => {
// window.AMap = AMap;
_this.initMap();
})
this.resetWidth()
this.initBMap();
this.resetWidth();
},
methods: {
goDetailPage() {
this.$router.push({name:'riskAssessDetail', query: {
vehicleId: this.vehicleId,
vin :this.basicData.vin}})
this.$router.push({
name: "riskAssessDetail",
query: {
vehicleId: this.vehicleId,
vin: this.basicData.vin,
},
});
},
resetWidth() {
const homePage = document.querySelector('.desktop-left-sider');
const homePage = document.querySelector(".desktop-left-sider");
// 创建 ResizeObserver 对象
this.resizeObserver = new ResizeObserver(entries => {
console.log(111111)
this.resizeObserver = new ResizeObserver((entries) => {
console.log(111111);
// 当元素大小发生变化时执行的回调函数
for (let entry of entries) {
const width = entry.contentRect.width;
let myElement = document.querySelector('.main-container');
if(width==0) {
myElement.style.width = '100%';
myElement.style.left = '0';
}
if(width==200) {
myElement.style.width = 'calc(100% - 200px)';
myElement.style.left = '200px';
}
const width = entry.contentRect.width;
let myElement = document.querySelector(".main-container");
if (width == 0) {
myElement.style.width = "100%";
myElement.style.left = "0";
}
if (width == 200) {
myElement.style.width = "calc(100% - 200px)";
myElement.style.left = "200px";
}
}
});
// 开始观察目标元素的大小变化
homePage && this.resizeObserver.observe(homePage);
homePage && this.resizeObserver.observe(homePage);
},
initMap() {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("alarmMap");
this.isInitMap = true;
this.$nextTick(() => {
this.boxShow = true
this.getStayPointList(this.vehicleId)
this.getBasicInformation(this.vehicleId)
this.getResidentInformation(this.vehicleId)
this.getAlarmInformation(this.vehicleId)
this.getUserBehaviorInformation(this.vehicleId)
}, 500)
} else {
this.checkMapLoaded = check();
}
});
};
this.checkMapLoaded = check();
async initBMap() {
this.mapObj = await mapService.init("alarmMap");
window.AMap = this.mapObj;
this.isInitMap = true;
this.boxShow = true;
this.getStayPointList(this.vehicleId);
this.getBasicInformation(this.vehicleId);
this.getResidentInformation(this.vehicleId);
this.getAlarmInformation(this.vehicleId);
this.getUserBehaviorInformation(this.vehicleId);
},
// 设备停留点查询
getStayPointList(vehicleId) {
EventBus.$emit("uiMap.historyLocation.destroy");
GET_STAY_POINTLIST({ vehicleId }).then(res => {
GET_STAY_POINTLIST({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
})
return
});
return;
}
let _data = res.data || []
let _data = res.data || [];
if (!_data.length) {
this.$message({
type: "info",
message: '暂无历史停留数据',
})
return
message: "暂无历史停留数据",
});
return;
}
_data.forEach((item, idx) => {
item.idx = idx;
......@@ -265,86 +309,92 @@ export default {
});
this.resultList = _data;
EventBus.$emit("uiMap.historyLocation.draw", _data);
})
});
},
// 获取车辆基本信息
getBasicInformation(vehicleId) {
GET_BASIC_INFORMATION({ vehicleId }).then(res => {
GET_BASIC_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
})
return
});
return;
}
this.basicData = res.data
})
this.basicData = res.data;
});
},
// 预测家庭地址和预测工作地址查询
getResidentInformation(vehicleId) {
GET_RESIDENT_INFORMATION({ vehicleId }).then(res => {
GET_RESIDENT_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
})
return
});
return;
}
this.alarmData.residence = res.data.residence
this.alarmData.homeAddress = res.data.homeAddress
this.alarmData.workAddress = res.data.workAddress
})
this.alarmData.residence = res.data.residence;
this.alarmData.homeAddress = res.data.homeAddress;
this.alarmData.workAddress = res.data.workAddress;
});
},
// 设备警情数据查询
getAlarmInformation(vehicleId) {
GET_ALARM_POINTLIST({ vehicleId }).then(res => {
GET_ALARM_POINTLIST({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
})
return
});
return;
}
this.alarmData.data = res.data.length > 6 ? res.data.slice(0, 6) : res.data
let _list = res.data
this.alarmData.data =
res.data.length > 6 ? res.data.slice(0, 6) : res.data;
let _list = res.data;
if (_list.length === 0) {
this.$refs.pieChartsRef.draw()
return
this.$refs.pieChartsRef.draw();
return;
}
_list[0].value = 1 / _list[0].alarmLevel * 100
this.pieList.push(_list[0])
this.$refs.pieChartsRef.draw()
})
_list[0].value = (1 / _list[0].alarmLevel) * 100;
this.pieList.push(_list[0]);
this.$refs.pieChartsRef.draw();
});
},
// 用户行为数据查询
getUserBehaviorInformation(vehicleId) {
GET_USER_BEHAVIOR_INFORMATION({ vehicleId }).then(res => {
GET_USER_BEHAVIOR_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) {
this.$message({
type: "error",
message: res.message,
})
return
});
return;
}
let _dataList = res.data.statisticsType == 1 ? res.data.userBehaviorWeekDTOList : res.data.userBehaviorDayDTOList
_dataList ? _dataList : []
let _dataList =
res.data.statisticsType == 1
? res.data.userBehaviorWeekDTOList
: res.data.userBehaviorDayDTOList;
_dataList ? _dataList : [];
if (_dataList.length == 0) {
this.useCarData = []
return
this.useCarData = [];
return;
}
this.linetype = res.data.statisticsType
let _int = res.data.statisticsType == 1 ? 'weekInt' : 'dayInt'
let _type = res.data.statisticsType == 1 ? 'weekNum' : 'dayNum'
this.lineChartsYear = _dataList[_dataList.length - 1].yearInt || ''
_dataList.forEach(item => {
res.data.statisticsType == 1 ? this.xAxisDataList.push(item[_int]) : this.xAxisDataList.push(item.monthInt + '.' + item[_int])
this.useCarData.push(item[_type])
})
this.linetype = res.data.statisticsType;
let _int = res.data.statisticsType == 1 ? "weekInt" : "dayInt";
let _type = res.data.statisticsType == 1 ? "weekNum" : "dayNum";
this.lineChartsYear = _dataList[_dataList.length - 1].yearInt || "";
_dataList.forEach((item) => {
res.data.statisticsType == 1
? this.xAxisDataList.push(item[_int])
: this.xAxisDataList.push(item.monthInt + "." + item[_int]);
this.useCarData.push(item[_type]);
});
setTimeout(() => {
this.$refs.useCarChartsRef.drawBarLine()
}, 1000)
})
}
this.$refs.useCarChartsRef.drawBarLine();
}, 1000);
});
},
},
// async created() {
// EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
......@@ -352,29 +402,30 @@ export default {
// });
// },
beforeDestroy() {
this.resizeObserver.disconnect()
this.resizeObserver.disconnect();
// this.checkLoadedTimeoutId && window.clearTimeout(this.checkLoadedTimeoutId);
},
};
</script>
<style lang="scss" scoped>
.analy-box, .detail-box{
.analy-box,
.detail-box {
/* 修改垂直滚动条 */
&::-webkit-scrollbar {
width: 2px; /* 修改宽度 */
}
/* 修改滚动条轨道背景色 */
&::-webkit-scrollbar-track {
background-color: #fff;
}
/* 修改滚动条滑块颜色 */
&::-webkit-scrollbar-thumb {
background-color: #181c36e6;
}
/* 修改滚动条滑块悬停时的颜色 */
&::-webkit-scrollbar-thumb:hover {
background-color: #181c36e6;
......@@ -384,7 +435,7 @@ export default {
position: fixed;
width: calc(100% - 200px);
height: calc(100% - 60px);
top:60px;
top: 60px;
left: 200px;
background: #fff;
padding: 0;
......@@ -410,7 +461,7 @@ export default {
.pie {
width: 300px;
height: 270px;
background: #181C36;
background: #181c36;
box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999;
}
......@@ -423,7 +474,7 @@ export default {
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
background: rgba(24 ,28, 54 ,0.9);
background: rgba(24, 28, 54, 0.9);
box-shadow: 0 4px 6px 0 #00000014;
box-sizing: border-box;
padding: 30px 16px 16px;
......@@ -431,18 +482,18 @@ export default {
.top-box {
position: relative;
.top-box-none{
.top-box-none {
position: relative;
width: 100%;
height: 130px;
.dask-bg{
.dask-bg {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.dask{
.dask {
position: absolute;
z-index: 2;
left: 0;
......@@ -460,7 +511,7 @@ export default {
justify-content: center;
font-weight: 600;
font-size: 21px;
color: #FFFFFF;
color: #ffffff;
}
}
&-item {
......@@ -471,7 +522,7 @@ export default {
.top-box-item-left {
font-weight: 400;
font-size: 12px;
color: #FFFFFF;
color: #ffffff;
text-align: center;
width: 100px;
margin-right: 12px;
......@@ -481,26 +532,26 @@ export default {
width: 140px;
height: 12px;
border-radius: 6px;
background: #46495E;
background: #46495e;
}
.item5 {
background: #4ED5D7;
background: #4ed5d7;
}
.item4 {
background: #58D068;
background: #58d068;
}
.item3 {
background: #F7D310;
background: #f7d310;
}
.item2 {
background: #F38906;
background: #f38906;
}
.item1 {
background: #F23204;
background: #f23204;
}
&-right-none {
......@@ -521,8 +572,8 @@ export default {
left: 158px;
font-weight: 600;
font-size: 14px;
color: #B5B5B5;
-webkit-text-stroke: 0.5px #181C36;
color: #b5b5b5;
-webkit-text-stroke: 0.5px #181c36;
}
}
......@@ -548,21 +599,20 @@ export default {
}
.dot-2 {
background: #58D068;
background: #58d068;
}
.dot-3 {
background: #F7D310;
background: #f7d310;
}
.dot-4 {
background: #F38906;
background: #f38906;
}
.dot-5 {
background: #F23204;
background: #f23204;
}
}
.bottom-box {
......@@ -578,7 +628,7 @@ export default {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #A3A4AF;
color: #a3a4af;
}
&-right {
......@@ -586,11 +636,10 @@ export default {
line-height: 17px;
font-weight: 400;
font-size: 12px;
color: #E5E5E8;
color: #e5e5e8;
}
}
}
}
.right-box {
......@@ -598,31 +647,30 @@ export default {
top: 10px;
right: 26px;
z-index: 9999;
.title{
.title {
display: flex;
align-items: center;
justify-content: space-between;
.detail-btn{
.detail-btn {
cursor: pointer;
width: 116px;
text-align: center;
color: #fff;
height: 32px;
line-height: 32px;
background: #0077FF;
background: #0077ff;
border-radius: 4px;
}
}
}
.detail-box {
margin-top: 8px;
width: 300px;
max-height: 420px;
overflow-y: auto;
overflow-x: hidden;
background: rgba(24 ,28, 54 ,0.9);
background: rgba(24, 28, 54, 0.9);
border-radius: 8px;
box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999;
......@@ -632,7 +680,7 @@ export default {
.title {
font-weight: 500;
font-size: 14px;
color: #158BFF;
color: #158bff;
margin-bottom: 10px;
}
......@@ -642,14 +690,14 @@ export default {
font-weight: 400;
font-size: 14px;
margin-bottom: 8px;
&:last-child{
&:last-child {
margin-bottom: 0;
}
&-left {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #A3A4AF;
color: #a3a4af;
min-width: 72px;
text-align: right;
}
......@@ -659,15 +707,15 @@ export default {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #E5E5E8;
color: #e5e5e8;
}
.detail-msg-desc {
color: #E5E5E8;
.sn{
color: #2994FF;
color: #e5e5e8;
.sn {
color: #2994ff;
}
& div{
& div {
margin-bottom: 1px;
line-height: 17px;
}
......@@ -678,14 +726,14 @@ export default {
.use-car-box {
width: 300px;
height: 270px;
background: rgba(24 ,28, 54 ,0.9);
background: rgba(24, 28, 54, 0.9);
border-radius: 8px;
box-sizing: border-box;
padding: 16px;
box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999;
position: relative;
.x-name{
.x-name {
color: #6e7079;
position: absolute;
right: 20px;
......@@ -694,7 +742,7 @@ export default {
.title {
font-weight: 500;
font-size: 14px;
color: #158BFF;
color: #158bff;
}
.empty-box {
......@@ -724,7 +772,7 @@ export default {
border-radius: 24px 24px 0 0;
font-weight: 600;
font-size: 20px;
color: #FFFFFF;
color: #ffffff;
text-align: center;
line-height: 48px;
z-index: 9999;
......@@ -732,4 +780,5 @@ export default {
.line-charts {
padding-left: 10px;
}</style>
\ No newline at end of file
}
</style>
\ No newline at end of file
......@@ -183,7 +183,8 @@
</template>
<script>
import "@/assets/spritesmith-generated/sprite.css";
import mapService from "@/utils/mapService.js";
// import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js";
import EventBus from "@/event-bus";
import { services } from "@/api";
......@@ -326,7 +327,8 @@ export default {
let _query = this.$route.query;
this.$set(this.form, "source", _query.source || 0);
this.initMap();
// this.initMap();
this.initBMap();
},
mounted() {
//store.dispatch("setFullsize", true);
......@@ -340,15 +342,11 @@ export default {
},
},
methods: {
// 初始化地图
initMap() {
let _this = this;
_this.$mapInit().then((AMap) => {
window.AMap = AMap;
window.AMap = AMap;
_this.map = mapService.init("map");
_this.getDevinceInfo();
});
//初始化百度地图
async initBMap(){
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.getDevinceInfo()
},
// 获取设备信息
......@@ -478,20 +476,21 @@ export default {
// 监听圆形围栏直径变化
onFenceRadiusChange(e) {
console.log("圆形围栏:", e);
this.$set(this.form, "radius", e);
if(e){
this.$set(this.form, "radius", e);
}
},
// 监听围栏类型变化
changeShapeType(e) {
let _this = this;
let _info = this.deviceInfo;
let areaCode = this.form.areaCode || [];
let areaText = this.form.areaText || [];
// 1:圆形围栏 4:行政区域 3:多边形
console.log(_info);
switch (e) {
case 4:
_this.drawDistrict(areaCode);
_this.drawDistrict(areaText);
break;
case 3:
_this.drawPolygon();
......@@ -509,10 +508,9 @@ export default {
// 监听行政区域
changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.drawDistrict(e.code);
this.drawDistrict(e.name);
this.$refs.form.clearValidate();
},
......@@ -521,7 +519,6 @@ export default {
let _this = this;
let o = deepClone(_this.form);
let query = this.$route.query;
console.log(o);
let oParams = {};
let deviceList = this.deviceList;
......@@ -547,7 +544,10 @@ export default {
// 多边形围栏
if (o.shapeType == 3) {
oParams.lnglat = this.polygonPath.join("|");
let lnglats = this.polygonPath.map((item) => {
return item.lng + "," + item.lat;
});
oParams.lnglat = lnglats.join("|");
}
// 行政区域围栏
......
......@@ -57,7 +57,8 @@
</template>
<script>
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
// import mapService from "utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant";
export default {
......@@ -90,24 +91,33 @@ export default {
fenceType: "polygon", //'area' 'polygon'
lng: "",
lat: "",
radius: "",
radius: 1000,
fenceCircle: null,
fenceCenter: null,
areaCode: "",
isFenceInit: false,
mapLoading: false,
polygonPath: [],
txtMenuItem: [
{
text: "设置围栏中心",
callback: function () {
map.zoomIn();
},
},
],
};
},
mounted() {
let _this = this;
let plugins = ["AMap.LngLat", "AMap.AutoComplete",'AMap.MouseTool','AMap.PolyEditor'];
_this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => {
window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu();
_this.bindSearch();
});
// let _this = this;
// let plugins = ["AMap.LngLat", "AMap.AutoComplete",'AMap.MouseTool','AMap.PolyEditor'];
// _this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => {
// window.AMap = AMap;
// _this.mapObj = mapService.init("mapContainer");
// _this.bindContextMenu();
// _this.bindSearch();
// });
this.initBMap();
},
watch: {
lng(newVal) {
......@@ -116,17 +126,15 @@ export default {
lat(newVal) {
//this.transfer()
},
/* mapData(newVal){
const fenceData = newVal;
this.initMapPromise.then(()=>{console.log(fenceData)
if(fenceData.fenceType === 'circle'){
this.drawFence(fenceData)
}
})
} */
},
async created() {},
methods: {
async initBMap() {
this.mapObj = await mapService.init("mapContainer");
window.AMap = this.mapObj;
this.bindContextMenu();
this.bindSearch();
},
initMap() {
this.initMapPromise = new Promise((resolve, reject) => {
let check = () => {
......@@ -153,82 +161,52 @@ export default {
});
},
bindSearch() {
const self = this;
AMap.plugin("AMap.Autocomplete", function () {
self.auto = new AMap.Autocomplete({
input: "fenceMapSearch",
});
self.autoCenterMarker = new AMap.Marker({
icon: require("images/auto-center-marker.gif"),
map: self.mapObj,
offset: new AMap.Pixel(-12, -12),
visible: false,
let self = this,
url = require("images/auto-center-marker.gif"),
size = AMap.invoke("Size", 24, 24);
self.auto = AMap.invoke("Autocomplete", {
input: "fenceMapSearch",
});
AMap.invoke("autocompleteShow");
AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
let location = e.item.value.location;
AMap.invoke("panTo", location, true);
self.autoCenterMarker = AMap.invoke("Marker", location, {
icon: AMap.invoke("Icon", url, size),
});
self.autoCenterMarker.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) {
self.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
AMap.invoke("markerAddEventListener", "rightclick", (e) => {
// AMap.invoke("mapAddEventListener", "rightclick", function (e) {
// console.log(e,'地图事件')
// })
// self.autoCenterMarker.setContextMenu(self.contextMenu)
self.contextMenuPositon = e.latLng; //右键菜单位置
});
self.auto.on("select", (e) => {
console.log(e.poi);
if (e.poi && e.poi.location) {
self.mapObj.setCenter(e.poi.location);
self.autoCenterMarker.setPosition(e.poi.location);
self.lng = e.poi.location.lng;
self.lat = e.poi.location.lat;
self.autoCenterMarker.show();
self.mapObj.add(self.autoCenterMarker);
}
self.mapObj.setZoom(14);
});
// AMap.event.addListener(self.auto, "select", (e) => {
// console.log(e.poi);
// if (e.poi && e.poi.location) {
// self.mapObj.setCenter(e.poi.location);
// self.autoCenterMarker.setPosition(e.poi.location);
// /*for(var i = 0, l = this.polygons.length; i < l; i++) {
// this.polygons[i].setMap(null);
// }*/
// self.lng = e.poi.location.lng;
// self.lat = e.poi.location.lat;
// self.autoCenterMarker.show();
// self.mapObj.add(self.autoCenterMarker);
// }
// self.mapObj.setZoom(14);
// });
self.lng = location.lng;
self.lat = location.lat;
AMap.invoke("addOverlay", self.autoCenterMarker);
AMap.invoke('centerAndZoom', location, 15)
});
},
bindContextMenu() {
const self = this;
var contextMenu = new AMap.ContextMenu();
const MAP = mapService.map;
var contextMenu = MAP.invoke("ContextMenu");
contextMenu.addItem(
"设置围栏中心",
function () {
MAP.invoke("MenuItem", "设置围栏中心", function () {
self.moveCenter();
},
0
})
);
//地图绑定鼠标右击事件——弹出右键菜单
self.mapObj.on("rightclick", function (e) {
contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat;
MAP.invoke("mapAddEventListener", "rightclick", function (e) {
MAP.invoke("addContextMenu", contextMenu);
self.contextMenuPositon = e.latlng;
});
self.contextMenu = contextMenu;
//contextMenu.open(self.mapObj, lnglat);
},
drawFence() {
if (!this.lng && !this.lat) {
this.mapLoading = true;
this.getCurrentPosition()
.then((pos) => {
console.log(pos);
this.lng = pos.lng;
this.lat = pos.lat;
this.radius = 1000;
......@@ -255,50 +233,37 @@ export default {
}
},
drawFenceCircle(fenceCenter) {
const mapObj = this.mapObj;
if (this.fenceCircle) {
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat));
} else {
this.fenceCircle = new AMap.Circle({
map: mapObj,
center: fenceCenter,
radius: this.radius * 1,
let options = {
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
});
mapObj.plugin(["AMap.CircleEditor"], () => {
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
// this.circleEditor.on("adjust", function (e) {
// console.log(e);
// });
AMap.event.addListener(this.circleEditor, "adjust", (e) => {
this.radius = e.radius / 1;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
});
AMap.event.addListener(this.circleEditor, "move", (e) => {
this.lng = e.lnglat.lng;
this.lat = e.lnglat.lat;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
enableEditing: true,
};
this.fenceCircle = AMap.invoke(
"Circle",
fenceCenter,
this.radius * 1,
options
);
AMap.invoke('centerAndZoom', fenceCenter, 14)
AMap.invoke("addOverlay", this.fenceCircle);
AMap.invoke("circleAddEventListener", "lineupdate", (e) => {
let overlay = e.overlay;
this.radius = parseInt(overlay.getRadius() / 1);
this.lng = e.overlay.getCenter().lng;
this.lat = e.overlay.getCenter().lat;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
this.circleEditor.open();
});
}
mapService.setFitView();
mapObj.setZoom(14);
},
initFence(data) {
let _this = this;
......@@ -311,7 +276,7 @@ export default {
this.fenceType = data.fenceType;
switch (data.fenceType) {
case "area":
_this.areaCode = data.areaCode;
_this.areaText = data.areaText;
_this.drawArea();
break;
case "polygon":
......@@ -332,17 +297,14 @@ export default {
},
// 更新围栏信息
updateFence(data) {
console.log("更新围栏信息", data);
let _this = this;
let mapInterval = setInterval(function () {
if (_this.mapObj) {
clearInterval(mapInterval);
_this.mapObj.clearMap();
AMap.invoke("clearOverlays");
_this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close();
_this.mouseTool && _this.mouseTool.close();
if (_this.fenceType === "circle") {
_this.fenceCircle = null;
if (data.lng) {
......@@ -357,13 +319,14 @@ export default {
_this.drawFence();
} else if (_this.fenceType === "area") {
if (data.areaCode) {
_this.areaCode = data.areaCode;
if (data.areaText) {
_this.areaText = data.areaText;
}
if (_this.areaCode) {
if (_this.areaText) {
_this.drawArea();
}
} else if (_this.fenceType === "polygon") {
console.log()
_this.drawPolygon();
}
}
......@@ -371,163 +334,124 @@ export default {
},
drawArea() {
let _this = this;
let areaCode = this.areaCode ? this.areaCode.toString() : "中国";
this.mapObj.clearMap();
for (var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}
let district, lng, lat;
this.mapLoading = true;
AMap.service("AMap.DistrictSearch", function () {
var opts = {
subdistrict: 1, //返回下一级行政区
extensions: "all",
showbiz: false, //最后一级返回街道信息
};
areaCode === "中国" ? delete opts.extensions : delete opts.showbiz;
district = new AMap.DistrictSearch(opts);
district.setLevel("district");
district.search(areaCode, function (status, result) {
var bounds = result.districtList[0].boundaries;
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
let polygon = new AMap.Polygon({
map: _this.mapObj,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.7,
fillColor: "#CCF3FF",
strokeColor: "#CC66CC",
});
_this.polygons.push(polygon);
}
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
//map.setZoom(10);
_this.mapLoading = false;
}
});
_this.mapLoading = true;
AMap.invoke("clearOverlays");
if (this.dist) AMap.invoke("removeDistrictLayer", this.dist);
this.dist = AMap.invoke("DistrictLayer", {
name: `(${_this.areaText})`,
fillOpacity: 0.7,
fillColor: "#CCF3FF",
strokeColor: "#CC66CC",
viewport: true,
});
AMap.invoke("addDistrictLayer", this.dist);
_this.mapLoading = false;
},
moveCenter() {
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.fenceCircle.setCenter(center);
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
if (this.fenceCircle) {
AMap.invoke("circleDisableEditing");
this.fenceCircle && this.fenceCircle.setCenter(this.contextMenuPositon);
AMap.invoke("removeOverlay", this.fenceCircle);
AMap.invoke("addOverlay", this.fenceCircle);
AMap.invoke("circleEnableEditing");
} else {
const lnglat = mapService.getLngLat(this.lng, this.lat);
this.drawFenceCircle(lnglat);
}
},
getCurrentPosition() {
const mapObj = this.mapObj;
const self = this;
return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () {
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition(function (status, result) {
if (status == "complete") {
var lnglatXY = mapService.getLngLat(
result.position.lng,
result.position.lat
);
resolve(lnglatXY);
}
if (status == "error") {
console.log("error", result);
//返回定位出错信息
resolve(mapObj.getCenter());
}
});
// AMap.event.addListener(self.geolocation, "complete", function (e) {
// console.log("complete", e);
// //返回定位信息
// var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
// resolve(lnglatXY);
// });
// AMap.event.addListener(self.geolocation, "error", function (e) {
// console.log("error", e);
// //返回定位出错信息
// resolve(mapObj.getCenter());
// });
AMap.invoke("Geolocation", (res) => {
var lnglatXY = mapService.getLngLat(res.longitude, res.latitude);
resolve(lnglatXY);
});
});
},
drawPolygon() {
const mapObj = this.mapObj;
const self = this;
console.log(this.polygonPath)
if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({
path: this.polygonPath,
let options = {
zIndex: 10,
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
fillColor: "#1791fc",
zIndex: 50,
enableEditing: true,
};
self.polygon = AMap.invoke("Polygon", this.polygonPath, options);
//获取多边形的中间位置
let lnglat = self.polygon.getBounds().getCenter();
// AMap.invoke("panTo", lnglat, true);
AMap.invoke("centerAndZoom", lnglat, 14);
AMap.invoke("polygonAddEventListener", "lineupdate", function (e) {
let pathArr = self.polygon.getPath();
self.emitPolyEvent(pathArr);
});
mapObj.add(self.polygon);
mapObj.setFitView([self.polygon]);
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
AMap.invoke("addOverlay", self.polygon);
} else {
self.mouseTool = new AMap.MouseTool(mapObj);
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: "#1791fc",
fillOpacity: 0.4,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [30,10],
});
self.mouseTool.on("draw", function (event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
self.mouseTool.close();
self.emitPolyEvent();
});
var styleOptions = {
strokeColor: "#FF33FF", // 边线颜色
fillColor: "#1791fc", // 填充颜色。当参数为空时,圆形没有填充颜色
strokeWeight: 6, // 边线宽度,以像素为单位
strokeOpacity: 0.2, // 边线透明度,取值范围0-1
fillOpacity: 0.4, // 填充透明度,取值范围0-1
};
var labelOptions = {
borderRadius: "2px",
background: "#FF33FF",
border: "1px solid #E1E1E1",
color: "#703A04",
fontSize: "12px",
letterSpacing: "0",
padding: "5px",
};
self.drawingManager = AMap.invoke(
"DrawingManager",
mapService.mapInstance,
{
isOpen: true, // 是否开启绘制模式
enableDrawingTool: false,
enableCalculate: false, // 绘制是否进行测距测面
enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式
polylineOptions: styleOptions, // 线的样式
polygonOptions: styleOptions, // 多边形的样式
rectangleOptions: styleOptions, // 矩形的样式
labelOptions: labelOptions, // label样式
}
);
AMap.invoke(
"drawingManagerAddEventListener",
"polygoncomplete",
function (e) {
let overlays = e;
let pathArr = e.getPath();
// let resultArr = pathArr.map((item) => {
// return item.latLng
// })
self.emitPolyEvent(pathArr);
}
);
AMap.invoke("setDrawingMode", "polygon");
}
},
emitPolyEvent() {
let pathArr = this.polygon.getPath();
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat];
});
emitPolyEvent(resultArr) {
this.polygonPath = resultArr;
this.$emit("onUpdateMapData", {
polygonPath: this.polygonPath,
});
console.log(resultArr.join("|"));
},
bindPolyEvent(polyEditor) {
const self = this;
......@@ -634,4 +558,7 @@ export default {
}
}
}
.tangram-suggestion-main {
z-index: 9999 !important; /* 使用 !important 可以确保覆盖其他样式 */
}
</style>
\ No newline at end of file
......@@ -142,7 +142,7 @@
<script>
import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import mapService from "utils/mapBService.js";
import "utils/mapEvent.js";
import EventBus from "../../event-bus";
import { services } from "../../api";
......@@ -246,13 +246,14 @@ export default {
},
mounted() {
// store.dispatch('setFullsize', true)
let _this = this;
_this.$mapInit({version:'1.4.2'}).then(AMap => {
window.AMap = AMap;
_this.initMap();
})
this.initBMap();
},
methods: {
async initBMap() {
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.isInitMap = true;
},
initMap() {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
......
......@@ -20,15 +20,32 @@
:trigger-on-focus="false"
:placeholder="'请输入'+['6位以上设备号','6位以上车架号','2位以上姓名'][searchType-1]"
@select="handleSelect"> -->
<el-input :placeholder="placeholderText" v-model.trim="searchText" size="small" class="input-with-select"
@keyup.enter.native="searchSubmit">
<el-select v-model="searchType" @change="selectChange" slot="prepend" placeholder="请选择" size="small">
<el-input
:placeholder="placeholderText"
v-model.trim="searchText"
size="small"
class="input-with-select"
@keyup.enter.native="searchSubmit"
>
<el-select
v-model="searchType"
@change="selectChange"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option>
<!-- <el-option label="工单号" value="4"></el-option> -->
</el-select>
<el-button icon="el-icon-search" size="mini" slot="append" :loading="isSearching" @click="searchSubmit">
<el-button
icon="el-icon-search"
size="mini"
slot="append"
:loading="isSearching"
@click="searchSubmit"
>
</el-button>
<!-- <template slot-scope="{ item }">
<div style="margin: 0 -20px; font-size: 12px; " class="auto_item">
......@@ -47,33 +64,74 @@
</div>
<el-row type="flex" class="filter-entrance" justify="space-between">
<!-- <el-button type="text" @click="importDialogHidden=false;listDialogHidden=true;resultDialogHidden=true;">导入查询</el-button> -->
<el-button type="text" @click="
treeHidden = false;
listDialogHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
">组织</el-button>
<el-button type="text" @click="
listDialogHidden = false;
treeHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
">监控列表({{ getMonitorListVisibleCount }})</el-button>
<el-button
type="text"
@click="
treeHidden = false;
listDialogHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
"
>组织</el-button
>
<el-button
type="text"
@click="
listDialogHidden = false;
treeHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
"
>监控列表({{ getMonitorListVisibleCount }})</el-button
>
</el-row>
<div class="filter-dialog-set">
<div class="filter-dialog animated" :class="importDialogHidden ? 'fadeOut' : 'active fadeIn'">
<div
class="filter-dialog animated"
:class="importDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header">
导入查询
<i class="el-icon-close pull-right" @click.stop="importDialogHidden = true"></i>
<i
class="el-icon-close pull-right"
@click.stop="importDialogHidden = true"
></i>
</div>
<div class="filter-dialog-body">
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini">
<el-form
ref="form"
:model="form"
:rules="rules"
:inline="false"
size="mini"
>
<el-form-item label="" prop="filename">
<el-upload ref="upload" class="upload-wrap" action="vehicle/importSerchDevice" :on-change="changeFile"
:before-upload="beforeUpload" :multiple="false" :show-file-list="false" :on-success="successUpload"
:on-error="errorUpload" :data="uploadData" accept=".xlsx" :auto-upload="false">
<el-input v-model="form.filename" placeholder="未选取任何文件" class="input-with-select" size="small">
<el-select v-model="form.uploadType" slot="prepend" placeholder="请选择" size="small">
<el-upload
ref="upload"
class="upload-wrap"
action="vehicle/importSerchDevice"
:on-change="changeFile"
:before-upload="beforeUpload"
:multiple="false"
:show-file-list="false"
:on-success="successUpload"
:on-error="errorUpload"
:data="uploadData"
accept=".xlsx"
:auto-upload="false"
>
<el-input
v-model="form.filename"
placeholder="未选取任何文件"
class="input-with-select"
size="small"
>
<el-select
v-model="form.uploadType"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option>
......@@ -87,48 +145,104 @@
</div>
</el-upload>
</el-form-item>
<el-button type="primary" class="upload-sure-btn" size="small" @click="submitUpload"
:loading="importing" :disabled="uploadDisabled">确认</el-button>
<el-button size="mini" type="text" @click="downloadTpl" style="margin-left: 0px">下载模板</el-button>
<el-button
type="primary"
class="upload-sure-btn"
size="small"
@click="submitUpload"
:loading="importing"
:disabled="uploadDisabled"
>确认</el-button
>
<el-button
size="mini"
type="text"
@click="downloadTpl"
style="margin-left: 0px"
>下载模板</el-button
>
</el-form>
</div>
</div>
<div class="filter-dialog animated" :class="listDialogHidden ? 'fadeOut' : 'active fadeIn'">
<div
class="filter-dialog animated"
:class="listDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header monitor_dialog_header">
<span>监控列表({{ monitorList.itemArr.length }})</span>
<i class="el-icon-close pull-right" @click.stop="listDialogHidden = true"></i>
<i
class="el-icon-close pull-right"
@click.stop="listDialogHidden = true"
></i>
</div>
<div class="filter-dialog-body">
<el-row type="flex" class="sub-filter" justify="space-between">
<el-select v-model="monitorFilterType" placeholder="请选择" size="small" style="width: 100px">
<el-select
v-model="monitorFilterType"
placeholder="请选择"
size="small"
style="width: 100px"
>
<el-option label="全部" value=""></el-option>
<el-option label="有线" value="1"></el-option>
<el-option label="无线" value="0"></el-option>
</el-select>
<el-button type="primary" plain size="small"
@click="removeMonitorByGroup(monitorList.itemArr)">批量删除</el-button>
<el-button
type="primary"
plain
size="small"
@click="removeMonitorByGroup(monitorList.itemArr)"
>批量删除</el-button
>
</el-row>
<ul class="monitor-list" style="max-height: calc(100vh - 380px)">
<ul
class="monitor-list"
style="max-height: calc(100vh - 380px)"
>
<template v-for="(sn, key) in monitorList.itemArr">
<li class="monitor-list-item" :key="sn" @click="openMapInfoWindow(sn, monitorList[sn].source, monitorList[sn].vid)" v-if="key !== 'count' &&
monitorList[sn] &&
(monitorList[sn].source == monitorFilterType ||
monitorFilterType == '')
">
<span class="device-icon" :class="monitorList[sn].online ? '' : 'offline'"
v-show="monitorList[sn].online !== undefined"></span>
<li
class="monitor-list-item"
:key="sn"
@click="
openMapInfoWindow(
sn,
monitorList[sn].source,
monitorList[sn].vid
)
"
v-if="
key !== 'count' &&
monitorList[sn] &&
(monitorList[sn].source == monitorFilterType ||
monitorFilterType == '')
"
>
<span
class="device-icon"
:class="monitorList[sn].online ? '' : 'offline'"
v-show="monitorList[sn].online !== undefined"
></span>
<div class="user-info">
<p>
<span class="name">{{
monitorList[sn].name || "--"
}}</span>
<span>{{ sn }}({{ monitorList[sn].sourceType }})</span>
<span
>{{ sn }}({{ monitorList[sn].sourceType }})</span
>
</p>
<p>车架号:{{ monitorList[sn].standNo }}</p>
</div>
<span class="none_tip" v-show="!monitorList[sn].isHasPosition">无定位信息</span>
<el-button type="text" @click.stop="removeMonitor(monitorList[sn], true)"><i
class="fa fa-trash"></i></el-button>
<span
class="none_tip"
v-show="!monitorList[sn].isHasPosition"
>无定位信息</span
>
<el-button
type="text"
@click.stop="removeMonitor(monitorList[sn], true)"
><i class="fa fa-trash"></i
></el-button>
</li>
</template>
</ul>
......@@ -142,30 +256,56 @@
</div>
</div>
</div>
<div class="filter-dialog animated" :class="resultDialogHidden ? 'fadeOut' : 'active fadeIn'">
<div
class="filter-dialog animated"
:class="resultDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header">
查询结果
<i class="el-icon-close pull-right" @click.stop="resultDialogHidden = true"></i>
<i
class="el-icon-close pull-right"
@click.stop="resultDialogHidden = true"
></i>
</div>
<div class="filter-dialog-body">
<el-row type="flex" class="sub-filter" justify="space-between">
<el-select v-model="resultFilterType" placeholder="请选择" size="small" style="width: 100px">
<el-select
v-model="resultFilterType"
placeholder="请选择"
size="small"
style="width: 100px"
>
<el-option label="全部" value=""></el-option>
<el-option label="有线" value="1"></el-option>
<el-option label="无线" value="0"></el-option>
</el-select>
<el-button type="primary" plain size="small" @click="addMonitorByGroup">批量监控</el-button>
<el-button
type="primary"
plain
size="small"
@click="addMonitorByGroup"
>批量监控</el-button
>
</el-row>
<ul class="monitor-list">
<li class="monitor-list-item" v-for="item in resultList" :key="item.id" v-show="item.source == resultFilterType || resultFilterType == ''
">
<li
class="monitor-list-item"
v-for="item in resultList"
:key="item.id"
v-show="
item.source == resultFilterType || resultFilterType == ''
"
>
<div class="user-info">
<p>
<span class="name">{{ item.name }}</span><span>{{ item.sn }}({{ item.sourceType }})</span>
<span class="name">{{ item.name }}</span
><span>{{ item.sn }}({{ item.sourceType }})</span>
</p>
<p>车架号:{{ item.standNo }}</p>
</div>
<el-button type="text" @click.prevent="addMonitor(item)">监控</el-button>
<el-button type="text" @click.prevent="addMonitor(item)"
>监控</el-button
>
</li>
<li v-show="!resultList.length">
<p class="text-center">无数据</p>
......@@ -173,24 +313,50 @@
</ul>
</div>
</div>
<div class="filter-dialog" :class="treeHidden ? 'fadeOut' : 'active fadeIn'">
<div
class="filter-dialog"
:class="treeHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header monitor_dialog_header">
<i class="el-icon-refresh i_refresh" title="重置组织" @click.stop="restInitTree"></i>
<i
class="el-icon-refresh i_refresh"
title="重置组织"
@click.stop="restInitTree"
></i>
<span>组织</span>
<i class="el-icon-close pull-right" @click.stop="treeHidden = true"></i>
<i
class="el-icon-close pull-right"
@click.stop="treeHidden = true"
></i>
</div>
<div class="filter-dialog-body">
<div class="monitor-list">
<el-tree ref="tree" :key="treeKey" :data="treeData" :props="treeProps" lazy :load="loadNode"
show-checkbox node-key="id" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys"
@check="handleCheck" v-loading="treeLoading" @check-change="handleCheckChange">
<el-tree
ref="tree"
:key="treeKey"
:data="treeData"
:props="treeProps"
lazy
:load="loadNode"
show-checkbox
node-key="id"
:default-expanded-keys="expandedKeys"
:default-checked-keys="checkedKeys"
@check="handleCheck"
v-loading="treeLoading"
@check-change="handleCheckChange"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="node.data.leaf">
<div>姓名:{{ node.data.label1 || "--" }}</div>
<div>设备号:{{ node.data.label || "--" }}</div>
<div>车架号:{{ node.data.label2 }}</div>
<div class="load_more_link" v-if="data.showMore" v-loading="loadingMore"
@click="loadNext(node, data)">
<div
class="load_more_link"
v-if="data.showMore"
v-loading="loadingMore"
@click="loadNext(node, data)"
>
查看更多
</div>
</div>
......@@ -212,7 +378,8 @@
import "@/assets/spritesmith-generated/sprite.css";
//import store from "@/vuex/store.js";
//import remoteLoad from "@/utils/remoteLoad.js";
import mapService from "@/utils/mapService.js";
// import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js";
//import monitor from '@/utils/monitor'
import EventBus from "@/event-bus";
......@@ -287,7 +454,7 @@ export default {
loadingMore: false,
placeholderText: "请输入6位以上车架号",
vidCode: undefined,
sourceType: 0
sourceType: 0,
};
},
computed: {
......@@ -443,7 +610,7 @@ export default {
params = { uId: data.id };
}
console.log("勾选树:", data);
// console.log("勾选树:", data);
params.termType = this.searchType;
params.term = this.searchText;
......@@ -464,9 +631,9 @@ export default {
//return false;
}
console.log(list);
let defaultVid = list && list.length ? list[list.length-1].vid : null
localStorage.setItem('vehicleId', defaultVid)
// console.log(list);
let defaultVid = list && list.length ? list[list.length - 1].vid : null;
localStorage.setItem("vehicleId", defaultVid);
let items = [];
items = list.map((item) => {
return {
......@@ -477,7 +644,7 @@ export default {
id: item.id,
source: item.source === "有线" ? "1" : "0",
sourceType: item.source,
vid: item.vid
vid: item.vid,
};
});
......@@ -554,7 +721,7 @@ export default {
node.data.test = true;
} else {
if (origin.type === "u") {
console.log("u");
// console.log("u");
let oParams = {};
oParams.uId = nodeData.id;
oParams.termType = this.searchType;
......@@ -585,7 +752,7 @@ export default {
return resolve(nodeData.children);
} else {
if (origin.type === "u") {
console.log("进入此处");
// console.log("进入此处");
let oParams = {};
oParams.uId = nodeData.id;
if (this.searchText) {
......@@ -646,51 +813,33 @@ export default {
resolve(data);
}, 500);
},
initMap() {
let check = () => {
this.checkLoadedTimeoutId &&
window.clearTimeout(this.checkLoadedTimeoutId);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
this.isInitMap = true;
if (this.$route.query.snArr) {
let routeQuery = JSON.parse(this.$route.query.snArr);
if (routeQuery.length > 0) {
/* this.addMonitor(routeQuery[0]);
this.autoOpenLastInfoWindow = true; */
routeQuery.forEach((item) => {
this.addMonitor(item);
});
this.autoOpenLastInfoWindow = true;
this.listDialogHidden = false;
}
}
if (this.$route.query.vin) {
MONITOR_SERVICE.getVehicleTree({
termType: 2,
term: this.$route.query.vin,
returnTrees: true,
}).then((res) => {
const items = res.data;
this.autoOpenLastInfoWindow = true;
this.expandTreeItems(items);
});
this.treeHidden = false;
this.listDialogHidden = true;
}
} else {
this.checkLoadedTimeoutId = check();
}
}, 100);
};
this.checkLoadedTimeoutId = check();
async initBMap() {
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.isInitMap = true;
if (this.$route.query.snArr) {
let routeQuery = JSON.parse(this.$route.query.snArr);
if (routeQuery.length > 0) {
routeQuery.forEach((item) => {
this.addMonitor(item);
});
this.autoOpenLastInfoWindow = true;
this.listDialogHidden = false;
}
}
if (this.$route.query.vin) {
MONITOR_SERVICE.getVehicleTree({
termType: 2,
term: this.$route.query.vin,
returnTrees: true,
}).then((res) => {
const items = res.data;
this.autoOpenLastInfoWindow = true;
this.expandTreeItems(items);
});
this.treeHidden = false;
this.listDialogHidden = true;
}
},
keyupSubmit() {
document.onkeydown = (e) => {
......@@ -773,13 +922,16 @@ export default {
term: this.searchText,
}).then((res) => {
this.isSearching = false;
console.log(res);
// console.log(res);
let list = res.data || [];
if (!list || list.length <= 0) {
return false;
}
this.vidCode = list[0].vid;
localStorage.setItem('vehicleId', list && list[0] ? list[0].vid : null)
localStorage.setItem(
"vehicleId",
list && list[0] ? list[0].vid : null
);
for (var i = 0, len = list.length; i < len; i++) {
_this.handleSelect(list[i]);
}
......@@ -807,12 +959,12 @@ export default {
let _this = this;
arr.forEach((item) => {
if (isDevice) {
console.log(item.id);
// console.log(item.id);
let keys = _this.$refs.tree.getCheckedKeys();
console.log("keys", keys);
// console.log("keys", keys);
//_this.$refs.tree.setCheckedKeys(keys);
_this.checkedKeys.push(item.id);
console.log("勾选key:", _this.checkedKeys);
// console.log("勾选key:", _this.checkedKeys);
_this.$refs.tree.setCheckedKeys(_this.checkedKeys);
this.addMonitor({
sn: item.label,
......@@ -822,12 +974,12 @@ export default {
id: item.id,
source: item.source === "有线" ? "1" : "0",
sourceType: item.source,
vid: item.vid
vid: item.vid,
});
} else {
console.log("展开节点", item);
// console.log("展开节点", item);
this.expandedKeys.push(item.id);
console.log(this.expandedKeys);
// console.log(this.expandedKeys);
}
if (item.children && item.children.length) {
this.expandTreeItems(
......@@ -923,7 +1075,7 @@ export default {
_this.currentMessage = this.$message({
type: "error",
message: "该列表中有设备正在监控中,请勿重复监控",
onClose: function() {
onClose: function () {
_this.currentMessage = "";
},
});
......@@ -941,15 +1093,6 @@ export default {
}
this.getPositionData();
},
// standNoMonitor(item){
// this.resetRefreshCount = true;
// this.monitorList.count++;
// for (let i in item) {
// this.monitorList[item.sn] = item[i].sn;
// }
// this.getPositionData();
// },
// 批量监控
addMonitorByGroup(items) {
......@@ -1034,8 +1177,6 @@ export default {
// 获取设备位置点
getPositionData(arr) {
/* let _this = this;
arr = arr.filter((item)=>this.monitorList[item.sn]); */
let snStr = this.monitorList.itemArr.join(","); //arr.map((item)=>item.sn).join(',');
if (!snStr) return;
if (this.resetRefreshCount || this.remainSearchSnStr != snStr) {
......@@ -1065,9 +1206,10 @@ export default {
item.eLocateType = relItem.eLocateType;
item = this.filterGpsBase(item);
console.log("filterGpsBase", item);
item.isSource = relItem.source;
item.vidCode = this.vidCode
item.sourceType = this.sourceType
item.vidCode = this.vidCode;
item.sourceType = this.sourceType;
});
this.monitorList = Object.assign({}, this.monitorList);
let drawData = data.filter(
......@@ -1080,6 +1222,7 @@ export default {
this.monitorList.itemArr.length > 0
) {
this.autoOpenLastInfoWindow = true;
console.log("drawData", drawData);
EventBus.$emit(
"uiMap.monitor.draw",
drawData,
......@@ -1152,7 +1295,7 @@ export default {
return item;
},
errorUpload(err) {
console.log(err);
// console.log(err);
//window.location.href = '../ots/login';
},
drawDoneCb() {
......@@ -1173,13 +1316,14 @@ export default {
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
},
openMapInfoWindow(sn, source, vid) {
localStorage.setItem('vehicleId', vid)
localStorage.setItem("vehicleId", vid);
EventBus.$emit("uiMap.monitor.openInfoWindow", `${sn}:${source}`);
},
downloadTpl() {
exportExcel("vehicle/downLoadImportSearchModel");
},
changeELocate(item) {
console.log("changeELocate", item);
this.monitorList[item.sn].eLocateType = item.eLocateType;
//item.eLocateType = item.eLocateType==='gpsLocation'?'bsLocation':'gpsLocation'
},
......@@ -1261,7 +1405,7 @@ export default {
let oParams = {};
oParams.sns = sns;
GET_MONITOR_ONLINELIST(oParams).then((res) => { });
GET_MONITOR_ONLINELIST(oParams).then((res) => {});
},
},
created() {
......@@ -1273,11 +1417,14 @@ export default {
this.getTreeData();
},
mounted() {
let _this = this;
_this.$mapInit({ version: "2.0" }).then((AMap) => {
window.AMap = AMap;
_this.initMap();
});
// let _this = this;
// _this.$mapInit({ version: "2.0" }).then((AMap) => {
// window.AMap = AMap;
// console.log("AMap:", AMap,window);
// _this.initMap();
// });
this.initBMap();
},
beforeDestroy() {
document.onkeydown = null;
......@@ -1316,7 +1463,7 @@ export default {
line-height: 26px;
}
.map-wrap .el-tree-node>.el-tree-node__children {
.map-wrap .el-tree-node > .el-tree-node__children {
overflow: visible;
}
......
......@@ -188,7 +188,8 @@
<script>
import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
// import mapService from "utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "utils/mapEvent.js";
import EventBus from "../../event-bus";
import { services } from "../../api";
......@@ -331,38 +332,17 @@ export default {
},
},
methods: {
initMap() {
let _this = this;
let check = () => {
_this.checkMapLoaded && window.clearTimeout(_this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!_this.mapObj
) {
window.AMap = AMap;
_this.mapObj = mapService.init("map");
//this.bindEvent();
_this.isInitMap = true;
//_this.drawPoi();
console.log(_this.fenceId != "undefined");
if (
_this.isInitFence &&
_this.fenceId &&
_this.fenceId != "undefined"
async initBMap(){
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.isInitMap = true;
if (
this.isInitFence &&
this.fenceId &&
this.fenceId != "undefined"
) {
//_this.drawFence();
_this.getFence();
this.getFence();
}
} else {
_this.checkMapLoaded = check();
}
}, 100);
};
_this.checkMapLoaded = check();
},
pickDate(recentHoursOrDays) {
let unit = "days";
......@@ -668,8 +648,6 @@ export default {
drawPoi() {
let _this = this;
BUSINESS_SERVICE.getPOI({ sn: _this.sn }).then((res) => {
console.log("666666666666");
console.log(res);
if (res.returnCode === "0") {
if (res.data && res.data.length) {
res.data.forEach((item) => {
......@@ -687,48 +665,18 @@ export default {
}
});
},
drawFence() {
MONITOR_SERVICE.getSingleFence({
sn: this.sn,
fenceId: parseInt(this.fenceId),
}).then((res) => {
if (res.returnCode == 0) {
const data = res.data;
if (data) {
if (data.shapeType === 2) {
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: data.lng,
lat: data.lat,
radius: data.radius,
isEdit: false,
});
} else if (data.shapeType === 3) {
this.drawDistrict(data.areaCode);
} else if (data.shapeType === 5) {
if (data.lnglat) {
let polygonPath = data.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
this.drawPolygon(polygonPath);
}
}
}
}
});
},
// 行政区域围栏
drawDistrict(areaCode) {
drawDistrict(areaText) {
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId = setTimeout(() => {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
EventBus.$emit("uiMap.fence.drawDistrict", areaText);
}, 500);
},
// 多边形围栏
drawPolygon(path) {
console.log("path");
EventBus.$emit("uiMap.fence.drawPolygon", {
path,
isEdit: false,
......@@ -741,7 +689,6 @@ export default {
//sn: this.sn,
fenceId: this.fenceId,
}).then((res) => {
console.log(res);
let list = res.data || [];
if (res.code != 200) {
return false;
......@@ -767,31 +714,23 @@ export default {
// 行政区域围栏
if (obj.shapeType == 4) {
this.drawDistrict([obj.areaCode]);
this.drawDistrict([obj.areaText]);
}
});
},
},
created() {
let _this = this;
let _config = { version: "1.4.2" };
_config.AMapUI = {
version: "1.1",
plugins: ["/misc/PathSimplifier"],
};
_this.$mapInit(_config).then((AMap) => {
console.log(window.AMap);
_this.initMap();
// if (AMap) {
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// _this.initMap();
// }
// );
// }
});
// let _this = this;
// let _config = { version: "1.4.2" };
// _config.AMapUI = {
// version: "1.1",
// plugins: ["/misc/PathSimplifier"],
// };
// _this.$mapInit(_config).then((AMap) => {
// _this.initMap();
// });
this.initBMap();
//轨迹播放当前位置地址显示
EventBus.$on("uiMap.replay.currAddress", (adr) => {
this.replayAddr = adr;
......@@ -845,4 +784,5 @@ export default {
.clearMargin {
margin-left: 0px;
}
</style>
\ No newline at end of file
</style>
......@@ -101,7 +101,8 @@
<script>
import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
// import mapService from "utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "utils/mapEvent.js";
import EventBus from "../../event-bus";
import { services } from "../../api";
......@@ -142,36 +143,13 @@ export default {
};
},
mounted() {
// store.dispatch('setFullsize', true)
let _this = this;
_this.$mapInit({ version: "1.4.2" }).then((AMap) => {
window.AMap = AMap;
_this.initMap();
});
this.initBMap();
},
methods: {
initMap() {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
//this.bindEvent();
this.isInitMap = true;
// this.drawPoi()
} else {
this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
async initBMap() {
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.isInitMap = true;
},
pickDate(beforeDays) {
this.form.dateRange = [
......@@ -279,35 +257,6 @@ export default {
exportExcel() {
if (this.exporting) return;
if (this.resultList.length) {
// let paramArr = [];
// this.resultList.forEach((dataItem)=>{
// let paramItem = {};
// for(let key in dataItem){
// switch(key){
// case 'name':
// case 'shopName':
// case 'sn':
// case 'sqbh':
// case 'standNo':
// case 'totalDurationString':
// case 'transferAddress':
// paramItem[key] = dataItem[key]?dataItem[key]:'';
// break;
// case 'totalTimes':
// paramItem[key] = dataItem[key]?(dataItem[key]+'次'):'';
// break;
// /*case 'transferAddress':
// paramItem.address = dataItem.transferAddress?dataItem.transferAddress:'';
// break;*/
// }
// }
// paramArr.push(paramItem);
// });
// exportExcel('track/exportVMData', {
// jsonStr: encodeURI(JSON.stringify(paramArr)),
// vmExportType: 4
// }, 'post');
exportExcel(
"/trialdrive/monitor/exportResident",
{ ...this.params },
......@@ -349,7 +298,6 @@ export default {
},
},
async created() {
EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
this.resultList = [].concat(data);
});
......
......@@ -160,7 +160,8 @@
</v-full-layout>
</template>
<script>
import mapService from "@/utils/mapService.js";
// import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js";
import { CONSTANT } from "@/constant";
import {
......@@ -222,136 +223,174 @@ export default {
};
},
mounted() {
this.initMap();
// this.initMap();
this.initBMap();
},
methods: {
// 地图初始化
initMap() {
let _this = this;
let plugins = CONSTANT.MAP_PLUGINS.concat([
"AMap.LngLat",
"AMap.Rectangle",
"AMap.LabelsLayer",
"AMap.LabelMarker",
"AMap.AutoComplete",
"AMap.MassMarks",
"AMap.MarkerCluster",
"AMap.Bounds",
"AMap.MouseTool"
]);
_this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 11, showLabel: false });
_this.mouseTool = new AMap.MouseTool(_this.map);
var autoComplete = new AMap.AutoComplete({
input: "tipInput",
});
autoComplete.on("select", function (e) {
console.log(e);
let poi = e.poi || {};
_this.poi = poi;
_this.$set(_this.form, "address", poi.name);
_this.$refs.addressInput.focus();
});
// 判断是否为全屏,是否带参数,如果带了矩形参数,则默认画一个矩形
let _query = _this.$route.query;
if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query);
}
// 给地图添加文字图层
_this.map.add([new AMap.TileLayer()]);
async initBMap() {
this.mapObj = await mapService.init("map");
this.mapLoading = false;
window.AMap = this.mapObj;
this.autoComplete = AMap.invoke("Autocomplete", {
input: "tipInput",
});
AMap.invoke("autocompleteShow");
AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
this.poi = e.item.value;
this.$set(this.form, "address", this.poi.address);
this.$refs.addressInput.focus();
});
// 判断是否为全屏,是否带参数,如果带了矩形参数,则默认画一个矩形
let _query = this.$route.query;
if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query);
}
},
// 获取地址
getAddress() {
let _this = this;
let poi = this.poi;
_this.clearMap();
if (poi && poi.location) {
AMap.invoke("panTo", poi.location, true);
_this.autoCenterMarker = mapService.createMarker(poi.location);
_this.map.setFitView();
_this.map.add(_this.autoCenterMarker);
AMap.invoke("addOverlay", _this.autoCenterMarker);
AMap.invoke("setZoom", 16);
}
},
// 选择区域
async chooseArea() {
let _this = this;
let _map = this.map;
let _zoom = _map.getZoom();
const _this = this;
const MAP = mapService.map;
// let _zoom = _map.getZoom();
if (_this.rectangle) {
showToast({
message: "地图上已有矩形,请先清除再画",
});
return false;
}
// if (_zoom < 11) {
// _this.map.setZoom(11);
// }
// _this.map.setZooms([11, 30]);
var styleOptions = {
fillColor: "#2C68FF",
strokeColor: "#2C68FF",
fillOpacity: 0.3, // 填充透明度,取值范围0-1
strokeWeight: 4, // 边线宽度,以像素为单位
strokeOpacity: 1, // 边线透明度,取值范围0-1
fillColor: "#1791fc", // 填充颜色。当参数为空时,圆形没有填充颜色
};
var labelOptions = {
borderRadius: "2px",
background: "#FF33FF",
border: "1px solid #E1E1E1",
color: "#703A04",
fontSize: "12px",
letterSpacing: "0",
padding: "5px",
};
_this.drawingManager = MAP.invoke(
"DrawingManager",
mapService.mapInstance,
{
isOpen: true, // 是否开启绘制模式
enableDrawingTool: false,
enableCalculate: true, // 绘制是否进行测距测面
enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式
polylineOptions: styleOptions, // 线的样式
polygonOptions: styleOptions, // 多边形的样式
rectangleOptions: styleOptions, // 矩形的样式
labelOptions: labelOptions, // label样式
}
);
MAP.invoke(
"drawingManagerAddEventListener",
"rectanglecomplete",
function (e) {
console.log(e);
_this.rectangle = e;
let bounds = e.getBounds();
_this.calculateWidthHeight(bounds);
}
);
MAP.invoke("setDrawingMode", "rectangle");
// if (_this.mouseTool) {
// _this.mouseTool.rectangle({
// fillColor: "#2C68FF",
// strokeColor: "#2C68FF",
// fillOpacity: 0.3,
// strokeWeight: 4,
// strokeOpacity: 1,
// draggable: true,
// });
// _this.mouseTool.on("draw", function (e) {
// let rectangle = e.obj;
// _this.mouseTool.close();
// return false;
// _this.rectangle = rectangle;
// _this.calculateWidthHeight(rectangle.getOptions().bounds);
// });
// }
if (_zoom < 11) {
_this.map.setZoom(11);
}
_this.map.setZooms([11, 30]);
if (_this.mouseTool) {
_this.mouseTool.rectangle({
fillColor: "#2C68FF",
strokeColor: "#2C68FF",
fillOpacity: 0.3,
strokeWeight: 4,
strokeOpacity: 1,
draggable: true,
});
_this.mouseTool.on("draw", function (e) {
let rectangle = e.obj;
_this.mouseTool.close();
_this.rectangle = rectangle;
_this.calculateWidthHeight(rectangle.getOptions().bounds);
});
}
},
getDistance(lat1, lon1, lat2, lon2) {
var R = 6371e3; // 地球半径,单位:米
var rad = Math.PI / 180;
var lat1Rad = lat1 * rad;
var lon1Rad = lon1 * rad;
var lat2Rad = lat2 * rad;
var lon2Rad = lon2 * rad;
var deltaLat = lat2Rad - lat1Rad;
var deltaLon = lon2Rad - lon1Rad;
var a =
Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
Math.cos(lat1Rad) *
Math.cos(lat2Rad) *
Math.sin(deltaLon / 2) *
Math.sin(deltaLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c; // 距离,单位:米
},
// 计算矩形宽度、高度
calculateWidthHeight(lnglats) {
if (!lnglats) {
return {};
}
// 左下角点坐标
let southWest = lnglats.southWest || {};
let southWest = lnglats.getSouthWest() || {};
// 右上角点坐标
let northEast = lnglats.northEast || {};
// 计算高度
let _height = AMap.GeometryUtil.distance(
[southWest.lng, southWest.lat],
[southWest.lng, northEast.lat]
);
// 计算宽度
let _width = AMap.GeometryUtil.distance(
[southWest.lng, southWest.lat],
[northEast.lng, southWest.lat]
);
this.rectangleHeight = _height.toFixed(0);
this.rectangleWidth = _width.toFixed(0);
let northEast = lnglats.getNorthEast() || {};
console.log(southWest, northEast);
// 计算长和宽
var width = this.getDistance(
southWest.lat,
southWest.lng,
northEast.lat,
southWest.lng
); // 西到东的距离
var height = this.getDistance(
southWest.lat,
southWest.lng,
southWest.lat,
northEast.lng
); // 南到北的距离
console.log(width, height);
this.rectangleHeight = width.toFixed(0);
this.rectangleWidth = height.toFixed(0);
},
// 清空地图覆盖物
clearMap() {
if (this.map) {
this.map.clearMap();
}
AMap.invoke("clearOverlays");
this.rectangleHeight = 0;
this.rectangleWidth = 0;
this.rectangle = null;
//this.mouseTool = null;
this.deviceList = [];
this.map.setZooms([2, 30]);
},
// 清空筛选条件
......@@ -361,10 +400,6 @@ export default {
this.rectangleWidth = 0;
this.form = {};
this.deviceList = [];
if (this.mouseTool) {
this.mouseTool.close(true);
//this.mouseTool = null;
}
},
// 展开
......@@ -426,10 +461,22 @@ export default {
return {};
}
let params = {};
let o = this.rectangle.getOptions();
let bounds = o.bounds || {};
params.leftLngLat = `${bounds.southWest.lng},${bounds.southWest.lat}`;
params.rightLngLat = `${bounds.northEast.lng},${bounds.northEast.lat}`;
let bounds = this.rectangle.getBounds() || {};
params.leftLngLat = `${bounds.getSouthWest().lng},${
bounds.getSouthWest().lat
}`;
params.rightLngLat = `${bounds.getNorthEast().lng},${
bounds.getNorthEast().lat
}`;
console.log(this.rectangle.getPath());
let pathArr = this.rectangle.getPath();
try {
pathArr = pathArr.map((item) => {
return item.lng + "," + item.lat;
});
params.paths = pathArr.join("|");
} catch (error) {}
return params;
},
......@@ -444,6 +491,7 @@ export default {
}
this.dloading = true;
delete params.paths;
let res = await GER_REGIONAL_EXPORT(params);
this.dloading = false;
if (res.code != 200) {
......@@ -517,19 +565,6 @@ export default {
_this.addMarkers(arr);
});
});
// if (!this.form.sn) {
// showToast({
// message: "请输入设备号",
// });
// return false;
// }
// if (!Validator.ISDECIMAL.test(this.form.sn)) {
// showToast({
// message: "设备号必须为纯数字",
// });
// return false;
// }
},
// 区域查车
......@@ -548,7 +583,7 @@ export default {
_this.deviceList = [];
if (_this.mapMass) {
_this.mapMass.clear();
AMap.invoke("clearOverlays");
_this.mapMass = null;
}
if (_options.type != "full") {
......@@ -557,7 +592,9 @@ export default {
}
_this.loading = true;
delete params.paths;
let res = await GER_REGIONAL_SEARCH(params);
console.log(res, "res");
_this.loading = false;
if (res.code != 200) {
showToast({
......@@ -575,82 +612,39 @@ export default {
drawDistrict(areaCode) {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
},
// 添加海量点 聚合点方式
// addMarkers3(arr) {
// let _this = this;
// let markers = [];
// let icon = {
// url: require("images/icon_car.png"),
// size: new AMap.Size(24, 15),
// offset: new AMap.Pixel(4, 4),
// };
// let renderMarker = function (context) {
// console.log(context.data);
// var content = '<div style="background-color: hsla(180, 100%, 50%, 0.3); height: 18px; width: 18px; border: 1px solid hsl(180, 100%, 40%); border-radius: 12px; box-shadow: hsl(180, 100%, 50%) 0px 0px 3px;"></div>';
// //context.marker.setIcon(require("images/icon_car.png"))
// context.marker.setContent(content)
// context.marker.setSize(24,15);
// // let m = new AMap.Marker({
// // icon: require("images/icon_car.png"),
// // position: context.data[0].lnglat,
// // });
// };
// for (let i = 0, len = arr.length; i < len; i++) {
// let k = arr[i];
// k.lnglat = [k.lng, k.lat];
// markers.push(k);
// }
// let params = {
// gridSize: 60,
// renderMarker: renderMarker,
// };
// let cluster = new AMap.MarkerCluster(_this.map, markers, params);
// },
// 添加海量点 (MassMarks方式)
addMarkers(arr) {
let _this = this;
let markers = [];
let icon = {
type: "image",
url: require("images/icon_car.png"),
size: [24, 15],
anchor: new AMap.Pixel(4, 4),
};
console.log(arr);
for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i];
k.lnglat = [k.lng, k.lat];
markers.push(k);
console.log(k);
let lnglat = mapService.getLngLat(k.lng, k.lat);
let marker = mapService.createCarMarker(lnglat);
markers.push(marker);
AMap.invoke("addOverlay", marker);
AMap.invoke("panTo", lnglat);
AMap.invoke("markerAddEventListener", "click", (e) => {
console.log(e);
let infoWindow = mapService.createAraeInfowindow(k);
AMap.invoke("mapOpenInfoWindow", infoWindow, e.target.getPosition());
});
}
var mass = new AMap.MassMarks(markers, {
opacity: 0.8,
zIndex: 111,
cursor: "pointer",
style: icon,
alwaysRender: false,
});
mass.on("click", function (e) {
console.log(e);
let infoWindow = mapService.createAraeInfowindow(e.data);
infoWindow.open(_this.map);
});
mass.setMap(_this.map);
this.drawDone = true;
if (arr && arr.length < 10) {
this.map.setFitView();
}
this.mapMass = mass;
// if (arr && arr.length < 10) {
// // this.map.setFitView();
// }
this.mapMass = markers;
},
// 全屏状态下,根据参数初始化页面
initPage(query) {
console.log(query);
this.menuId = query.menuId;
if (query.address) {
this.$set(this.form, "address", query.address);
}
if (query.sn) {
this.$set(this.form, "sn", query.sn);
}
......@@ -662,41 +656,58 @@ export default {
// 如果是地址,则标记出对应的点
if (query.menuId == 1 && query.lng) {
let poi = new AMap.LngLat(query.lng, query.lat);
let poi=AMap.invoke('Point',query.lng, query.lat)
this.autoCenterMarker = mapService.createMarker(poi);
this.map.add(this.autoCenterMarker);
AMap.invoke('addOverlay',this.autoCenterMarker);
AMap.invoke("panTo", poi);
}
this.drawRectangle(query);
this.getAreaLocation();
this.autoComplete.setInputValue(this.form.address);
},
// 绘画矩形
drawRectangle(query) {
let leftLngLat = query.leftLngLat.split(",");
let rightLngLat = query.rightLngLat.split(",");
let southWest = new AMap.LngLat(leftLngLat[0], leftLngLat[1]);
let northEast = new AMap.LngLat(rightLngLat[0], rightLngLat[1]);
let bounds = new AMap.Bounds(southWest, northEast);
let rectangle = new AMap.Rectangle({
bounds: bounds,
const MAP = mapService.map;
let arr = query.paths.split("|");
let pathArr = arr.map((item) => {
let lnglat = item.split(",");
return mapService.getLngLat(lnglat[0], lnglat[1]);
});
console.log(pathArr);
const overlay = AMap.invoke("Polygon", pathArr, {
fillColor: "#2C68FF",
strokeColor: "#2C68FF",
fillOpacity: 0.3,
strokeWeight: 4,
strokeOpacity: 1,
draggable: true,
enableLimit: false,
enableCalculate: false,
});
this.map.add(rectangle);
this.rectangle = rectangle;
this.calculateWidthHeight(rectangle.getOptions().bounds);
let _zoom = this.map.getZoom();
AMap.invoke("addOverlay", overlay);
console.log(overlay);
AMap.invoke("rectOpenEdit", overlay,{
isOpen:false,
enableDragging:true
}); //开启编辑
// AMap.invoke("rectCloseEdit"); //关闭编辑
// AMap.invoke("rectAddEventListener", "operate-change", (e) => {
// console.log(e.target);
// });
this.rectangle=overlay
this.calculateWidthHeight(overlay.getBounds());
let _zoom = AMap.invoke("getZoom");
AMap.invoke("setZoom",24)
console.log(_zoom);
if (_zoom < 11) {
this.map.setZoom(11);
AMap.invoke("setZoom",11)
}
this.map.setZooms([11, 30]);
this.map.setFitView();
AMap.invoke("panTo", pathArr[0], true);
},
// 跳转全屏页面
......@@ -721,8 +732,7 @@ export default {
if (this.form.sn) {
m.sn = this.form.sn;
}
console.log(qs.stringify(m));
m.paths = params.paths;
let _path = `oEshield#/monitor/zoneCar?type=full&` + qs.stringify(m);
window.open(_path);
},
......
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-20 11:07:37
* @FilePath: \oEshield\src\utils\fence.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import EventBus from '@/event-bus'
import mapService from './mapService.js'
import MAPGEO from './mapgeo'
// import mapService from './mapService.js'
import mapService from './mapBService.js'
// import MAPGEO from './mapgeo'
import MAPGEO from './mapBgeo'
//电子围栏
const fence = {
polygons: [],
circle: null,
dist:null,
drawingManager:null,
isEditMode: true,
marker:'',
bindEvent() {
EventBus.$on('uiMap.fence.drawDistrict', (data) => {
this.drawDistrict(data)
......@@ -32,13 +45,15 @@ const fence = {
});
EventBus.$on('uiMap.fence.drawPolygon', (data) => {
if (data) {
if (Array.isArray(data)) {
this.polygonPath = data;
this.isEditMode = true;
} else if (('isEdit' in data) && !data.isEdit) {
this.polygonPath = data.path;
let arr= data.path.map(item=>{
return mapService.getLngLat(item[0], item[1])
})
this.polygonPath =arr;
this.isEditMode = false;
}
}
......@@ -53,129 +68,111 @@ const fence = {
destroy() {
const MAP = mapService.map;
if (MAP) {
this.polygons && MAP.remove(this.polygons);
this.circle && MAP.remove(this.circle);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor);
this.polygons = [];
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
this.polygon && MAP.remove(this.polygon)
// // MAP.invoke('removeOverlay',this.polygons)
// this.polygon &&MAP.invoke('removeOverlay',this.polygon);
// this.circle && MAP.invoke('removeOverlay',this.circle);
// this.drawingManager && MAP.invoke('removeOverlay',this.drawingManager);
AMap.invoke('clearOverlays');
AMap.invoke('addOverlay',this.marker)
//清除多边形
if( this.drawingManager&&this.drawingManager.getOverlays().length){
let overlays=this.drawingManager.getOverlays()[0]
AMap.invoke('removeOverlay',overlays);
}
if(document.getElementById('cancelOperate')){
document.getElementById('cancelOperate').click()
}
this.dist&& MAP.invoke('removeDistrictLayer', this.dist)
// this.polygons = [];
// this.polyEditor && this.polyEditor.close()
// this.mouseTool && this.mouseTool.close()
}
//this.clearTimeoutIds();
},
// 行政区域
drawDistrict(data) {
const MAP = mapService.map;
this.destroy();
if (!data || data.length <= 0) {
return false;
}
var opts = {
subdistrict: 0, //返回下一级行政区
extensions: 'all',
showbiz: false //最后一级返回街道信息
};
let oParams = data[data.length - 1];
//data == "中国" ? delete opts.extensions : delete opts.showbiz;
let district = new AMap.DistrictSearch(opts);
switch (data.length) {
case 1:
district.setLevel('province');
break;
case 2:
district.setLevel('city');
break;
default:
district.setLevel('district');
break;
if ( this.dist) AMap.invoke('removeDistrictLayer', this.dist)
this.dist = AMap.invoke('DistrictLayer', {
name: `(${data[data.length-1]})`,
fillOpacity: 0.7,
fillColor: '#CCF3FF',
strokeColor: '#CC66CC',
viewport: true
});
AMap.invoke('addDistrictLayer', this.dist)
},
updateFenceCircle(data){
AMap.invoke('circleDisableEditing')
if( data.radius&&this.circle){
this.circle.setRadius(data.radius * 1)
}
//EventBus.$emit('uiMap.fence.loading', true);
//行政区查询
district.search(oParams, function (status, result) {
console.log(result)
const dst = result.districtList[0];
var bounds = dst.boundaries;
let lng = dst.center.lng;
let lat = dst.center.lat;
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
var polygon = new AMap.Polygon({
map: MAP,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.7,
fillColor: '#CCF3FF',
strokeColor: '#CC66CC',
});
fence.polygons.push(polygon);
}
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
//EventBus.$emit('uiMap.fence.loading', false);
}
});
if(data.lng&&data.lat){
let center = mapService.getLngLat(data.lng, this.lat);
this.circle&& this.circle.setCenter(center);
AMap.invoke('panTo',center,true)
}
AMap.invoke('removeOverlay', this.circle)
AMap.invoke('addOverlay', this.circle)
AMap.invoke('circleEnableEditing')
},
createFenceCircle(data) {
let _this = this
const MAP = mapService.map;
_this.destroy();
let mapInterval = setInterval(() => {
if (MAP) {
clearInterval(mapInterval)
console.log(data)
let lng = data.lng || _this.lng
let lat = data.lat || _this.lat
if (data.lng) {
_this.lng = data.lng
}
if (data.lat) {
_this.lat = data.lat
}
_this.circle = new AMap.Circle({
map: MAP,
center: mapService.getLngLat(lng, lat),
radius: data.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
zIndex: 0,
});
_this.circleEditor = new AMap.CircleEditor(MAP, _this.circle);
_this.circleEditor.on('adjust', function (e) {
console.log('监听圆心改变', e)
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius / 1)
})
_this.circleEditor.on('move', function (e) {
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: e.lnglat.lng,
lat: e.lnglat.lat
});
})
if (_this.isEditMode) {
_this.circleEditor.open();
} else {
_this.circleEditor.close();
if(!this.circle){
let _this = this
const mapInstance= mapService.mapInstance
let mapInterval = setInterval(() => {
if (AMap) {
clearInterval(mapInterval)
let lng = data.lng || _this.lng
let lat = data.lat || _this.lat
if (data.lng) {
_this.lng = data.lng
}
if (data.lat) {
_this.lat = data.lat
}
const lnglat=mapService.getLngLat(lng, lat)
let options={
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
enableEditing:true
}
if(!_this.isEditMode) options.enableEditing=false
_this.circle=AMap.invoke('Circle',lnglat,data.radius * 1,options)
AMap.invoke('panTo',lnglat,true)
AMap.invoke('addOverlay',_this.circle)
AMap.invoke('setZoom',14)
_this.bindContextMenu()
AMap.invoke('circleAddEventListener','lineupdate',function(e){
let overlay=e.overlay
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng:e.overlay.getCenter().lng,
lat:e.overlay.getCenter().lat
});
EventBus.$emit('uiMap.fence.onFenceRadiusChange', parseInt(overlay.getRadius() / 1))
})
}
mapService.setFitView()
MAP.setZoom(14);
_this.bindContextMenu()
}
}, 100);
}, 2000);
}else{
this.destroy();
this.updateFenceCircle(data)
}
},
createFenceMarker(data) {
this.data = [{
elng: data.lngGPS,
elat: data.latGPS
......@@ -186,69 +183,77 @@ const fence = {
elat: data.latBase
});
}
const MAP = mapService.map;
//MAPGEO.transferAddressByGroup(this, ()=>{
//data.transferAddressGPS = this.data[0].transferAddress;
// if(this.data.length > 1){
// data.transferAddressBase = this.data[1].transferAddress;
// }
console.log(data)
let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP);
let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data);
//});
const getLngLat=mapService.getLngLat(data.lngGPS,data.latGPS)
this.marker = mapService.createCarMarker(getLngLat, AMap);
let infoWindow = mapService.bindFenceInfoWindow( this.marker, AMap, data);
AMap.invoke('addOverlay',this.marker)
},
drawPolygon() {
const MAP = mapService.map;
const self = this;
this.destroy();
if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({
path: this.polygonPath,
let options={
zIndex: 10,
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
fillColor: '#1791fc',
zIndex: 50,
})
MAP.add(self.polygon)
MAP.setFitView([self.polygon])
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
if (self.isEditMode) {
self.polyEditor.open()
} else {
self.polyEditor.close()
enableEditing:true
}
self.bindPolyEvent(self.polyEditor)
} else if (self.isEditMode) {
self.mouseTool = new AMap.MouseTool(MAP)
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: '#1791fc',
fillOpacity: 0.4,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [30,10],
})
self.mouseTool.on('draw', function (event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
self.polyEditor.open()
self.bindPolyEvent(self.polyEditor)
self.mouseTool.close()
self.emitPolyEvent()
if(!self.isEditMode){
options.enableEditing=false
}
self.polygon=AMap.invoke('Polygon',this.polygonPath,options)
//获取多边形的中间位置
let lnglat=self.polygon.getBounds().getCenter()
//地图的中心点更改为给定的点
AMap.invoke('panTo',lnglat,true)
AMap.invoke('polygonAddEventListener','lineupdate',function(e){
let pathArr = self.polygon.getPath()
self.emitPolyEvent(pathArr)
})
AMap.invoke('addOverlay', self.polygon)
} else if (self.isEditMode) {
var styleOptions = {
strokeColor: '#FF33FF', // 边线颜色
fillColor: '#1791fc', // 填充颜色。当参数为空时,圆形没有填充颜色
strokeWeight: 6, // 边线宽度,以像素为单位
strokeOpacity: 0.2, // 边线透明度,取值范围0-1
fillOpacity: 0.4 // 填充透明度,取值范围0-1
};
var labelOptions = {
borderRadius: '2px',
background: '#FF33FF',
border: '1px solid #E1E1E1',
color: '#703A04',
fontSize: '12px',
letterSpacing: '0',
padding: '5px'
};
self.drawingManager = AMap.invoke('DrawingManager', mapService.mapInstance, {
isOpen: true, // 是否开启绘制模式
enableDrawingTool: true,
enableCalculate: false, // 绘制是否进行测距测面
enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式
polylineOptions: styleOptions, // 线的样式
polygonOptions: styleOptions, // 多边形的样式
rectangleOptions: styleOptions, // 矩形的样式
labelOptions: labelOptions, // label样式
})
AMap.invoke('drawingManagerAddEventListener','polygoncomplete',function(e){
let overlays=e
let pathArr = e.getPath()
console.log(pathArr)
// let resultArr = pathArr.map((item) => {
// return item.latLng
// })
self.emitPolyEvent(pathArr)
})
AMap.invoke('setDrawingMode', 'polygon')
}
......@@ -276,18 +281,11 @@ const fence = {
// event.target 即为编辑后的多边形对象
})
},
emitPolyEvent() {
let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat]
})
emitPolyEvent(resultArr) {
this.polygonPath = resultArr
EventBus.$emit('uiMap.fence.polygonChange', {
polygonPath: this.polygonPath
});
console.log(resultArr.join('|'))
},
clearTimeoutIds() {
this.timeoutIds && this.timeoutIds.forEach((item) => {
......@@ -299,32 +297,27 @@ const fence = {
// 地图增加右键功能
bindContextMenu() {
const self = this;
const MAP = mapService.map;
var contextMenu = new AMap.ContextMenu();
const mapInstance = mapService.mapInstance;
var contextMenu = AMap.invoke('ContextMenu');
contextMenu.addItem(
"设置围栏中心",
function () {
self.moveCenter();
},
0
AMap.invoke('MenuItem',"设置围栏中心", function () {
self.moveCenter();
})
);
//地图绑定鼠标右击事件——弹出右键菜单
MAP.on("rightclick", function (e) {
contextMenu.open(MAP, e.lnglat);
self.contextMenuPositon = e.lnglat;
});
AMap.invoke('mapAddEventListener','rightclick',function (e) {
AMap.invoke('addContextMenu',contextMenu)
self.contextMenuPositon = e.latlng
})
},
// 改变圆心
moveCenter() {
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.circle.setCenter(center);
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: this.lng,
lat: this.lat,
});
const MAP = mapService.map;
AMap.invoke('circleDisableEditing')
this.circle&& this.circle.setCenter(this.contextMenuPositon);
AMap.invoke('removeOverlay', this.circle)
AMap.invoke('addOverlay', this.circle)
AMap.invoke('circleEnableEditing')
},
// 更新围栏
......@@ -332,10 +325,10 @@ const fence = {
let _this = this;
const MAP = mapService.map;
let mapInterval = setInterval(function () {
if (MAP) {
if (AMap) {
clearInterval(mapInterval);
if (_this.fenceCircle) {
MAP.remove(_this.fenceCircle)
AMap.remove(_this.fenceCircle)
}
_this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close();
......@@ -354,11 +347,13 @@ const fence = {
_this.radius = Number(data.radius);
}
console.log(data)
_this.createFenceCircle(data);
// _this.createFenceCircle(data);
_this.updateFenceCircle(data)
return false;
}
mapService.setFitView()
// mapService.setFitView()
MAP.setZoom(14);
AMap.invoke('setZoom',14)
}
}, 100);
}
......
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).GlMap=r()}(this,(function(){"use strict";function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function r(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function e(t,r,e){return r&&function(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(){n=function(){return r};var t,r={},e=Object.prototype,o=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof g?r:g,a=Object.create(o.prototype),c=new P(n||[]);return i(a,"_invoke",{value:O(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=s;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",m={};function g(){}function w(){}function b(){}var L={};l(L,c,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(T([])));E&&E!==e&&o.call(E,c)&&(L=E);var j=b.prototype=g.prototype=Object.create(L);function G(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function S(t,r){function e(n,i,a,c){var u=h(t[n],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==typeof l&&o.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function O(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var f=h(r,e,n);if("normal"===f.type){if(o=n.done?d:y,f.arg===m)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(o=d,n.method="throw",n.arg=f.arg)}}}function _(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function A(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return w.prototype=b,i(j,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},r.awrap=function(t){return{__await:t}},G(S.prototype),l(S.prototype,u,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(s(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},G(j),l(j,f,"Generator"),l(j,c,(function(){return this})),l(j,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,P.prototype={constructor:P,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),f=o.call(a,"finallyLoc");if(u&&f){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!f)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),A(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;A(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function o(r){return function(r){if(Array.isArray(r))return t(r)}(r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(r,e){if(r){if("string"==typeof r)return t(r,e);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(r,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t){var r=function(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof r?r:r+""}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var c={1:"develop",2:"test",3:"production",4:"beta"},u=function(){return e((function t(){var e=this;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t);var o,i,u={env:3,version:3},f=arguments[0];if(arguments.length>1&&(u="object"==a(arguments[0])?arguments[0]:u,f=arguments[1],null!==(o=u)&&void 0!==o&&o.env||(u.env=3),null!==(i=u)&&void 0!==i&&i.version||(u.version=3)),"undefined"!=typeof window){var l=function(){var t,o=(t=n().mark((function t(){var r,o,i,a;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=map-api-js&env=".concat(c[u.env]));case 3:return r=t.sent,t.next=6,r.json();case 6:o=t.sent,i=Array.from(document.head.getElementsByTagName("script")).some((function(t){return t.src===o.apiUrl})),i?f&&"function"==typeof f&&(e.GLMap=new window.$GlMapApi(u,(function(){f&&"function"==typeof f&&f(e)}))):((a=document.createElement("script")).src=o.apiUrl,document.head.appendChild(a),a.onload=function(){e.GLMap=new window.$GlMapApi(u,(function(){f&&"function"==typeof f&&f(e)}))}),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),console.error("Failed to fetch configuration:",t.t0);case 14:case"end":return t.stop()}}),t,null,[[0,11]])})),function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))});return function(){return o.apply(this,arguments)}}();l()}}),[{key:"invoke",value:function(t){var r,e=Array.prototype.slice.call(arguments,1);return(r=this.GLMap)[t].apply(r,o(e))}},{key:"map",get:function(){return this.GLMap._BMAP}},{key:"mapGL",get:function(){return this.GLMap._BMapGL}}])}();return u}));
import EventBus from '../event-bus'
import mapService from './mapService.js'
import mapService from './mapBService.js'
import MAPGEO from './mapgeo'
//历史停留
const historyLocation = {
data: [],
points:[],
cluster:'',
markers: {},
infowins: {},
bindEvent(){
EventBus.$on('uiMap.historyLocation.draw', (data)=>{
console.log(data, '--------');
this.destroy();
const MAP = mapService.map;
this.data = data;
// MAPGEO.transferAddressByGroup(this, ()=>{
// EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
// this.data.forEach((item)=>{
// let marker = mapService.createHistoryLocationMarker([item.elng, item.elat], MAP);
// let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item);
// this.markers[item.idx] = marker;
// this.infowins[item.idx] = infoWindow;
// });
// console.log(this.markers)
// mapService.setFitView(MAP);
// this.createClusterer();
// });
let markers=[]
// v1.7.0历史停留为保证地址信息显示与导出一致 取后端返回的address 不需高德逆地址解析
EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
this.data.forEach((item)=>{
let marker = mapService.createHistoryLocationMarker([item.elng, item.elat], MAP);
let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item);
let lnglatXY=mapService.getLngLat(item.elng, item.elat);
markers.push(lnglatXY)
let marker = mapService.createHistoryLocationMarker(lnglatXY, AMap);
let infoWindow = mapService.bindLocationInfoWindow(marker, AMap, item);
this.markers[item.idx] = marker;
this.infowins[item.idx] = infoWindow;
// AMap.invoke('addOverlay',this.markers[item.idx])
});
console.log(this.markers)
mapService.setFitView(MAP);
AMap.invoke('setViewport',markers)
this.points=markers
this.createClusterer();
});
......@@ -47,105 +39,51 @@ const historyLocation = {
if(this.markers[idx]){
const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition();
this.infowins[idx].open(MAP, lnglat);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat);
// this.infowins[idx].open(MAP, lnglat);
MAP.invoke("mapOpenInfoWindow", this.infowins[idx],lnglat)
MAP.invoke('centerAndZoom',lnglat,10)
}
});
},
createClusterer(){
let map=mapService.mapInstance;
var cluster, markers = [];
for(let idx in this.markers){
markers.push(this.markers[idx]);
}
var self = this;
var map = mapService.map;
var count = markers.length;
var _renderClusterMarker = function (context) {
var factor = Math.pow(context.count / count, 1 / 18);
var div = document.createElement('div');
var Hue = 180 - factor * 180;
var bgColor = 'hsla(' + Hue + ',100%,50%,0.7)';
var fontColor = 'hsla(' + Hue + ',100%,20%,1)';
var borderColor = 'hsla(' + Hue + ',100%,40%,1)';
var shadowColor = 'hsla(' + Hue + ',100%,50%,1)';
div.style.backgroundColor = bgColor;
var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20);
div.style.width = div.style.height = size + 'px';
div.style.border = 'solid 1px ' + borderColor;
div.style.borderRadius = size / 2 + 'px';
div.style.boxShadow = '0 0 1px ' + shadowColor;
div.innerHTML = context.count;
div.style.lineHeight = size + 'px';
div.style.color = fontColor;
div.style.fontSize = '14px';
div.style.textAlign = 'center';
context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));
context.marker.setContent(div)
};
addCluster(2);
function addCluster(tag) {
if (self.cluster) {
self.cluster.setMap(null);
}
if (tag == 2) {//完全自定义
self.cluster = new AMap.MarkerClusterer(map, markers, {
gridSize: 80,
maxZoom: 16,
renderClusterMarker: _renderClusterMarker
});
} else if (tag == 1) {//自定义图标
var sts = [{
url: "https://a.amap.com/jsapi_demos/static/images/blue.png",
size: new AMap.Size(32, 32),
offset: new AMap.Pixel(-16, -16)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/green.png",
size: new AMap.Size(32, 32),
offset: new AMap.Pixel(-16, -16)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/orange.png",
size: new AMap.Size(36, 36),
offset: new AMap.Pixel(-18, -18)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/red.png",
size: new AMap.Size(48, 48),
offset: new AMap.Pixel(-24, -24)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/darkRed.png",
size: new AMap.Size(48, 48),
offset: new AMap.Pixel(-24, -24)
}];
self.cluster = new AMap.MarkerClusterer(map, markers, {
styles: sts,
gridSize: 80
});
} else {//默认样式
self.cluster = new AMap.MarkerClusterer(map, markers, {gridSize: 80});
this.cluster = AMap.invoke('Cluster', markers, data => {
return {
point: [data.latLng.lng, data.latLng.lat],
properties: {
marker: data
}
}
}
})
AMap.invoke('clusterSetData', this.cluster)
AMap.invoke('clusterAddEventListener', 'click', (e) => {
AMap.invoke('infoWindowDisableCloseOnClick', e.properties.marker.openInfoWindow)
AMap.invoke("mapOpenInfoWindow", e.properties.marker.openInfoWindow,e.properties.marker.getPosition() )
})
},
destroy: function(){
const MAP = mapService.map;
//MAP.clearMap();
this.data = [];
for(let idx in this.markers){
MAP.remove(this.markers[idx])
AMap.invoke('removeOverlay',this.markers[idx])
}
for(let idx in this.infowins){
MAP.remove(this.infowins[idx])
AMap.invoke('mapCloseInfoWindow')
}
this.markers = {};
this.infowins = {};
if (this.cluster) {
this.cluster.setMap(null);
self.cluster = null;
AMap.invoke('clusterDestroy')
this.cluster = null;
}
this.clearTimeoutIds();
},
......
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-12-06 14:10:32
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-20 11:23:44
* @FilePath: \oEshield\src\utils\mapBService.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import ClipboardJS from 'clipboard'
window.ClipboardJS = ClipboardJS
import EventBus from '../event-bus'
import { Message } from "element-ui";
import store from '../vuex/store.js'
import vue from 'vue'
import GLMapSdk from "@/utils/glsk-map-sdk";
EventBus.$on('uiMap.copySuccess', (data) => {
Message({
type: 'success',
message: '已复制内容至粘贴板'
});
});
var clipboard = null;
function MapService() {
this.map = null;
this.restainLayer = null;
this.mapInstance=null
}
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = {
init: function(id, options) {
var self = this;
let params = options || {}
if (self.map) {
self.map=null
}
return new Promise((resolve)=>{
new GLMapSdk({
env:3,
version:1
}, async (mapapi) => {
console.log('mapapi',mapapi)
self.map = mapapi;
this.mapInstance= await mapapi.invoke("Map", id);
this.mapInstance.enableScrollWheelZoom()//启用滚轮放大缩小
this.mapInstance.enableAutoResize()//启用自动适应容器尺寸变化
mapapi.invoke(
"centerAndZoom",
mapapi.invoke("Point", 116.404, 39.915),
params.zoom || 13
);
// 添加比例尺
mapapi.invoke("ScaleControl")
// 距离测量
// mapapi.invoke('DistanceTool',this.mapInstance)
resolve(mapapi)
// //距离测量
// map.plugin(["AMap.RangingTool"], function() {
// self.ruler = new AMap.RangingTool(map);
// });
// //定位
// map.plugin('AMap.Geolocation', function() {
// self.geolocation = new AMap.Geolocation();
// });
// mapapi.invoke("enableScrollWheelZoom");
});
})
// self.map = map;
// return self.map;
},
toggleMapType: function(type) {
var self = this;
console.log(type,888)
if (type) {
// 构造官方卫星、路网图层
self.mapInstance.setMapType(BMAP_NORMAL_MAP);
} else {
// 地图上设置图层
self.mapInstance.setMapType(BMAP_SATELLITE_MAP);
}
},
rulerTurnOn: function() {
// this.ruler.turnOn();
this.map.invoke('distanceToolOpen') // 开启测距
},
rulerTurnOff: function() {
// this.ruler.turnOff();
this.map.invoke('distanceToolclose') // 关闭测距
},
getCurrentLocation: function() {
var self = this;
self.map.invoke('Geolocation', res => {
console.log(res,999)
// self.currentMarker && self.map.remove(self.currentMarker);
// var lnglatXY = self.getLngLat(res.point.lng, res.point.lat);
var lnglatXY = self.getLngLat(116.404, 39.915);
console.log(lnglatXY,'lnglatXY')
self.currentMarker = self.createMarker(lnglatXY);
// self.setFitView()
})
},
createMarker: function(lnglatXY) {
let that=this,
url=require('images/mapLocation.gif'),
size=that.map.invoke('Size', 24, 24)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
return marker;
},
createPointMarker: function(lnglatXY) {
let that=this,
url=require('images/point.png'),
size=that.map.invoke('Size', 36, 22)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
return marker;
},
createConstantMarker: function(lnglatXY, map) {
let that=this,
url=require('images/icon_constant.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
return marker;
},
createCarMarker: function(lnglatXY, map) {
let that=this,
url=require('@/assets/images/icon_car.png'),
size=that.map.invoke('Size', 36, 22)
var marker=that.map.invoke('Marker',lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createPOIMarker(lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
content: `<span class="poi_marker"></span>`,
//icon: require('images/poi-marker-default.png'),
map: map,
autoRotation: true,
offset: new AMap.Pixel(-20, -50),
zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP'
});
return marker;
},
createPOIInfo(info) {
return `<div class="poi_infowin">
<h3 class="map-infowindow-title">POI信息</h3>
<div class="map-infowindow-ct">
<p class="poi_item"><label>经度:</label><span>${info.lng}</span></p>
<p class="poi_item"><label>纬度:</label><span>${info.lat}</span></p>
<p class="poi_item"><label>自定义名称:</label><span>${info.poiName}</span></p>
<p class="poi_item"><label>解析地址:</label><span>${info.address}</span>
</div></div>`
},
bindPOIInfoWindow(marker, map, info) {
var infoDiv = document.createElement('div'),
self=this;
infoDiv.innerHTML = this.createPOIInfo(info);
var infoWindow=self.map.invoke('InfoWindow',infoDiv,{
offset:self.map.invoke('Size',0, -48),
enableAutoPan:true
})
marker.infoWindow = infoWindow;
self.map.invoke('markerAddEventListener','click',markerClick)
function markerClick(e) {
self.map.invoke("mapOpenInfoWindow", infoWindow,e.target.getPosition())
// infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
setAlarmIcon(marker) {
let that=this,
url=require('@/assets/images/icon_car_alarm.png'),
size=that.map.invoke('Size', 36, 22)
marker.setIcon(that.map.invoke('Icon', url,size))
},
setDefaultIcon(marker) {
let that=this,
url=require('@/assets/images/icon_car.png'),
size=that.map.invoke('Size', 36, 22)
marker.setIcon(that.map.invoke('Icon', url,size))
},
createHistoryLocationMarker(lnglatXY, map) {
let that=this,
url=require('images/icon_location.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createStartMarker: function(lnglatXY, map) {
let that=this,
url=require('images/icon_start.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createEndMarker: function(lnglatXY, map) {
let that=this,
url=require('images/icon_end.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createPolyline: function(map) {
// return new AMap.Polyline({
// map: map,
// strokeWeight: 2,
// strokeColor: '#009944'
// });
let that=this,
polyline=that.map.invoke('Polyline','',{
strokeWeight: 2,
strokeColor: '#009944'
})
return polyline
},
createCircle: function(lnglatXY, map, radius) {
let that=this,
Circle= that.map.invoke('Circle', lnglatXY, radius, {
strokeColor: '#094',
fillColor: '#094',
strokeWeight: 1,
strokeOpacity: 0.8,
fillOpacity: 0.1
})
return Circle
},
createPoint: function(lnglatXY, map) {
let that=this,
Circle= that.map.invoke('Circle', lnglatXY, 3, {
strokeColor: '#094',
fillColor: '#094',
strokeWeight: 3,
strokeOpacity: 1,
fillOpacity: 1
})
return Circle
},
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var self = this;
var infoWindow=self.map.invoke('InfoWindow',div,{
enableAutoPan:!!isInfoAutoMove
})
marker.openInfoWindow = infoWindow;
if (clipboard) {
clipboard.destroy();
}
clipboard = new ClipboardJS('.copy-btn', {
text: function(trigger) {
return trigger.getAttribute('aria-label');
}
})
clipboard.on('success', function(e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
clipboard.on('error', function(e) {
});
if (isInfoOpen) {
infoWindow.redraw();
}
//给Marker绑定单击事件
// marker.addEventListener('click', markerClick);
self.map.invoke('markerAddEventListener','click',markerClick)
function markerClick(e) {
//infoWindow.setContent(e.target.content);
self.map.invoke("mapOpenInfoWindow", infoWindow,e.target.getPosition())
// infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
// 初始化复制事件
initCopyEvent() {
var clipboard = new ClipboardJS('.copy-btn', {
text: function(trigger) {
return trigger.getAttribute('aria-label');
}
})
},
// 车辆监控-查看位置点
bindMonitorInfoWindow: function(marker, map, info, isInfoOpen, isInfoAutoMove) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createMonitorInfo(info);
let eLocation = info[info.eLocateType];
var statusArr = ['行驶中', '静止', '离线', '在线']
if (info.status === 2) {
let _msg = `${statusArr[info.status]} | 已离线${info.statusTime && info.statusTime != null ? info.statusTime : ''}`;
infoDiv.querySelector('[data-status]').textContent = _msg;
infoDiv.querySelector('[data-status]').setAttribute('aria-label', _msg)
} else {
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
infoDiv.querySelector('[data-status]').setAttribute('aria-label', statusArr[info.status]);
}
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', eLocation.dateTime);
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', eLocation.transferAddress);
//infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', eLocation.transferAddress);
infoDiv.querySelector('[data-address-icon').setAttribute('aria-label', eLocation.transferAddress);
if (info.battery) {
infoDiv.querySelector('[data-battery]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
let gpsBtn = infoDiv.querySelector('[data-gps]')
let baseBtn = infoDiv.querySelector('[data-base]')
let wifiBtn = infoDiv.querySelector('[data-wifi]')
//console.log(info.eLocateType)
if (info.eLocateType === 'bsLocation') {
gpsBtn && gpsBtn.classList.remove('el-button--primary');
baseBtn.classList.add('el-button--primary');
} else {
gpsBtn && gpsBtn.classList.add('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
}
// 基站
baseBtn && (baseBtn.onclick = function(e) {
console.log('基站')
if (info.eLocateType === 'bsLocation') return;
info.eLocateType = 'bsLocation'
eLocation = info[info.eLocateType];
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无基站数据'
});
return;
}
gpsBtn && gpsBtn.classList.remove('el-button--primary');
wifiBtn && wifiBtn.classList.remove('el-button--primary');
baseBtn && baseBtn.classList.add('el-button--primary');
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-address-icon').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', eLocation.dateTime);
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
})
// gps
gpsBtn && (gpsBtn.onclick = function(e) {
if (info.eLocateType === 'gpsLocation') return;
info.eLocateType = 'gpsLocation'
eLocation = info[info.eLocateType];
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无GPS数据'
});
return;
}
gpsBtn && gpsBtn.classList.add('el-button--primary');
wifiBtn && wifiBtn.classList.remove('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-address-icon').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', eLocation.dateTime);
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
//self.setFitView()
})
// wifi数据
wifiBtn && (wifiBtn.onclick = function(e) {
if (info.wifiLocation && info.wifiLocation.elng) {
console.log(info)
if (info.eLocateType === 'wifiLocation') return;
info.eLocateType = 'wifiLocation'
gpsBtn && gpsBtn.classList.remove('el-button--primary');
wifiBtn && wifiBtn.classList.add('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
infoDiv.querySelector('[data-transferAddress]').textContent = info.wifiLocation.address;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', info.wifiLocation.address);
infoDiv.querySelector('[data-time]').textContent = info.wifiLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', info.wifiLocation.dateTime);
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
}
//EventBus.$emit('uiMap.monitor.wifiLocate', { info, infoDiv, gpsBtn, baseBtn, wifiBtn })
})
if (info.alarmTypeSet && info.alarmTypeSet.length) {
let _html = '<i class="icon icon-info_device_alarm"></i>报警状态:'
info.alarmTypeSet.forEach((alarmType) => {
if (alarmType === 1) {
_html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmoff >断电</button>`
} else if (alarmType === 99) {
_html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmlight >光感</button>`
}
});
infoDiv.querySelector('[data-alarm]').innerHTML = _html;
/* if(infoDiv.querySelector('[data-alarmoff]')){
infoDiv.querySelector('[data-alarmoff]').onclick = function(e){
console.log(e.target.dataset)
window.open(`#/report/antiOffAlarm?type=1&time=${e.target.dataset.alarmtime}&sn=${info.sn}`)
}
}
if(infoDiv.querySelector('[data-alarmlight]')){
infoDiv.querySelector('[data-alarmlight]').onclick = function(e){
console.log(e.target.dataset)
window.open(`#/report/antiOffAlarm?type=99&time=${e.target.dataset.alarmtime}&sn=${info.sn}`)
}
} */
infoDiv.querySelector('[data-alarm]').style.display = 'block';
} else {
infoDiv.querySelector('[data-alarm]').style.display = 'none';
}
// 通用参数
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
// 跳转到历史停留页面 无线设备不能跳转历史停留 isSource:1有线,其他无线
let historyBtn = infoDiv.querySelector('[data-history]');
if (historyBtn) {
if (info.isSource != 1) {
historyBtn.classList.add('history_btn_grey');
}
historyBtn.onclick = function() {
if (info.isSource == 1) {
mapService.openPage(`#/monitor/historyLocation?${queryCode}`)
}
}
}
// 跳转到常住地 无线设备不能跳转常住地 isSource:1有线,其他无线
let residentBtn = infoDiv.querySelector('[data-resident]');
if (residentBtn) {
//注意去掉!
if (info.isSource != 1) {
residentBtn.classList.add('resident_btn_grey');
}
residentBtn.onclick = function() {
if (info.isSource == 1) {
queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}&locationType=${info.eLocateType}`
mapService.openPage(`#/monitor/resident?${queryCode}`)
}
}
}
// 跳转到轨迹回放页面
let replayBtn = infoDiv.querySelector('[data-replay]');
if (replayBtn) {
replayBtn.onclick = function() {
mapService.openPage(`#/monitor/replay?${queryCode}`)
}
}
// 跳转到风险评估页面 无线设备不显示按钮 info.deviceCompose=010/020/011/012/013/022,需要有风险评估按钮出现
let riskBtn = infoDiv.querySelector('[data-risk]');
if (riskBtn) {
if (info.deviceCompose != '010' && info.deviceCompose != '020' && info.deviceCompose != '011' && info.deviceCompose != '012' && info.deviceCompose != '013' && info.deviceCompose != '022') {
riskBtn.classList.add('resident_btn_hidden');
}
riskBtn.onclick = function() {
let id = localStorage.getItem('vehicleId');
queryCode = `vehicleId=${id}`
mapService.openPage(`#/monitor/alarmAnalysis?${queryCode}`)
}
}
// 跳转到电子围栏页面 无线设备不能跳转电子围栏 isSource:1有线,其他无线
let fenceBtn = infoDiv.querySelector('[data-fence]');
// 判断是否分配了电子围栏按钮权限
//let fencePermission = vue.prototype.$parentCommon.isPermission('ADD_WIRELESS_DEVICE_FENCE');
//console.log(vue.$parentCommon.hasPermission);
//console.log(fencePermission);
if (fenceBtn) {
// 判断是否分配了电子围栏按钮权限
vue.prototype.$parentCommon.isPermission('ADD_WIRELESS_DEVICE_FENCE').then(fencePermission => {
if (!fencePermission) {
fenceBtn.classList.add('fence_btn_grey');
}
// v1.25.0版本需求,无线设备和有线设备都支持围栏
queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}&source=${info.isSource}`;
fenceBtn.onclick = function() {
if (fencePermission) {
mapService.openPage(`#/monitor/fence?${queryCode}`)
}
}
})
}
const snSourceType = `${info.sn}:${info.isSource}`
/* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{
if(status === 2){
infoDiv.querySelector('[data-status]').textContent = `${statusArr[info.status]} | 已离线${info.deadline}`;
}else{
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
}
}) */
// 浮窗点击事件
let questionIcon = infoDiv.querySelector('.question_icon');
if (questionIcon) {
let _obj = infoDiv.querySelector('.popover_box');
questionIcon.addEventListener('mouseenter', function(e) {
console.log(e.stopPropagation)
_obj.style.display = 'block';
e.stopPropagation()
})
questionIcon.addEventListener('mouseleave', function(e) {
_obj.style.display = 'none';
e.stopPropagation()
})
}
return this.createInfoWindow(marker, map, infoDiv, isInfoOpen, isInfoAutoMove);
},
bindLocationInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createLocationInfo(info);
// let addressCopyBtn = infoDiv.querySelector('[address-copy]');
let addressCopyBtn = new ClipboardJS(infoDiv.querySelector('.address-copy'));
console.log(addressCopyBtn, 'addressCopyBtn');
addressCopyBtn.on('success', function(e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
addressCopyBtn.on('error', function(e) {
});
return this.createInfoWindow(marker, map, infoDiv);
},
bindResidentInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createResidentInfo(info);
return this.createInfoWindow(marker, map, infoDiv);
},
bindFenceInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createFenceInfo(info);
var statusArr = ['行驶中', '静止', '离线', '在线'];
function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.timeGPS;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressGPS;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressGPS);
infoDiv.querySelector('#locateTypeGps').classList.add('active');
infoDiv.querySelector('#locateTypeBase').classList.remove('active');
marker.setPosition(self.getLngLat(info.lngGPS, info.latGPS));
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
// marker.openInfoWindow()
}
function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.timeBase;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressBase;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressBase);
infoDiv.querySelector('#locateTypeGps').classList.remove('active');
infoDiv.querySelector('#locateTypeBase').classList.add('active');
marker.setPosition(self.getLngLat(info.lngBase, info.latBase));
// marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
}
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
if (info.battery) {
infoDiv.querySelector('[data-battery]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e) {
fillBase()
}
fillGPS();
return this.createInfoWindow(marker, map, infoDiv);
},
//经纬度坐标
getLngLat: function(lng, lat) {
return this.map.invoke('Point',lng, lat)
// return new AMap.LngLat(lng, lat);
},
getGeocoder: function() {
return new Promise((resolve) => {
var geocoder= AMap.invoke('Geocoder');
resolve(geocoder);
})
},
getAddress: function(geocoder, lnglatXY) {
geocoder.getAddress(lnglatXY, function(status, result) {
if (status === 'complete' && result.info === 'OK') {
//获得了有效的地址信息:
//即,result.regeocode.formattedAddress
} else {
//获取地址失败
}
});
},
zoomIn: function() {
this.mapInstance.zoomIn();
},
zoomOut: function() {
this.mapInstance.zoomOut();
},
// 监控弹框
createMonitorInfo: function(info) {
/*var _html = '<h3 class="uimap-info-title">'+ info.name+'/'+ info.standNo +'</h3><div class="uimap-info-ct"><p><span><i class="fa fa-inbox"></i></span>'+ info.sn +'</p>';
if(info.time){
_html += '<p><span><i class="fa fa-clock-o"></i></span>'+ info.time +'</p>';
}
_html += '<p><span><i class="fa fa-map-marker"></i></span>'+ info.transferAddress +'</p>';
_html += '<p><span><i class="fa fa-car"></i></span>'+ '驻留次数:' +(info.totalTimes?info.totalTimes:'1')+'</p>';
return _html;*/
let _this = this;
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
var _html = `<div class="map-infowindow-title"><span class="copy-btn" aria-label="${info.name}">${info.name}</span><span>/</span><span class="copy-btn" aria-label="${info.standNo}">${info.standNo}</span><span class="question_icon"></span>`;
_html += '<div class="popover_box" style="display:none;"><div class="title">信息复制说明:</div><p>非标题类文字,支持“单击”复制,已复制信息可用快捷键或者鼠标有键“粘贴”功能进行使用。</p></div>'
_html += '</div>'
_html += `<div class="map-infowindow-ct map_info_window">`;
if (zhongliType == 'yes') {
_html += `<div>`;
if (info.shopName) {
_html += `<p><i class="icon icon-icon_store"></i> 店面名称: <span class="des copy-btn" aria-label="${info.shopName}">${info.shopName}</span></p>`;
}
if (info.shopContacts) {
_html += `<p style="margin-left:29px;"> 店面联系人: <span class="des copy-btn" aria-label="${info.shopContacts}">${info.shopContacts}</span></p>`;
}
if (info.contactsPhone) {
_html += `<p style="margin-left:29px;"> 联系方式: <span class="des copy-btn" aria-label="${info.contactsPhone}">${info.contactsPhone}</span></p>`;
}
if (info.idnum) {
_html += `<p style="margin-left:29px;"> 车牌号: <span class="des copy-btn" aria-label="${info.idnum}">${info.idnum}</span></p>`;
}
_html += `</div>`;
}
// 根据权限-显示店面名称、车牌号
let list = vue.prototype.$parentCommon.getAuthData();
let o = list.find(k => k.origin.permissionTag == 'oEshield_monitor_store_name');
let n = list.find(k => k.origin.permissionTag == 'oEshield_monitor_plate_number');
if (o && info.shopName) {
_html += `<p><i class="icon_info_shop"></i> 店面名称: <span class="des copy-btn" aria-label="${info.shopName}">${info.shopName || '--'}</span></p>`;
}
if (n && info.licensePlate) {
_html += `<p><i class="icon_info_plate"></i>车牌号: <span class="des copy-btn" aria-label="${info.licensePlate}">${info.licensePlate || '--'}</span></p>`;
}
_html += `<p class="" aria-label="${info.sn}"><i class="icon icon-info_device"></i> 设备号:<span class="des copy-btn" aria-label="${info.sn}(${info.isSource === '1' ? '有线' : '无线'})"> ${info.sn} (${info.isSource === '1' ? '有线' : '无线'})</span>
<span class="battery" data-battery>
<i class="fill"><i class="fill-percentage" data-battery-percentage></i></i>
<i class="icon icon-battery_enough"></i>
<i class="text" data-battery-text></i>
</span></p>
<p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des copy-btn" data-status aria-label=""></span></p>
<p data-alarm>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmoff>断电</button>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmlight>光感</button>
</p>
<p><i class="icon icon-info_time"></i> 最后上点时间: <span class="des copy-btn" data-time aria-label=""></span></p>
<p><i class="icon icon-info_location"></i> 最后上点地址: <span class="des adr copy-btn" data-transferAddress aria-label="${info.transferAddress}">${info.transferAddress}</span>
<a class="" data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy copy-btn" data-address-icon aria-label="${info.transferAddress}"></i></a>
</p>
<p><i class="icon icon-info_type"></i> 定位类型:<span class="el-button-group">`
// 是否有gps按钮
if (info.gpsLocation && info.gpsLocation.elng) {
_html += `<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> `
}
// 是否有基站按钮
if (info.bsLocation && info.bsLocation.elng) {
_html += `<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`
}
// 是否有wifi按钮
if (info.hasWifi) {
if (info.wifiLocation && info.wifiLocation.elng) {
_html += `<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>`
} else {
_html += `<button type="button" class="el-button el-button--mini history_btn_grey" data-wifi>wifi</button>`
}
}
_html += ` </p>
<p class="redirect-row">
<a class="redirect-btn" id="btn_replay" data-replay>轨迹回放</a>
<a class="redirect-btn" id="btn_fence" data-fence>电子围栏</a>
<a class="redirect-btn" id="btn_resident" data-resident>常驻地</a>
<a class="redirect-btn" id="btn_history" data-history>历史停留</a>
<a class="redirect-btn" id="btn_risk" data-risk>风险评估</a>
</p>
</div>`;
return _html;
},
createFenceInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.standno}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.sourceString})</span>
<span class="battery hide" data-battery>
<i class="fill"><i class="fill-percentage" data-battery-percentage></i></i>
<i class="icon icon-battery_enough"></i>
<i class="text" data-battery-text></i>
</span></p>
<p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></span></p>
<p><i class="icon icon-info_time"></i> 最后上点时间: <span class="des" data-time></span></p>
<p><i class="icon icon-info_location"></i> 最后上点地址: <span class="des adr" data-transferAddress>${info.transferAddress}</span>
<a class="copy-btn" data-clipboard-text=""><i class="icon icon-info_copy"></i></a>
</p>
<p>
<i class="icon icon-info_type"></i>
定位类型:
<a class="locate-btn active" id="locateTypeGps">GPS</a>
<a class="locate-btn" id="locateTypeBase">基站</a>
</p>
</div>`;
},
createLocationInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.vin}/${info.sn}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p>
<p><i class="icon icon-info_location"></i> 停留地址: <span class="des adr" >${info.transferAddress}</span>
<a class="copy-btn address-copy" id="address-copy" address-copy data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy"></i></a>
</p>
<p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p>
</div>`;
},
createResidentInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.vin}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn}</span></p>
<p><i class="icon icon-info_location"></i> 常驻地址: <span class="des adr" >${info.transferAddress}</span>
<a class="copy-btn" data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy"></i></a>
</p>
<p><i class="icon icon-info_device"></i> 驻留次数: <span class="des">${info.totalTimes}次</span></p>
<p><i class="icon icon-info_stop"></i> 驻留时长: <span class="des">${info.totalDurationString}</span></p>
</div>`;
},
clearMap: function(map) {
this.map.clearMap();
},
setFitView: function(map) {
this.mapInstance.setZoom();
},
bindClickEvent() {
},
// 创建位置点弹框
createActiveInfo(info) {
let msg = '报警'
// 激活
if (info.type == 1) {
msg = '激活'
}
// 定位
if (info.type == 2) {
msg = '定位'
}
return `<h3 class="map-infowindow-title">${info.name || '--'}/${info.standNo || '--'}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn} (${info.source == 1 ? '有线' : '无线'})</span></p>
<p><i class="icon icon-info_time"></i>${msg}时间: <span class="des"data-time>${info.time}</span></p>
<div style="display:${info.bsLng ? 'block' : 'none'}"><i class="icon icon-info_type"></i>定位类型: <a class="locate-btn active" id="locateTypeGps">GPS</a><a class="locate-btn" id="locateTypeBase">基站</a></div>
<p><i class="icon icon-info_location"></i> ${msg}地址: <span class="des" data-transferAddress>${info.address}</span></p>
</div>`
},
// 位置点弹框
bindActiveLocationInfoWindow(marker, map, info) {
var self = this
var infoDiv = document.createElement('div')
infoDiv.innerHTML = self.createActiveInfo(info)
// gps位置信息
function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.time;
infoDiv.querySelector('[data-transferAddress]').textContent = info.address;
infoDiv.querySelector('#locateTypeGps').classList.add('active');
infoDiv.querySelector('#locateTypeBase').classList.remove('active');
marker.setPosition(self.getLngLat(info.lng, info.lat));
self.setFitView()
// marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
}
// 基站位置信息
function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.bsTime;
infoDiv.querySelector('[data-transferAddress]').textContent = info.bsAddress;
infoDiv.querySelector('#locateTypeGps').classList.remove('active');
infoDiv.querySelector('#locateTypeBase').classList.add('active');
marker.setPosition(self.getLngLat(info.bsLng, info.bsLat));
console.log(marker,self.getLngLat(info.bsLng, info.bsLat))
self.setFitView()
// marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e) {
console.log('-----------------------------------基站')
fillBase()
}
if (info.lng) {
fillGPS()
}
if (!info.lng && info.bsLng) {
fillBase()
}
return this.createActiveInfoWindow(marker, map, infoDiv)
},
// 创建位置点弹框
createActiveInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var self = this;
var infoWindow=self.map.invoke('InfoWindow',div,{
offset:self.map.invoke('Size',0,0),
enableAutoPan:!!isInfoAutoMove
})
marker.infoWindow = infoWindow
console.log(isInfoOpen,'-----------------------------------isInfoOpen')
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
}
//给Marker绑定单击事件
self.map.invoke('markerAddEventListener','click',markerClick)
function markerClick(e) {
self.map.invoke("mapOpenInfoWindow", infoWindow,e.target.getPosition())
//infoWindow.setContent(e.target.content);
// infoWindow.open(map, e.target.getPosition())
}
return infoWindow
},
// 页面跳转,打开新窗口
openPage(path) {
vue.prototype.$parentCommon.setBreadCrumbs(path);
window.open(path)
},
// 区域查车弹框
createAraeInfowindow(info) {
console.log(info,'info')
let self=this;
let _types = {
1: '有线设备',
0: '无线设备'
}
let _div = `<h3 class="map-infowindow-title">${info.ownerName || '--'}/${info.vin || '--'}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn || '--'} (${_types[info.source] || '--'})</span>
<span class="battery" data-battery style="display:${info.battery ? 'block' : 'none'}">
<i class="fill"><i class="fill-percentage" data-battery-percentage style="width:${info.battery}%;"></i></i>
<i class="icon icon-battery_enough"></i>
<i class="text" data-battery-text>${info.battery}</i>
</span></p>
</div>`;
// var infoWindow = new AMap.InfoWindow({
// offset: new AMap.Pixel(0, -20),
// content: _div,
// autoMove: true,
// position: [info.lng, info.lat]
// })
var infoWindow=self.map.invoke('InfoWindow',_div,{
offset:self.map.invoke('Size',0,-20),
enableAutoPan:true
})
return infoWindow
},
// 创建poi信息弹框
createPoiMarkerInfowindow(info) {
let infoDiv = document.createElement('div');
let _div = `<div class="map_poi_infowindow_popup"><h3 class="map_poi_infowindow_title">${info.address || '暂无地址'}</h3>
<div class="map_poi_infowindow_content">
<span class="near_address">${info.near || '无'}${info.near ? '附近' : ''}</span>
<button href="javascript:void(0)" class="clear_link" data-poi-delete>删除</button>
</div></div>`;
infoDiv.innerHTML = _div;
infoDiv.querySelector('[data-poi-delete]').onclick = function(e) {
// console.log(e);
EventBus.$emit('uiMap.poi.marker.delete', info);
}
// var infoWindow = new AMap.InfoWindow({
// offset: new AMap.Pixel(12, -5),
// content: infoDiv,
// autoMove: true,
// position: [info.lng, info.lat],
// })
var infoWindow=self.map.invoke('InfoWindow',infoDiv,{
offset:self.map.invoke('Size',12, -5),
enableAutoPan:true
})
return infoWindow
},
}
const mapService = new MapService();
export default mapService
\ No newline at end of file
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-12 14:23:37
* @FilePath: \oEshield\src\utils\mapgeo.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const MAPGEO = {
geocoder: null,
getGeocoder: function () {
return new Promise((resolve) => {
console.log(window)
var geocoder= AMap.invoke('Geocoder');
// AMap.plugin('AMap.Geocoder', function () {//回调函数
// var geocoder = new AMap.Geocoder({
// batch: true
// });
MAPGEO.geocoder = geocoder;
resolve(geocoder);
});
// })
},
transferAddressByGroup(obj, cb) {
if (!this.geocoder) {
this.getGeocoder().then(() => {
this.transfer(obj, cb)
})
} else {
this.transfer(obj, cb)
}
},
transfer(obj, cb) {
const data = obj.data;
obj.len = data.length;
obj.times = obj.len > 20 ? Math.ceil(obj.len / 20) : 1;
obj.totalNum = 0;
obj.realNum = 0; //为了剔除脏数据,脏数据导致解析不回调
for (let i = 0; i < obj.times; i++) {
let lnglatArr = [];
let initIdx = i * 20;
let maxIdx = i === obj.times - 1 ? obj.len : (i + 1) * 20;
for (let idx = initIdx; idx < maxIdx; idx++) {
// 防止出现gps点:.00000的错误
if (Number(data[idx].elng) > 0 && Number(data[idx].elat) > 0) {
lnglatArr.push([data[idx].elng, data[idx].elat])
obj.realNum++;
}
}
(function (initIdx) {
geocoderGetAdr(lnglatArr, initIdx)
})(initIdx)
}
function fixed6(num) {
return Number(num).toFixed(6);
}
// 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720
function setAddress(row, item) {
let _list = data.filter(
(k) =>
fixed6(k.elng) == fixed6(row.lng) && fixed6(k.elat) == fixed6(row.lat)
);
_list.map((k) => {
k.transferAddress = item.address;
});
}
function geocoderGetAdr(arr, initIdx) {
if (!arr || arr.length <= 0) {
return false;
}
const timeoutId = window.setTimeout(() => {
arr.forEach(item=>{
let o=AMap.invoke('Point',...item)
MAPGEO.geocoder.getLocation( o,function(res){
console.log(res,'res')
setAddress(o, res);
obj.totalNum++;
if (obj.totalNum === obj.realNum) {
console.log('geocoderGetAdr', data)
cb && cb(data)
}
})
})
// MAPGEO.geocoder.getAddress(arr, function (status, result) {
// if (status === 'complete' && result.info === 'OK') {//获取地址成功
// result.regeocodes.forEach((item, idx) => {
// let o = arr[idx]
// setAddress(o, item);
// obj.totalNum++;
// });
// if (obj.totalNum === obj.realNum) {
// cb && cb(data)
// }
// } else {
// // geocoderGetAdr(arr, initIdx)
// }
// });
});
if (!obj.timeoutIds) {
obj.timeoutIds = []
}
obj.timeoutIds.push(timeoutId)
}
}
}
export default MAPGEO
\ No newline at end of file
......@@ -22,6 +22,7 @@ function MapService() {
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = {
init: function(id, options) {
console.log('init map',id, options)
var self = this;
let params = options || {}
if (self.map) {
......
......@@ -68,6 +68,7 @@ const MAPGEO = {
// 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720
function setAddress(row, item) {
console.log('setAddress', row, item)
let _list = data.filter(
(k) =>
fixed6(k.elng) == fixed6(row.lng) && fixed6(k.elat) == fixed6(row.lat)
......@@ -85,6 +86,7 @@ const MAPGEO = {
MAPGEO.geocoder.getAddress(arr, function (status, result) {
if (status === 'complete' && result.info === 'OK') {//获取地址成功
console.log('geocoderGetAdr', result)
result.regeocodes.forEach((item, idx) => {
let o = arr[idx]
// let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat);
......
import EventBus from '../event-bus'
import mapService from './mapService.js'
import MAPGEO from './mapgeo'
// import mapService from './mapService.js'
import mapService from './mapBService.js'
// import MAPGEO from './mapgeo'
import MAPGEO from './mapBgeo'
import { Message } from "element-ui";
import { services } from '../api'
const MONITOR_SERVICE = services.monitor;
......@@ -17,6 +20,7 @@ const monitor = {
compareText: null,
bindEvent() {
EventBus.$on('uiMap.monitor.draw', (data, autoOpenLastInfoWindow) => {
console.log('监听围栏更新', data)
this.draw(data, autoOpenLastInfoWindow);
});
......@@ -24,11 +28,11 @@ const monitor = {
const MAP = mapService.map;
if (snSourceType) {
if (this.markers[snSourceType]) {
MAP.remove(this.markers[snSourceType])
AMap.invoke('removeOverlay',this.markers[snSourceType])
}
if (this.infowins[snSourceType]) {
MAP.remove(this.infowins[snSourceType])
AMap.invoke('mapCloseInfoWindow',this.infowins[snSourceType])
}
delete this.markers[snSourceType];
delete this.infowins[snSourceType];
......@@ -36,12 +40,12 @@ const monitor = {
} else {
for (let snSourceType in this.markers) {
if (this.markers[snSourceType]) {
MAP.remove(this.markers[snSourceType])
AMap.invoke('removeOverlay',this.markers[snSourceType])
}
}
for (let snSourceType in this.infowins) {
if (this.markers[snSourceType]) {
MAP.remove(this.infowins[snSourceType])
AMap.invoke('mapCloseInfoWindow',this.infowins[snSourceType])
EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`)
}
}
......@@ -58,11 +62,13 @@ const monitor = {
})
EventBus.$on('uiMap.monitor.changeSourceType', (sourceType) => {
const MAP = mapService.map;
console.log('标记显示')
console.log(AMap)
let rourceReg = /^\d+\:(\d)$/;
if (sourceType === '') {
for (let snSourceType in this.markers) {
this.markers[snSourceType].show();
AMap.invoke('addOverlay',this.markers[snSourceType])
// this.markers[snSourceType].show();
}
} else {
......@@ -70,9 +76,12 @@ const monitor = {
let execResult = rourceReg.exec(snSourceType);
if (execResult) {
if (execResult[1] === sourceType) {
this.markers[snSourceType].show();
AMap.invoke('addOverlay',this.markers[snSourceType])
// this.markers[snSourceType].show();
} else {
this.markers[snSourceType].hide();
AMap.invoke('removeOverlay',this.markers[snSourceType])
}
}
}
......@@ -84,21 +93,24 @@ const monitor = {
EventBus.$on('uiMap.monitor.openInfoWindow', (snSourceType) => {
if (this.markers[snSourceType]) {
const MAP = mapService.map;
const lnglat = this.markers[snSourceType].getPosition();
this.infowins[snSourceType].open(MAP, lnglat);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat,true);
AMap.invoke("mapOpenInfoWindow", this.infowins[snSourceType],lnglat)
AMap.invoke('addOverlay',this.markers[snSourceType])
mapService.mapInstance.panTo(lnglat,true)
}
});
EventBus.$on('uiMap.monitor.changeELocate', (item) => {
const snSourceType = `${item.sn}:${item.isSource}`
const snSourceType = `${item.sn}:${item.isSource}`;
let eLocation = item[item.eLocateType];
console.log(eLocation)
if (this.markers[snSourceType]) {
this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
AMap.invoke("mapOpenInfoWindow", this.infowins[snSourceType],mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)))
AMap.invoke('addOverlay',this.markers[snSourceType])
// this.infowins[snSourceType].setPosition();
}
this.isCompare && this.compareLocation()
......@@ -128,7 +140,8 @@ const monitor = {
const snSourceType = `${info.sn}:${info.isSource}`
if (this.markers[snSourceType]) {
this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat)));
this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat)));
AMap.invoke("mapOpenInfoWindow", this.infowins[snSourceType],mapService.getLngLat(parseFloat(transferObj.elng)))
AMap.invoke('addOverlay',this.markers[snSourceType])
}
gpsBtn && gpsBtn.classList.remove('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
......@@ -150,8 +163,7 @@ const monitor = {
EventBus.$on("uiMap.monitor.drawMaker", this.drawMaker);
},
draw(data, autoOpenLastInfoWindow) {
const MAP = mapService.map;
this.data = data;
this.data = data;
const transferObj = []
data.forEach((item) => {
if (item.gpsLocation && item.gpsLocation.elat && item.gpsLocation.elng) {
......@@ -163,13 +175,12 @@ const monitor = {
})
MAPGEO.transferAddressByGroup({ data: transferObj }, () => {
this.data.forEach((item, idx) => {
let eLocation = item[item.eLocateType];
if (!eLocation.elng && !eLocation.elat) return;
let isInfoOpen = false;
let tag = `${item.sn}:${item.isSource}`;
if (this.infowins[tag] && this.infowins[tag].getIsOpen()) {
if (this.infowins[tag] && this.infowins[tag].isOpen()) {
isInfoOpen = true;
}
......@@ -179,14 +190,18 @@ const monitor = {
this.markers[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
//this.infowins[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
//infoWindow = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen);
this.infowins[tag] = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen, this.isCompare ? true : false);
console.log(this.markers,'markers')
this.infowins[tag] = mapService.bindMonitorInfoWindow(this.markers[tag], AMap, item, isInfoOpen, this.isCompare ? true : false);
AMap.invoke('addOverlay', this.markers[tag])
EventBus.$emit(`uiMap.monitor.changeStatus.${snSourceType}`)
} else {
this.infowins[tag] && MAP.remove(this.infowins[tag]);
let marker = mapService.createCarMarker([parseFloat(eLocation.elng), parseFloat(eLocation.elat)], MAP);
infoWindow = mapService.bindMonitorInfoWindow(marker, MAP, item, isInfoOpen, this.isCompare ? true : false);
const getLngLat=mapService.getLngLat(parseFloat(eLocation.elng),parseFloat(eLocation.elat))
let marker = mapService.createCarMarker(getLngLat, AMap);
infoWindow = mapService.bindMonitorInfoWindow(marker, AMap, item, isInfoOpen, this.isCompare ? true : false);
this.markers[tag] = marker;
this.infowins[tag] = infoWindow;
AMap.invoke('addOverlay', this.markers[tag])
}
if (item.alarmModelList && item.alarmModelList.length) {
......@@ -194,7 +209,6 @@ const monitor = {
} else {
mapService.setDefaultIcon(this.markers[tag])
}
if (autoOpenLastInfoWindow && idx === 0) {
EventBus.$emit('uiMap.monitor.openInfoWindow', snSourceType)
}
......@@ -223,7 +237,7 @@ const monitor = {
const MAP = mapService.map;
if (!this.compareLine) {
this.compareLine = new AMap.Polyline({
map: MAP,
map: AMap,
strokeColor: '#80d8ff',
isOutline: true,
outlineColor: 'white'
......@@ -231,7 +245,7 @@ const monitor = {
}
if (!this.compareText) {
this.compareText = new AMap.Text({
map: MAP,
map: AMap,
text: '',
style: {
'background-color': '#29b6f6',
......@@ -272,13 +286,12 @@ const monitor = {
},
compareDestroy: function () {
const MAP = mapService.map;
for (let snSourceType in this.markers) {
MAP.remove(this.markers[snSourceType])
AMap.remove(this.markers[snSourceType])
}
for (let snSourceType in this.infowins) {
MAP.remove(this.infowins[snSourceType])
AMap.remove(this.infowins[snSourceType])
}
this.markers = {};
this.infowins = {};
......@@ -302,15 +315,16 @@ const monitor = {
// 激活位置
drawMaker(data, autoOpenLastInfoWindow) {
console.log('drawMaker', data)
let tag = `${data.sn}-${data.standNo}`;
const MAP = mapService.map
const getLngLat=mapService.getLngLat(parseFloat(data.lng || data.bsLng),parseFloat(data.lat || data.bsLat))
const marker = mapService.createCarMarker(
[parseFloat(data.lng || data.bsLng), parseFloat(data.lat || data.bsLat)],
MAP
getLngLat,
AMap
)
const infoWindow = mapService.bindActiveLocationInfoWindow(
marker,
MAP,
AMap,
data,
true
)
......@@ -324,17 +338,16 @@ const monitor = {
// /EventBus.$emit("uiMap.monitor.openInfoWindow");
monitor.openActiveInfoWindow(marker, infoWindow)
}
AMap.invoke('addOverlay',marker)
// mapService.setFitView(MAP);
EventBus.$emit('uiMap.monitor.drawDone')
},
// 打开激活位置点弹框
openActiveInfoWindow(makers, infoWindow) {
const MAP = mapService.map
const lnglat = makers.getPosition()
infoWindow.open(MAP, lnglat)
MAP.setZoomAndCenter(MAP.getZoom(), lnglat,true)
AMap.invoke("mapOpenInfoWindow", infoWindow,lnglat)
// infoWindow.open(MAP, lnglat)
AMap.invoke("centerAndZoom",lnglat,14)
}
}
......
import EventBus from '../event-bus'
import mapService from './mapService.js'
import MAPGEO from './mapgeo'
import mapService from './mapBService.js'
import MAPGEO from './mapBgeo'
//单个地址解析容器
const transferObj = {
data: [],
......@@ -24,6 +24,7 @@ const replay = {
markers: {},
infowins: {},
speed: 1,
idx:0,
transferAddressByGroup(ifPlay){
const data = replay.data;
......@@ -34,112 +35,47 @@ const replay = {
},
init(){
if(!replay.pathSPromise){
replay.pathSPromise = new Promise(function(resolve, reject){
AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) {
if (!PathSimplifier.supportCanvas) {
alert('当前环境不支持 Canvas!');
return;
}
replay.PathS = PathSimplifier;
resolve()
});
})
}
var replayData = []
var replayData = []
replay.data.forEach(function(item){
var arr = [];
arr.push(item.elng)
arr.push(item.elat)
replayData.push(arr)
let lnglat=mapService.getLngLat(item.elng,item.elat)
replayData.push(lnglat)
});
const MAP = mapService.map;
replay.pathSPromise.then(()=>{
if(replay.PathS){
replay.pathSimplifierIns = new replay.PathS({
zIndex: 100,
map: MAP, //所属的地图实例
getPath: function(pathData, pathIndex) {
//返回轨迹数据中的节点坐标信息,[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
return pathData.path;
},
getHoverTitle(){
return ''
},
clickToSelectPath: false,
renderOptions: {
//轨迹线的样式
pathLineStyle: {
strokeStyle: '#0b94db',
lineWidth: 6,
dirArrowStyle: true
}
}
});
replay.dis = AMap.GeometryUtil.distanceOfLine(replayData) / 1000 // 算出轨迹的距离(km)
replay.pathSimplifierIns.setData([{
path: replayData
}]);
replay.pathSimplifierIns.show();
//创建一个巡航器
replay.navg = replay.pathSimplifierIns.createPathNavigator(0, //关联第1条轨迹
{
loop: false, //循环播放
speed: replay.getSpeed(replay.speed, replay.dis),
pathNavigatorStyle: {
width: 36,
height: 22,
//使用图片
content: replay.PathS.Render.Canvas.getImageContent('https://e-shield-old.glsx.com.cn/images/icon_car.png'),
initRotateDegree: -90
}
});
const firstItem = replay.data[0];
const lnglat = new AMap.LngLat(firstItem.elng, firstItem.elat);
replay.navgInfoWindow = new AMap.InfoWindow({
isCustom: true,
position: lnglat,
content: replay.getNavgInfoContent(firstItem),
offset: new AMap.Pixel(80, -20)
});
replay.navgInfoWindow.open(MAP)
replay.navg.start();
replay.navg.on('move', function(e){
replay.navgTimeoutId && clearTimeout(replay.navgTimeoutId);
replay.navgTimeoutId = setTimeout(()=>{
let idx = replay.navg.getCursor().idx;
let lnglat = replay.navg.getPosition();
let item = replay.data[idx]
replay.navgInfoWindow.setContent(replay.getNavgInfoContent(item));
replay.navgInfoWindow.open(MAP)
replay.navgInfoWindow.setPosition(lnglat);
EventBus.$emit('uiMap.replay.currAddress', '');
}, 0)
let idx = replay.navg.getCursor().idx;
if(idx === replay.data.length-1){
EventBus.$emit('uiMap.replay.done');
}
//$playBtn.addClass('active');
//$pauseBtn.removeClass('active');
/**/
});
let startPoint = replay.data[0];
let endPoint = replay.data[replay.data.length-1];
replay.startMarker = mapService.createStartMarker([startPoint.elng, startPoint.elat], MAP);
replay.endMarker = mapService.createEndMarker([endPoint.elng, endPoint.elat], MAP);
EventBus.$emit('uiMap.replay.initDone')
}
})
let p1=replayData[0];
let p2=replayData[replayData.length-1];
let line = AMap.invoke('Polyline', replayData, { strokeColor: '#0b94db',strokeWeight: 6 })
replay.startMarker = mapService.createStartMarker(p1, AMap);
replay.endMarker = mapService.createEndMarker(p2, AMap);
replay.dis = AMap.invoke('getDistance', p1, p2)/1000 // 算出轨迹的距离(km)
AMap.invoke('setViewport',replayData);
AMap.invoke('addOverlay', line)
AMap.invoke('addOverlay', replay.startMarker)
AMap.invoke('addOverlay', replay.endMarker )
const firstItem = replay.data[0];
replay.navg= AMap.invoke('LuShu', replayData, {
defaultContent: replay.getNavgInfoContent(firstItem),
autoView: true, // 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
speed: replay.getSpeed(replay.speed, replay.dis),
icon: AMap.invoke('Icon', 'https://e-shield-old.glsx.com.cn/images/icon_car.png', AMap.invoke('Size', 36, 22),{ anchor: AMap.invoke('Size', 24, 24) }),
enableRotation: true, // 是否设置marker随着道路的走向进行旋转
})
AMap.invoke('lushuStart') //开始
// AMap.invoke('lushuStop') //停止
// AMap.invoke('lushuPause') //暂停
// AMap.invoke('lushuShowInfoWindow') //打开信息窗口
EventBus.$emit('uiMap.replay.initDone')
AMap.invoke('lushuAddEventListener','move', (e) =>{
this.idx = e.target.i;
let lnglat = replayData[this.idx]
let item=replay.data[this.idx]
AMap.invoke('lushuSetContent',replay.getNavgInfoContent(item)) //设置信息窗口文案
EventBus.$emit('uiMap.replay.currAddress', '');
console.log(this.idx,replay.data.length-1)
if(this.idx >= replay.data.length-2){
EventBus.$emit('uiMap.replay.done');
}
});
},
getNavgInfoContent(item){
return `<div class="navg-info-window">
......@@ -152,18 +88,18 @@ const replay = {
</div>`
},
destroy: function(){
const MAP = mapService.map;
if(replay.pathSimplifierIns){
replay.pathSimplifierIns.hide();
replay.pathSimplifierIns.clearPathNavigators();
MAP.remove(replay.navgInfoWindow);
}
// const MAP = mapService.map;
// if(replay.pathSimplifierIns){
// replay.pathSimplifierIns.hide();
// replay.pathSimplifierIns.clearPathNavigators();
// MAP.remove(replay.navgInfoWindow);
// }
replay.startMarker && MAP.remove(replay.startMarker);
replay.endMarker && MAP.remove(replay.endMarker);
replay.data = [];
EventBus.$emit('uiMap.transfer.currAddress', '')
this.clearTimeoutIds()
// replay.startMarker && MAP.remove(replay.startMarker);
// replay.endMarker && MAP.remove(replay.endMarker);
// replay.data = [];
// EventBus.$emit('uiMap.transfer.currAddress', '')
// this.clearTimeoutIds()
},
bindEvent(){
//解析轨迹地址
......@@ -183,24 +119,24 @@ const replay = {
});
//播放轨迹
EventBus.$on('uiMap.replay.play', function(){
EventBus.$on('uiMap.replay.play', ()=>{
console.log(replay.navg)
if(replay.navg){
if(replay.navg.getCursor().idx === replay.navg.getPathEndIdx()){
replay.navg.start();
}else if(replay.navg.getNaviStatus()==='pause'){
replay.navg.resume();
}else{
replay.navg.start();
if(this.idx === replay.data.length-1){
AMap.invoke('stop')
AMap.invoke('lushuStart') //开始
}else {
AMap.invoke('lushuStart');
}
}
});
//轨迹暂停
EventBus.$on('uiMap.replay.pause', function(ifShowAddr){
EventBus.$on('uiMap.replay.pause', (ifShowAddr)=>{
if(replay.navg){
replay.navg.pause();
AMap.invoke('lushuPause')
if(ifShowAddr){
let idx = replay.navg.getCursor().idx;
let idx =this.idx
if(replay.data[idx].transferAddress){
EventBus.$emit('uiMap.replay.currAddress', replay.data[idx].transferAddress);
}else{
......@@ -216,16 +152,16 @@ const replay = {
//轨迹刷新
EventBus.$on('uiMap.replay.refresh', function(){
if(replay.navg){
replay.navg.start();
AMap.invoke('lushuStop') //停止
AMap.invoke('lushuStart') //开始
}
});
//播放轨迹,速度改变
EventBus.$on('uiMap.replay.speedChange', function(data){
let speed = replay.getSpeed(data, replay.dis)
if(replay.navg){
replay.navg.setSpeed(speed)
AMap.invoke('lushuSetSpeed',speed)
}
});
......@@ -278,6 +214,7 @@ const replay = {
//mapService.setFitView(MAP);
},
speedEvent(idx, dis) {
console.log(idx, dis)
let timeArr = [[40, 30, 16], [30, 20, 12], [20, 12, 8], [5, 3, 2]] // 慢 正常 快 很快
let speed
if (dis >= 100) { // 100公里以上
......
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-20 10:11:12
* @FilePath: \oEshield\src\utils\resident.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import EventBus from '../event-bus'
import mapService from './mapService.js'
import mapService from './mapBService.js'
import MAPGEO from './mapgeo'
//常驻地
......@@ -19,56 +27,42 @@ const resident = {
EventBus.$on('uiMap.resident.openInfoWindow', (idx)=>{
if(this.markers[idx]){
const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition();
this.infowins[idx].open(MAP, lnglat);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat);
AMap.invoke("mapOpenInfoWindow", this.infowins[idx],lnglat)
AMap.invoke('centerAndZoom',lnglat,13)
}
});
},
draw(data){
const MAP = mapService.map;
this.data = data;
// MAPGEO.transferAddressByGroup(this, ()=>{
// EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
// this.data.forEach((item)=>{
// if(parseFloat(item.elng) === 0 && parseFloat(item.elat) === 0) return;
// let marker = mapService.createConstantMarker([parseFloat(item.elng), parseFloat(item.elat)], MAP);
// let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item);
// this.markers[item.idx] = marker;
// this.infowins[item.idx] = infoWindow;
// });
// mapService.setFitView(MAP);
// });
let paths=[]
// v1.7.0常驻地为保证导出内容与显示一致 取后端返回的address 不需高德逆地址解析
EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
this.data.forEach((item)=>{
if(parseFloat(item.elng) === 0 && parseFloat(item.elat) === 0) return;
let marker = mapService.createConstantMarker([parseFloat(item.elng), parseFloat(item.elat)], MAP);
let lnglatXY=mapService.getLngLat(parseFloat(item.elng), parseFloat(item.elat));
paths.push(lnglatXY)
let marker = mapService.createConstantMarker(lnglatXY, MAP);
let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item);
this.markers[item.idx] = marker;
this.infowins[item.idx] = infoWindow;
MAP.invoke('addOverlay',this.markers[item.idx])
});
mapService.setFitView(MAP);
AMap.invoke('setViewport',paths)
// mapService.invoke('panTo', MAP.getCenter())
},
intervalDraw(){
},
destroy: function(){
const MAP = mapService.map;
for(let idx in this.markers){
MAP.remove(this.markers[idx])
AMap.invoke('removeOverlay',this.markers[idx])
}
for(let idx in this.infowins){
MAP.remove(this.infowins[idx])
AMap.invoke('mapCloseInfoWindow')
}
this.markers = {};
this.infowins = {};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!