Commit a668374c by 前端

Merge branch 'v1.23.0' into 'master'

V1.23.0版本需求已上线,合并代码到master

See merge request !38
2 parents 80a00715 74e9eed3
......@@ -1591,6 +1591,16 @@
"integrity": "sha1-MgmlHKSkrVQaO409am1bg6JIWTU=",
"dev": true
},
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmmirror.com/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"dev": true,
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bluebird": {
"version": "3.5.1",
"resolved": "http://registry.npm.taobao.org/bluebird/download/bluebird-3.5.1.tgz",
......@@ -4217,6 +4227,13 @@
"schema-utils": "^0.4.5"
}
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true,
"optional": true
},
"filename-regex": {
"version": "2.0.1",
"resolved": "http://registry.npm.taobao.org/filename-regex/download/filename-regex-2.0.1.tgz",
......@@ -4445,8 +4462,9 @@
"dev": true,
"optional": true,
"requires": {
"nan": "^2.3.0",
"node-pre-gyp": "^0.6.39"
"bindings": "^1.5.0",
"nan": "^2.12.1",
"node-pre-gyp": "*"
},
"dependencies": {
"abbrev": {
......@@ -4997,6 +5015,13 @@
"dev": true,
"optional": true
},
"nan": {
"version": "2.17.0",
"resolved": "https://registry.npmmirror.com/nan/-/nan-2.17.0.tgz",
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==",
"dev": true,
"optional": true
},
"node-pre-gyp": {
"version": "0.6.39",
"bundled": true,
......@@ -8376,13 +8401,6 @@
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",
"dev": true
},
"nan": {
"version": "2.10.0",
"resolved": "http://registry.npm.taobao.org/nan/download/nan-2.10.0.tgz",
"integrity": "sha1-ltDNYQ69WNS03pzAxoKM2pnHVI8=",
"dev": true,
"optional": true
},
"nanomatch": {
"version": "1.2.9",
"resolved": "http://registry.npm.taobao.org/nanomatch/download/nanomatch-1.2.9.tgz",
......
import request from './request'
// 新增poi点
export const ADD_POI_INFO = params => {
return request(params, '/trialdrive/poifence/add', 'post')
}
// 修改poi点信息
export const UPDATE_POI_INFO = params => {
return request(params, '/trialdrive/poifence/update', 'post')
}
// 修改poi点状态
export const MODIFY_POI_INFO = params => {
return request(params, '/trialdrive/poifence/modify', 'get')
}
// 删除poi点
export const DELETE_POI_INFO = params => {
return request(params, '/trialdrive/poifence/delete', 'get')
}
// 获取历史poi点
export const GET_POI_TRACK = params => {
return request(params, '/trialdrive/poifence/queryPoiTrack', 'get')
}
// 获取历史poi详情
export const GET_POI_INFO = params => {
return request(params, '/trialdrive/poifence/findone', 'get')
}
// 校验poi名称
export const CHECK_POI_NAME = params => {
return request(params, '/trialdrive/poifence/checkPoiName', 'get')
}
.bottom_list {
position: absolute;
left: 0;
right: 0;
bottom: 0;
background: #fff;
//height: 313px;
z-index: 999;
display: flex;
flex-direction: column;
.head {
flex-shrink: 0;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
padding: 11px 15px;
.left {
font-weight: 400;
font-size: 16px;
color: #333333;
.cred {
color: #EE3040;
}
.btn {
width: 88px;
height: 32px;
background: #9999991a;
border: 1px solid #CCCCCC;
border-radius: 4px;
padding: 0;
box-sizing: border-box;
font-weight: 500;
font-size: 16px;
color: #666666;
// line-height: 32px;
cursor: pointer;
}
.btn:hover {
background: #2196f31a;
color: #2196F3;
border-color: #2196F3;
}
}
.right {
display: flex;
align-items: center;
.link {
width: 48px;
height: 24px;
text-align: center;
line-height: 24px;
font-weight: 400;
font-size: 16px;
color: #999999;
text-decoration: none;
}
.link:hover {
background: #2196f31a;
border-radius: 2px;
color: #2196F3;
}
}
}
.head:after {
position: absolute;
display: block;
content: "";
height: 1px;
background: #D2D2D2;
left: 0;
right: 0;
bottom: 0;
transform: scaleY(0.5);
opacity: 0.5;
}
.content {
flex: 1;
overflow-y: auto;
}
}
.bottom_list_hide {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 24px;
border-radius: 4px 4px 0px 0px;
background: #fff;
z-index: 999;
right: 0;
bottom: 0;
cursor: pointer;
box-shadow: 0 -2px 10px 0 #0000001a;
i {
margin-right: 4px;
}
span {
font-weight: 400;
font-size: 14px;
color: #666666;
}
}
.bottom_list_hide:hover {
background: #185efe33;
i,
span {
color: #185EFE;
}
}
.addPoiForm {
display: flex;
padding: 20px;
.form_list {
flex: 1;
}
.lnglat_box {
display: flex;
.el-form-item {
flex: 1;
}
}
}
.btn_box {
display: flex;
justify-content: flex-end;
border-top: 1px solid #f2f2f2;
padding: 10px 20px;
}
.map-seacrh-wrap {
position: absolute;
top: 40px;
left: 10px;
z-index: 1000;
}
\ No newline at end of file
......@@ -571,28 +571,31 @@
.map-infowindow-title {
position: relative;
padding-right:30px;
padding-right: 30px;
.question_icon {
display:inline-block;
display: inline-block;
background: url('https://img01.glsx.com.cn/weapp/resource/e-shield/circle-question.png') no-repeat;
background-size: 20px auto;
width: 20px;
height: 20px;
vertical-align: middle;
}
.popover_box {
position: absolute;
background: rgba(0, 0, 0, 0.5);
top: 20px;
right: 0px;
padding:10px;
z-index:2;
border-radius:4px;
color:#fff;
font-size:12px;
padding: 10px;
z-index: 2;
border-radius: 4px;
color: #fff;
font-size: 12px;
pointer-events: none;
p{
margin:0;
p {
margin: 0;
}
}
}
......@@ -600,5 +603,47 @@
.map_info_window {
position: relative;
}
// 新增poi 弹框样式
.map_poi_infowindow_popup {
width: 360px;
}
.map_poi_infowindow_title {
position: relative;
padding: 0 10px 10px 10px;
max-width: 400px;
}
.map_poi_infowindow_title:after {
display: block;
content: "";
height: 1px;
background: #f2f2f2;
position: absolute;
left: -10px;
right: -10px;
bottom: 0;
}
.map_poi_infowindow_content {
padding: 10px;
display: flex;
justify-content: space-between;
.clear_link {
flex-shrink: 0;
background: #409EFF;
border-radius: 4px;
border: 0;
color: #fff;
padding: 4px 10px;
cursor: pointer;
}
.clear_link:hover {
opacity: 0.8;
}
}
\ No newline at end of file
// 图片请求域名前缀
export const IMAGE_PREFIX = 'https://img01.glsx.com.cn/weapp/resource';
export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
export const MAP_SERVICE_KEY = 'd22348363c34c266f772ae9b635eef2a'
......@@ -22,5 +25,10 @@ export const CONSTANT = {
MAP_KEY,
MAP_SERVICE_KEY,
MAP_PLUGINS,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=${MAP_PLUGINS.toString()}`
}
// 静态图标地址
export const STATICIMAGE = {
POI_MARKER:`${IMAGE_PREFIX}/e-shield/poi_icon.gif`,
POI_MASS_ICON:`${IMAGE_PREFIX}/e-shield/poi-marker-default.png`
}
\ No newline at end of file
......@@ -20,6 +20,10 @@ import store from '@/vuex/store.js'
import App from '@/App.vue'
import Vue from 'vue'
// 全局引入地图
import {mapInit} from '@/utils/mapInit';
Vue.prototype.$mapInit = mapInit
Vue.component('vLayout', vLayout)
Vue.component('vFullLayout', vFullLayout)
......
......@@ -79,13 +79,14 @@
<style scoped>
ul.map-control{
position: absolute;
bottom: 260px;
top: 50%;
right: 10px;
list-style: none;
padding: 5px;
margin: 0px;
background-color: rgba(0,0,0,0.1);
z-index: 102;
transform: translateY(-50%);
}
.map-control>li{
width: 30px;
......
<template>
<div class="map-wrap" >
<div id="map" class="map-container" v-loading="mapLoading"></div>
<div class="menu-search">
<el-input placeholder="请输入对应条件值" v-model="search.text" size="small" class="input-with-select">
<el-select v-model="search.type" 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-input>
<el-button icon="el-icon-search" size="mini" type="primary" :loading="search.isSearching" @click="searchSubmit">搜索</el-button>
<el-button :icon="search.showResult?'fa fa-caret-up':'fa fa-caret-down'" size="mini" type="primary" @click="toggleResult"></el-button>
</div>
</div>
<div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div>
<div class="menu-search">
<el-input
placeholder="请输入对应条件值"
v-model="search.text"
size="small"
class="input-with-select"
>
<el-select
v-model="search.type"
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-input>
<el-button
icon="el-icon-search"
size="mini"
type="primary"
:loading="search.isSearching"
@click="searchSubmit"
>搜索</el-button
>
<el-button
:icon="search.showResult ? 'fa fa-caret-up' : 'fa fa-caret-down'"
size="mini"
type="primary"
@click="toggleResult"
></el-button>
</div>
</div>
</template>
<script>
import remoteLoad from 'utils/remoteLoad.js'
import mapService from 'utils/mapService.js'
import 'utils/mapEvent.js'
import MapMenu from './MapMenu.vue'
import MapTable from './MapTable.vue'
import MapControll from './MapControll.vue'
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import "utils/mapEvent.js";
import MapMenu from "./MapMenu.vue";
import MapTable from "./MapTable.vue";
import MapControll from "./MapControll.vue";
import EventBus from '../../event-bus'
import EventBus from "../../event-bus";
import {services} from '../../api'
import mock from '../../mock'
const MONITOR_SERVICE = services.monitor;
import { services } from "../../api";
import mock from "../../mock";
const MONITOR_SERVICE = services.monitor;
import {CONSTANT} from '../../constant'
import { CONSTANT } from "../../constant";
export default{
data(){
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false
}
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
export default {
data() {
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
};
},
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;
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
},
async created () {
if(window.AMap){
this.initMap();
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
},
beforeDestroy(){
this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
},
components: {
}
}
//this.bindEvent();
this.isInitMap = true;
} else {
this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
},
},
async created() {
let _this = this;
_this.$mapInit({ version: "1.0.11" }).then((AMap) => {
_this.initMap();
});
},
beforeDestroy() {
this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval);
},
components: {},
};
</script>
<style scoped>
.map-wrap{
position: absolute;
top: 100px;
left: 0;
width: 100%;
height: calc(100% - 100px);
overflow: hidden;
}
.map-container{
width: 100%;
height: 100%;
z-index: 100
}
.el-loading-mask{
z-index: 101;
}
.menu-search{
position: absolute;
top: 20px;
left: 20px;
}
.map-wrap {
position: absolute;
top: 100px;
left: 0;
width: 100%;
height: calc(100% - 100px);
overflow: hidden;
}
.map-container {
width: 100%;
height: 100%;
z-index: 100;
}
.el-loading-mask {
z-index: 101;
}
.menu-search {
position: absolute;
top: 20px;
left: 20px;
}
</style>
\ No newline at end of file
......@@ -4,21 +4,26 @@
<el-breadcrumb-item>激活位置</el-breadcrumb-item>
</template>
<template slot="main">
<div class="device_list" v-if="deviceList && deviceList.length>1">
<div class="device_list" v-if="deviceList && deviceList.length > 1">
<div class="title">
<span>设备列表({{deviceList.length}})</span>
<span>设备列表({{ deviceList.length }})</span>
<!-- <i class="el-icon-close i_close"></i> -->
</div>
<div class="list_box">
<div class="cell" v-for="(item,index) in deviceList" :key="index" @click="openMapInfoWindow(item.sn, item.vin)">
<div
class="cell"
v-for="(item, index) in deviceList"
:key="index"
@click="openMapInfoWindow(item.sn, item.vin)"
>
<div class="top">
<i class="i_circle" :class="item.status == 2?'i_red':''"></i>
<span>{{item.ownerName||''}}</span>
<span>{{item.sn||''}}({{statusList[item.source]}})</span>
<i class="i_circle" :class="item.status == 2 ? 'i_red' : ''"></i>
<span>{{ item.ownerName || "" }}</span>
<span>{{ item.sn || "" }}({{ statusList[item.source] }})</span>
</div>
<div class="bottom">
<span>车架号:</span>
<span>{{item.vin||''}}</span>
<span>{{ item.vin || "" }}</span>
</div>
</div>
</div>
......@@ -55,17 +60,10 @@ export default {
},
created() {
console.log(history.state);
if (window.AMap) {
this.initMap();
} else {
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
() => {
this.initMap();
}
);
});
}
let _this = this;
_this.$mapInit({ version: "1.0.11" }).then((AMap) => {
_this.initMap();
});
},
methods: {
// 初始化地图
......@@ -93,10 +91,10 @@ export default {
}
// 兼容其他页面的跳转
if(query && query.sn){
query.elat = query.lat
query.elng = query.lng
this.addLocation(query,true);
if (query && query.sn) {
query.elat = query.lat;
query.elng = query.lng;
this.addLocation(query, true);
return false;
}
......@@ -104,7 +102,7 @@ export default {
if (o.lng || o.bsLng) {
o.elat = o.lat;
o.elng = o.lng;
this.addLocation(o,true);
this.addLocation(o, true);
}
} else {
this.checkLoadedTimeoutId = check();
......@@ -295,5 +293,4 @@ export default {
.i_red {
background: #f00;
}
</style>
\ No newline at end of file
......@@ -217,17 +217,10 @@ export default {
},
},
created() {
if (window.AMap) {
this.initMap();
} else {
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
() => {
this.initMap();
}
);
});
}
let _this = this;
_this.$mapInit({ version: "1.0.11" }).then((AMap) => {
_this.initMap();
});
//this.keyupSubmit();
//EventBus.$on("uiMap.monitor.drawDone", this.drawDoneCb);
//EventBus.$on("uiMap.monitor.changeELocate", this.changeELocate);
......
......@@ -11,65 +11,137 @@
<el-scrollbar class="el_scrollbar">
<div class="search-box">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" size="mini" class="form" label-position="top">
<p class="info">{{ name }}/{{ standno }}/{{ sn }}</p>
<el-form
ref="form"
:model="form"
:rules="rules"
size="mini"
class="form"
label-position="top"
>
<el-form-item label="定位方式">
<el-select v-model="form.locationType" class="a_select" placeholder="请选择" size="small" :disabled="true">
<el-select
v-model="form.locationType"
class="a_select"
placeholder="请选择"
size="small"
:disabled="true"
>
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" maxlength="200"></el-input>
<el-input
v-model.trim="form.fenceName"
maxlength="200"
></el-input>
</el-form-item>
<el-form-item label="触发类型" prop="triggerType">
<el-select v-model="form.triggerType" class="a_select" placeholder="请选择" size="small">
<el-select
v-model="form.triggerType"
class="a_select"
placeholder="请选择"
size="small"
>
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="dateRange">
<el-date-picker style="width: 100%;" v-model="form.dateRange" type="daterange" size="small" :clearable="false" :editable="false" :unlink-panels="true" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
<el-date-picker
style="width: 100%"
v-model="form.dateRange"
type="daterange"
size="small"
:clearable="false"
:editable="false"
:unlink-panels="true"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item is-required">
<el-form-item
label="监控区域"
class="row-form-item is-required"
>
<div class="el_radio_group">
<div class="radio_cell">
<el-radio :label="1" v-model="form.shapeType">圆形</el-radio>
<el-radio :label="1" v-model="form.shapeType"
>圆形</el-radio
>
<el-form-item label="" prop="radius">
<el-input v-model.trim="form.radius" style="width:120px" maxlength="200">
<el-input
v-model.trim="form.radius"
style="width: 120px"
maxlength="200"
>
<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
>
</el-form-item>
</div>
<div class="radio_cell">
<el-radio :label="3" v-model="form.shapeType">多边形</el-radio>
<div class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</div>
<el-radio :label="3" v-model="form.shapeType"
>多边形</el-radio
>
<div class="shape_tip">
*注:地图任意位置,单击新增双击结束绘制。
</div>
</div>
<div class="radio_cell">
<el-radio :label="4" v-model="form.shapeType">行政区域</el-radio>
<el-radio :label="4" v-model="form.shapeType"
>行政区域</el-radio
>
<el-form-item label="" prop="areaName">
<city-select v-model="form.areaName" :checkStrictly="true" :disabled="form.shapeType != 4" @change="changeArea"></city-select>
<city-select
v-model="form.areaName"
:checkStrictly="true"
:disabled="form.shapeType != 4"
@change="changeArea"
></city-select>
</el-form-item>
</div>
</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="围栏状态" class="is-required">
<el-radio v-model="form.enableStatus" :label="1">开启</el-radio>
<el-radio v-model="form.enableStatus" :label="0">关闭</el-radio>
<el-radio v-model="form.enableStatus" :label="1"
>开启</el-radio
>
<el-radio v-model="form.enableStatus" :label="0"
>关闭</el-radio
>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
<el-button
type="primary"
@click="submit"
size="small"
:loading="isSubmitting"
>保存</el-button
>
</el-form-item>
</el-form>
</div>
</el-scrollbar>
</div>
<!-- <el-alert v-show="showSuccessTips" :title="`保存成功,页面将在${timer}秒后自动关闭`" type="success" :closable="false" show-icon class="show_success_tips"></el-alert> -->
<!-- <el-dialog title="提示" custom-class="monitor_dialog" :visible.sync="showSuccessTips" width="340px" append-to-body :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false">
......@@ -86,13 +158,20 @@
<div class="monitor_dialog" v-show="showSuccessTips">
<div class="monitor_dialog_content">
<i class="el-icon-circle-check i_icon"></i>
<span class="tips">{{`保存成功,页面将在${timer}秒后自动关闭`}}</span>
<el-button type="primary" class="btn" size="small" @click="closePage">立即关闭</el-button>
<span class="tips">{{
`保存成功,页面将在${timer}秒后自动关闭`
}}</span>
<el-button
type="primary"
class="btn"
size="small"
@click="closePage"
>立即关闭</el-button
>
</div>
<div class="blk"></div>
</div>
<!-- 提示弹框 end -->
</div>
</template>
</v-full-layout>
......@@ -109,7 +188,6 @@ import { CONSTANT } from "@/constant";
import { deepClone, showToast } from "@/utils/utils";
import AreaSelect from "./AreaSelect.vue";
import MapControll from "./MapControll.vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import { GET_DEVICE_LOCATION } from "@/api/services/monitor";
import CitySelect from "@/components/area";
import { SAVE_ELECFENCE_INFO } from "@/api/services/fence";
......@@ -256,11 +334,8 @@ export default {
// 初始化地图
initMap() {
let _this = this;
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: CONSTANT.MAP_PLUGINS, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
_this.$mapInit().then((AMap) => {
window.AMap = AMap;
window.AMap = AMap;
_this.map = mapService.init("map");
_this.getDevinceInfo();
......@@ -614,8 +689,8 @@ export default {
}
.tips {
margin: 15px 0;
font-size:14px;
color:#999;
font-size: 14px;
color: #999;
}
}
}
......
......@@ -26,16 +26,25 @@
<div id="mapContainer" class="map-container"></div>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll>
<fence-map-controll
@onRefreshMap="refreshMap"
:isModalMap="true"
></fence-map-controll>
<div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入搜索地址" id="fenceMapSearch" size="small" maxlength="200" v-model="fenceMapSearch" :disabled="readonlyStatus">
<el-input
placeholder="请输入搜索地址"
id="fenceMapSearch"
size="small"
maxlength="200"
v-model="fenceMapSearch"
:disabled="readonlyStatus"
>
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
</div>
</div>
<!-- <div slot="footer" class="dialog-footer">
......@@ -51,7 +60,6 @@ import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant";
import AMapLoader from "@amap/amap-jsapi-loader";
export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() {
......@@ -93,11 +101,8 @@ export default {
},
mounted() {
let _this = this;
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: "1.4.2",
plugins: CONSTANT.MAP_PLUGINS,
}).then((AMap) => {
let plugins = ["AMap.LngLat", "AMap.AutoComplete"];
_this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => {
window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu();
......@@ -168,22 +173,36 @@ export default {
}
});
AMap.event.addListener(self.auto, "select", (e) => {
console.log(e.poi)
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);
/*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.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);
// });
});
},
bindContextMenu() {
......@@ -201,7 +220,7 @@ export default {
contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat;
});
self.contextMenu = contextMenu
self.contextMenu = contextMenu;
//contextMenu.open(self.mapObj, lnglat);
},
drawFence() {
......@@ -229,10 +248,10 @@ export default {
} else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
}
},
drawFenceCircle(fenceCenter) {
......@@ -254,6 +273,9 @@ export default {
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", {
......@@ -416,19 +438,33 @@ export default {
return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () {
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition();
self.geolocation.getCurrentPosition(function (status, result) {
if (status == "complete") {
var lnglatXY = mapService.getLngLat(
result.position.lng,
result.position.lat
);
resolve(lnglatXY);
}
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());
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());
// });
});
});
},
......
......@@ -383,7 +383,6 @@ import { CONSTANT } from "@/constant";
import MapControll from "./MapControll.vue";
import { exportExcel } from "@/utils";
import { GET_MONITOR_ONLINELIST } from "@/api/services/monitor";
import AMapLoader from "@amap/amap-jsapi-loader";
export default {
data() {
let checkFilename = (rule, vaule, cb) => {
......@@ -1319,10 +1318,9 @@ export default {
}
} */
this._drawTimeoutId = setTimeout(() => {
this.getPositionData();
}, 10 * 1000);
}, 60 * 1000);
},
terminate() {
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
......@@ -1419,17 +1417,6 @@ export default {
},
},
created() {
// if (window.AMap) {
// this.initMap();
// } else {
// remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// this.initMap();
// }
// );
// });
// }
this.keyupSubmit();
EventBus.$on("uiMap.monitor.drawDone", this.drawDoneCb);
EventBus.$on("uiMap.monitor.changeELocate", this.changeELocate);
......@@ -1439,19 +1426,9 @@ export default {
},
mounted() {
let _this = this;
if (window.AMap) {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: "1.4.2",
plugins: CONSTANT.MAP_PLUGINS,
}).then((AMap) => {
_this.$mapInit({ version: "2.0" }).then((AMap) => {
window.AMap = AMap;
_this.initMap();
}).catch(error => {
window.location.reload()
});
},
beforeDestroy() {
......
......@@ -186,7 +186,6 @@
<script>
import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant";
import CitySelect from "@/components/area";
import {
......@@ -254,24 +253,12 @@ export default {
"AMap.LabelsLayer",
"AMap.LabelMarker",
]);
if (window.AMap) {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map");
})
.catch((error) => {
console.log(error);
window.location.reload();
});
_this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map");
});
},
// 画矩形
......@@ -377,7 +364,8 @@ export default {
let num = w ? w / 2 : 500 / 2;
// 中心点-左边点的经纬度
let leftLng = lng + (num * Math.sin(180)) / ((arc * Math.cos(lat) * 2 * pi) / 360);
let leftLng =
lng + (num * Math.sin(180)) / ((arc * Math.cos(lat) * 2 * pi) / 360);
// let leftLat = lat;
// 中心点-下边点的经纬度
......@@ -437,8 +425,8 @@ export default {
console.log(location);
let lnglats = this.getLngLat(location.lng, location.lat);
console.log(lnglats)
console.log(this.getLngLat2(location.lng, location.lat))
console.log(lnglats);
console.log(this.getLngLat2(location.lng, location.lat));
this.drawRectangle(lnglats);
},
......
......@@ -162,7 +162,6 @@
<script>
import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant";
import {
GER_REGIONAL_SEARCH,
......@@ -238,42 +237,33 @@ export default {
"AMap.MassMarks",
"AMap.MarkerCluster",
"AMap.Bounds",
"AMap.MouseTool"
]);
if (window.AMap) {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 11 });
_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);
}
})
.catch((error) => {
console.log(error);
window.location.reload();
_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()]);
});
},
// 获取地址
......
......@@ -273,7 +273,15 @@ const routes = [
meta: { title: '设备激活位置' },
component: () => import('pages/monitor/activeLocation.vue'),
notMenu: true,
}]
},
{
path: 'addPoi',
name: 'addPoi',
meta: { title: '新增POI' },
component: () => import('pages/monitor/addPoi.vue'),
notMenu: true,
}
]
},
{
path: '/business',
......
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant";
export const mapInit = params => {
return new Promise((resolve,reject) => {
let options = params || {};
// let plugins = options.plugins|| CONSTANT.MAP_PLUGINS;
// let version = options.version || '2.0';
console.log(window.window)
console.log(window.AMap);
let _list = window.localStorage || {};
// if(window.AMap){
// let _amap = window.AMap|| {};
// console.log(_amap.version)
// if(options.version == _amap.version){
// resolve(window.AMap);
// }else{
// delete window.AMap;
// delete window.AMapUI;
// delete window.Loca;
// // 删除高德地图缓存,防止出现禁止多种API加载方式混用的bug
// for(let k in _list){
// if(k.indexOf('_AMap') == 0){
// localStorage.removeItem(k);
// }
// }
// }
// }
let mapConfig ={...options};
mapConfig.key = CONSTANT.MAP_KEY; // 申请好的Web端开发者Key,首次调用 load 时必填
mapConfig.version = options.version || '2.0'; // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
mapConfig.plugins = options.plugins|| CONSTANT.MAP_PLUGINS;// 需要使用的的插件列表,如比例尺'AMap.Scale'等
if(options.AMapUI){
mapConfig.AMapUI = options.AMapUI;
}
AMapLoader.reset();
AMapLoader.load(mapConfig).then((AMap) => {
window.AMap = AMap;
resolve(AMap);
})
.catch((error) => {
window.location.reload();
reject(error);
});
})
}
\ No newline at end of file
......@@ -29,7 +29,8 @@ MapService.prototype = {
}
var map = new AMap.Map(id, {
resizeEnable: true,
zoom: params.zoom||11
zoom: params.zoom||11,
...params
});
// 添加比例尺
......@@ -53,9 +54,18 @@ MapService.prototype = {
},
toggleMapType: function () {
var self = this;
let _map = self.map;
self.type = self.type ? 0 : 1; //0:使用2D地图,1:混合图
_map.plugin(["AMap.MapType"],function(){
//地图类型切换
let _mapType= new AMap.MapType({
defaultType: self.type,
});
_map.addControl(_mapType);
_mapType.hide();
});
return false;
if (self.type === 1) {
// 构造官方卫星、路网图层
......@@ -70,6 +80,7 @@ MapService.prototype = {
} else {
// 地图上设置图层
self.map.remove(self.mixLayers);
/*self.map.plugin(["AMap.MapType"],function(){
//地图类型切换
var type = new window.AMap.MapType({
......@@ -87,17 +98,28 @@ MapService.prototype = {
},
getCurrentLocation: function () {
var self = this;
self.geolocation.getCurrentPosition();
self.currentMarker && self.map.remove(self.currentMarker);
AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息
var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
self.currentMarker = self.createMarker(lnglatXY);
//self.map.setCenter(lnglatXY);
self.setFitView()
});
AMap.event.addListener(self.geolocation, 'error', function (e) {//返回定位出错信息
self.geolocation.getCurrentPosition(function(status,result){
console.log(status);
console.log(result);
if(status == 'complete'){
self.currentMarker && self.map.remove(self.currentMarker);
var lnglatXY = self.getLngLat(result.position.lng, result.position.lat);
self.currentMarker = self.createMarker(lnglatXY);
self.setFitView()
}
});
// console.log(self.geolocation)
// self.currentMarker && self.map.remove(self.currentMarker);
// AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息
// console.log(e);
// var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
// self.currentMarker = self.createMarker(lnglatXY);
// //self.map.setCenter(lnglatXY);
// self.setFitView()
// });
// AMap.event.addListener(self.geolocation, 'error', function (e) {//返回定位出错信息
// });
},
createMarker: function (lnglatXY) {
var marker = new AMap.Marker({
......@@ -935,6 +957,28 @@ MapService.prototype = {
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],
})
return infoWindow
}
}
const mapService = new MapService();
......
......@@ -62,6 +62,21 @@ const MAPGEO = {
})(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.formattedAddress;
});
}
function geocoderGetAdr(arr, initIdx) {
if (!arr || arr.length <= 0) {
return false;
......@@ -72,9 +87,10 @@ const MAPGEO = {
if (status === 'complete' && result.info === 'OK') {//获取地址成功
result.regeocodes.forEach((item, idx) => {
let o = arr[idx]
let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat);
//data[initIdx + idx].transferAddress = item.formattedAddress;
data[_idx].transferAddress = item.formattedAddress;
// let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat);
// //data[initIdx + idx].transferAddress = item.formattedAddress;
// data[_idx].transferAddress = item.formattedAddress;
setAddress(o, item);
obj.totalNum++;
});
if (obj.totalNum === obj.realNum) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!