Compare commits

...

3 Commits

@ -1,17 +1,14 @@
<template>
<el-dialog title="电子围栏" :close-on-click-modal="false" :visible="true" top="10vh" width="90%" append-to-body
<el-dialog :title="title" :close-on-click-modal="false" :visible="true" top="10vh" width="90%" append-to-body
modal-append-to-body :before-close="handleClose" class="my-dialog">
<div class="cont">
<div class="tips">
<p>1绘制鼠标左键点击及移动即可绘制图形; &nbsp;&nbsp; 2结束绘制鼠标左键双击即可结束绘制折线多边形会自动闭合圆形矩形椭圆单击即可结束;&nbsp;&nbsp;
3中断绘制过程中按下esc键可中断该过程</p>
<p>1绘制鼠标左键点击及移动即可绘制图形; &nbsp;&nbsp; 2结束绘制鼠标左键双击即可结束绘制折线多边形会自动闭合圆形矩形椭圆单击即可结束</p>
</div>
<div class="addpolygon">
<div id="mapFencecontainer">
<div class="mapBtn">
<el-button size="small" type="danger" @click="clearOverlays()"></el-button>
<el-button size="small" type="primary" @click="sendLngLat"></el-button>
<el-button size="small" type="primary" @click="sendMsg"></el-button>
</div>
</div>
<div class="loadMap" v-if="loadMapFlag">...</div>
@ -22,15 +19,14 @@
</template>
<script>
let marker, polygon, drawingManager, lngLat,ap, map;
let marker, polygon, drawingManager, lngLat,ap, map, MultiPolygon;
let path = [];//
import axios from 'axios'
// let map, marker, polygon, drawingManager, lngLat; //
let overlaysArray = []; // ,
let path4 = [];//
//
export default {
props: ['position', 'areaMapInfo'],
props: ['position', 'areaMapInfo', 'mode'],
data() {
return {
longitude: '',
@ -48,9 +44,16 @@ export default {
}
],
editor: null,
loadMapFlag: true
loadMapFlag: true,
targetAreaPath: []
};
},
computed: {
title() {
const str = this.mode == 'add' ? '新建电子围栏' : '编辑电子围栏'
return str
}
},
mounted() {
this.$nextTick(() => {
// this.init();
@ -62,19 +65,16 @@ export default {
this.$emit('areaVisibleChange', false)
},
clearOverlays() {
polyline.setMap(null);
polygon.setMap(null);
},
sendLngLat() {
},
sendMsg() {
this.$emit('areaVisibleChange', false, this.targetAreaPath)
},
/**
* //
*/
getMyLocation() {
var geolocation = new qq.maps.Geolocation('U24BZ-7UECT-ZSNXI-L3GJD-GZD3E-3YFF6', '易回收后台');
const geolocation = new qq.maps.Geolocation('U24BZ-7UECT-ZSNXI-L3GJD-GZD3E-3YFF6', '易回收后台');
geolocation.getLocation(this.showPosition, this.showErr);
},
showPosition(position) {
@ -94,63 +94,37 @@ export default {
* 位置信息在地图上展示
*/
setMapData() {
var myLatlng = new qq.maps.LatLng(this.position.latitude, this.position.longitude);
const myLatlng = new qq.maps.LatLng(this.position.latitude, this.position.longitude);
console.log("当前位置:"+this.position.latitude, this.position.longitude, myLatlng)
var myOptions = {
const myOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: qq.maps.MapTypeId.ROADMAP
}
console.log(myOptions)
//dom
map = new qq.maps.Map(document.getElementById('mapFencecontainer'), myOptions)
//
marker = new qq.maps.Marker({
position: myLatlng,
map: map,
draggable: false
})
this.mouseClick()
/**绘制围栏 */
this.addpolygon();
//
this.getAllPolygons()
},
/**
* 鼠标点击获取标记位置事件
*/
mouseClick () {
const _this = this
qq.maps.event.addListener(map, 'click', function (event) {
if(!marker) {
marker=new qq.maps.Marker({
position: event.latLng,
map:map
})
return
}
marker.setPosition(event.latLng)
console.log("鼠标点击位置:"+event.latLng)
_this.position.latitude = event.latLng.getLat();
_this.position.longitude = event.latLng.getLng();
_this.existsPolygon();
})
},
/**绘制围栏 */
addpolygon() {
const _this = this
const drawingControl = this.mode == 'add' ? true : false
drawingManager = new window.qq.maps.drawing.DrawingManager({
drawingMode: window.qq.maps.drawing.OverlayType.null, //
drawingControl: true,
drawingControl: drawingControl,
drawingControlOptions: {
position: window.qq.maps.ControlPosition.TOP_CENTER,
//
drawingModes: [
// window.qq.maps.drawing.OverlayType.MARKER,
// window.qq.maps.drawing.OverlayType.CIRCLE,
window.qq.maps.drawing.OverlayType.POLYGON,
// window.qq.maps.drawing.OverlayType.POLYLINE,
window.qq.maps.drawing.OverlayType.RECTANGLE
]
},
markerOptions: {
@ -163,30 +137,39 @@ export default {
fillColor: new window.qq.maps.Color(202, 67, 58, 0.1),
clickable: false
},
// //
// circleOptions: {
// fillColor: new window.qq.maps.Color(255, 208, 70, 0.3),
// strokeColor: new window.qq.maps.Color(88, 88, 88, 1),
// strokeWeight: 3,
// clickable: false
// }
});
drawingManager.setMap(map);
window.qq.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
console.log('overlaycomplete', event)
// clearOverlays(overlaysArray)
lngLat = [];
// overlaysArray.push(event.overlay);
// for (const item of event.overlay.getPath().elems) {
// const lng = item.getLng();
// const lat = item.getLat();
// lngLat.push({
// lat: lat,
// lng: lng
// });
// }
console.log("绘图后获得的:"+JSON.stringify(lngLat,null,4)); //
// polygon.setMap(null);
const lngLat = [];
for (const item of event.overlay.getPath().elems) {
const lng = item.getLng();
const lat = item.getLat();
lngLat.push({
lat: lat,
lng: lng
});
}
console.log("绘图后获得的:",JSON.stringify(lngLat,null,4), polygon); //
_this.showPolygons(lngLat, true)
});
//
window.qq.maps.event.addListener(polygon, 'adjustNode',function (event) {
console.log(99999, event)
const lngLat = [];
for (const item of event.path.elems) {
const lng = item.getLng();
const lat = item.getLat();
lngLat.push({
lat: lat,
lng: lng
});
}
this.targetAreaPath = lngLat
console.log("adjustNode后获得的"+JSON.stringify(lngLat,null,4)); //
})
},
/**
* 获取所有围栏
@ -250,7 +233,16 @@ export default {
]
}
]
if (this.mode == 'add') {
_this.polygonPath = _this.polygonPath.filter(e => !e.editable)
}
_this.showArrayPolygon()
/**绘制围栏 */
this.addpolygon();
},
/**循环调用显示围栏方法 */
showArrayPolygon(){
@ -263,6 +255,16 @@ export default {
_this.showpolygons(path, polygonpath.editable)
}
},
showMultiPolygons(path, editable) {
const _this = this
MultiPolygon = new TMap.MultiPolygon({
map: map,
editable,
strokeColor: new qq.maps.Color(202, 67, 58, 0.8),
fillColor: new qq.maps.Color(202, 67, 58, 0.1)
});
MultiPolygon.setPath(path);
},
/**
* 显示围栏
*/
@ -275,31 +277,10 @@ export default {
fillColor: new qq.maps.Color(202, 67, 58, 0.1)
});
polygon.setPath(path);
},
/**
* 当前位置是否在围栏中
*/
existsPolygon() {
const _this = this;
// console.log(":"+ _this.position.latitude,_this.position.longitude)
axios.post(url.url + "/v1/polygons/existPolygons", {
lng: _this.position.longitude, //getMyLocation obj.longitudeobj.latitude
lat: _this.position.latitude,
}).then(function (response) {
// response.datahttp or https
if(response.data.indexOf("http") == 0){
window.location.href = response.data;
} else {
_this.$notify({
title: '定位失败',
message: '经度: '+ _this.position.longitude + ", 纬度:" + _this.position.latitude + "" + "信息:" + response.data,
type: 'success'
})
// if (editable && this.mode == 'add') {
// polygon.setMap(map);
// }
}
}).catch(function (error) {
console.error(error);
});
},
}
};
</script>

@ -101,7 +101,7 @@
<!-- 表单结束 -->
</template>
</el-form>
<area-dialog :position="position" :areaMapInfo="dataForm.areaMapInfo" v-if="areaVisible" @areaVisibleChange="handleAreaVisibleChange" />
<area-dialog :mode="mode" :position="position" :areaMapInfo="dataForm.areaMapInfo" v-if="areaVisible" @areaVisibleChange="handleAreaVisibleChange" />
<!-- <SelectDialog v-if="selectDialogVisible" :config="currTableConf" :formData="dataForm"
ref="selectDialog" @select="addForSelect" @close="selectDialogVisible=false"/> -->
</el-row>
@ -122,7 +122,7 @@
import { thousandsFormat } from "@/components/Generator/utils/index"
export default {
components: { areaDialog },
props: [],
props: ['mode'],
data() {
return {
position: {},
@ -258,8 +258,11 @@
this.areaVisible = true
// this.getPosition()
},
handleAreaVisibleChange(areaVisible) {
handleAreaVisibleChange(areaVisible, targetAreaPath) {
this.areaVisible = areaVisible
if (targetAreaPath) {
this.dataForm.areaMapInfo = targetAreaPath
}
},
prev() {
this.index--

@ -142,7 +142,7 @@
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData"/>
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<JNPF-Form :mode="mode" v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download"/>
@ -222,6 +222,7 @@
sidx: "",
},
formVisible: false,
mode: '',
flowVisible: false,
flowListVisible: false,
flowList: [],
@ -485,6 +486,8 @@
this.initData()
},
addOrUpdateHandle(row, isDetail) {
const mode = row ? 'edit' : 'add'
this.mode = mode
let id = row?row.id:""
this.formVisible = true
this.$nextTick(() => {

@ -9,7 +9,6 @@ function resolve(dir) {
}
const name = defaultSettings.title || '易回收' // page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run

Loading…
Cancel
Save