Browse Source

地图偏移

shibei_master
jiangyy 3 years ago
parent
commit
9a082df227
  1. 2
      src/views/modules/visual/basicinfo/basicInfoMain.vue
  2. 268
      src/views/modules/workSys/mapConfig.vue

2
src/views/modules/visual/basicinfo/basicInfoMain.vue

@ -157,7 +157,7 @@ import People from "./people";
import cptCard from "@/views/modules/visual/cpts/card"; import cptCard from "@/views/modules/visual/cpts/card";
import ScreenLoading from "@/views/modules/visual/cpts/loading"; import ScreenLoading from "@/views/modules/visual/cpts/loading";
var centerPointGlobal = [120.38945519, 36.0722275] var centerPointGlobal = [120.664619, 36.504963]
let loading;// let loading;//

268
src/views/modules/workSys/mapConfig.vue

@ -1,49 +1,112 @@
<template> <template>
<div style="position: relative"> <div>
<div style="position: relative">
<div class="div_search">
<div class="div_search">
<el-select v-model="selAgencyId"
placeholder="请选择或点击区域选择"> <el-select v-model="selAgencyId"
<el-option @click.native="orgChange(index)" placeholder="请选择或点击区域选择">
v-for="(item,index) in subAgencyArray" <el-option @click.native="orgChange(index)"
:key="item.id" v-for="(item,index) in subAgencyArray"
:label="item.name" :key="item.id"
:value="item.id"> :label="item.name"
</el-option> :value="item.id">
</el-select> </el-option>
<div v-if="selAgencyId && subAgencyArray.length>0"> </el-select>
<el-button v-if="showBtn&&!hasPolygon" <div v-if="selAgencyId && subAgencyArray.length>0">
style="margin-left:10px" <el-button v-if="showBtn&&!hasPolygon"
type="primary" style="margin-left:10px"
icon="el-icon-plus" type="primary"
@click="handleAddPolygon">{{method==='mAddPolygon'?'取消绘制':'绘制区域'}}</el-button> icon="el-icon-plus"
<el-button v-if="showBtn&&hasPolygon" @click="handleAddPolygon">{{method==='mAddPolygon'?'取消绘制':'绘制区域'}}</el-button>
<el-button v-if="showBtn&&hasPolygon"
style="margin-left:10px"
type="primary"
icon="el-icon-edit"
@click="handleEditPolygon">{{method==='mEditPolygon'?'取消绘制':'重新绘制'}}</el-button>
<el-button v-if="showBtn&&hasPolygon"
style="margin-left:10px"
type="primary"
icon="el-icon-delete"
@click="handleDelPolygon">删除区域</el-button>
<el-button v-if="showBtn"
style="margin-left:10px"
type="primary"
icon="el-icon-upload2"
@click="handleManually">手动录入</el-button>
<!-- <el-button v-if="showBtn"
style="margin-left:10px"
type="primary"
icon="el-icon-delete"
@click="handleSetOffset">设置偏差</el-button> -->
<span v-if="showBtn&&hasPolygon"> 经度偏差</span>
<el-input v-if="showBtn&&hasPolygon"
resize="none"
size="mini"
style="width:100px"
placeholder='请输入经度偏差'
v-model="xOffset">
</el-input>
<span v-if="showBtn&&hasPolygon"> 纬度偏差</span>
<el-input v-if="showBtn&&hasPolygon"
resize="none"
size="mini"
style="width:100px"
placeholder='请输入维度偏差'
v-model="yOffset">
</el-input>
<el-button v-if="showBtn&&hasPolygon"
style="margin-left:10px"
type="primary"
size="mini"
icon="el-icon-folder-add"
@click="handleOffsetOk">保存</el-button>
<!-- <el-button v-if="showBtn"
style="margin-left:10px"
type="primary"
size="mini"
icon="el-icon-delete"
@click="handleOffsetCancel">预览</el-button> -->
</div>
</div>
<div class="div_back">
<el-button v-if="runNum>0"
style="margin-left:10px" style="margin-left:10px"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-back"
@click="handleEditPolygon">{{method==='mEditPolygon'?'取消绘制':'重新绘制'}}</el-button> @click="handleBack">返回上一级</el-button>
<!-- <el-button v-if="showBtn&&hasPolygon"
style="margin-left:10px"
type="primary"
icon="el-icon-delete"
@click="handleDelPolygon">删除区域</el-button> -->
</div> </div>
</div> <div class="div_tip">
<div class="div_back"> <span>按住alt键单击标注可以进入下一级地图</span>
<el-button v-if="runNum>0" </div>
style="margin-left:10px" <div id="map"
type="primary" class="div_map"
icon="el-icon-back" :style="{height:mapHeight+'px'}"></div>
@click="handleBack">返回上一级</el-button>
</div>
<div class="div_tip">
<span>按住alt键单击标注可以进入下一级地图</span>
</div>
<div id="map"
class="div_map"
:style="{height:mapHeight+'px'}"></div>
</div>
<el-dialog title="手动录入"
:visible.sync="dialogVisible"
width="50%"
:before-close="handleClose">
<div>
<el-input type="textarea"
:autosize="{ minRows: 4, maxRows: 7}"
:rows="5"
resize="none"
style="width:600px"
placeholder='请复制坐标数据'
v-model="polygonManullyString">
</el-input>
</div>
<span slot="footer"
class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary"
@click="handleManuallyOk"> </el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
@ -67,7 +130,7 @@ import { Loading } from 'element-ui'; //引入Loading服务
import { requestPost } from "@/js/dai/request"; import { requestPost } from "@/js/dai/request";
import { altKeyOnly, click, pointerMove } from 'ol/events/condition'; import { altKeyOnly, click, pointerMove } from 'ol/events/condition';
var centerPointGlobal = [120.38945519, 36.0722275] var centerPointGlobal = [120.664619, 36.504963]
let loading;// let loading;//
let x = 1500 let x = 1500
@ -85,15 +148,15 @@ let mapView;
let gaodeMapLayer;// let gaodeMapLayer;//
let parentLayer;// let parentLayer;//
let parentSource;// let parentSource;//
let polygonLayer;// let polygonLayer;//
let polygonSource;// let polygonSource;//
let draw;//handle let draw;//handle
let select;// let select;//
let selectAltClick; let selectAltClick;
let selectedFeatures; let selectedFeatures;
// //
var createTextStyle = function (feature) { var createTextStyle = function (feature) {
return new Text({ return new Text({
textAlign: undefined, textAlign: undefined,
@ -101,7 +164,7 @@ var createTextStyle = function (feature) {
//fontFamily: "Courier New, monospace", //fontFamily: "Courier New, monospace",
fontWeight: "bold", fontWeight: "bold",
text: feature.values_.name, text: feature.values_.name,
//text: "", //text: "",
fill: new Fill({ color: "#007ab9" }), fill: new Fill({ color: "#007ab9" }),
stroke: new Stroke({ color: "#ffffff", width: 3 }), stroke: new Stroke({ color: "#ffffff", width: 3 }),
offsetY: 0, offsetY: 0,
@ -172,6 +235,14 @@ const vueGis = {
zoom: null, zoom: null,
parentPolygon: [], parentPolygon: [],
//
dialogVisible: false,
showOffset: false,
polygonManullyString: "POLYGON (( 120.33902844 36.10290786, 120.33928218 36.10292997, 120.33956336 36.10316381, 120.34016675 36.10367715, 120.34044913 36.10391476, 120.34045707 36.10392145, 120.34068696 36.10411489, 120.34103181 36.10436285, 120.34117309 36.10441824, 120.34134613 36.10447927, 120.34164715 36.10465122, 120.34124679 36.10507284, 120.34088128 36.10538902, 120.34076198 36.10549222, 120.34053890 36.10520966, 120.34044967 36.10507284, 120.34030632 36.10494761, 120.34019091 36.10484679, 120.33976558 36.10448095, 120.33966658 36.10439980, 120.33947147 36.10425822, 120.33932037 36.10417613, 120.33913002 36.10411307, 120.33895751 36.10406073, 120.33879451 36.10403693, 120.33864104 36.10403158, 120.33864031 36.10395235, 120.33863211 36.10305897, 120.33902175 36.10290728, 120.33902844 36.10290786))",
polygonStringResult: '',
xOffset: 0,
yOffset: 0,
} }
}, },
async mounted () { async mounted () {
@ -292,7 +363,7 @@ const vueGis = {
// //
loadParentPolygon () { loadParentPolygon () {
parentSource.clear()// parentSource.clear()//
let featureData = []// let featureData = []//
if (this.parentPolygon && this.parentPolygon.length > 0) {// if (this.parentPolygon && this.parentPolygon.length > 0) {//
@ -348,7 +419,7 @@ const vueGis = {
}, },
// //
loadPolygon (subAgencyArray) { loadPolygon (subAgencyArray) {
polygonSource.clear()// polygonSource.clear()//
let featureData = []// let featureData = []//
if (subAgencyArray && subAgencyArray.length > 0) {// if (subAgencyArray && subAgencyArray.length > 0) {//
@ -548,7 +619,7 @@ const vueGis = {
}, },
// //
addParentLayer () { addParentLayer () {
parentSource = new VectorSource({ parentSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject) //features: (new GeoJSON()).readFeatures(geojsonObject)
@ -565,7 +636,7 @@ const vueGis = {
}, },
// //
addPolygonLayer () { addPolygonLayer () {
polygonSource = new VectorSource({ polygonSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject) //features: (new GeoJSON()).readFeatures(geojsonObject)
@ -628,6 +699,86 @@ const vueGis = {
}); });
}, },
//
handleManually () {
this.dialogVisible = true
},
//
handleClose () {
this.dialogVisible = false
},
handleManuallyOk () {
//
//120.54033616308595,36.53603370922851,120.69620469335939,36.5408402277832,120.63166001562502,36.46771248120117,120.52728989843752,36.458786089599606,120.54033616308595,36.53603370922851
//
// 73°33E135°05E
// 3°51N53°33N
const arrayString = this.polygonManullyString
let array = arrayString.split(/[, ]/)
console.log(array)
this.polygonStringResult = ''
array.forEach(element => {
let num = Number(element)
if (num) {
this.polygonStringResult = this.polygonStringResult + element + ','
}
});
this.polygonStringResult = this.polygonStringResult.substring(0, this.polygonStringResult.length - 1)
this.addPolygon(this.polygonStringResult)
},
handleSetOffset () {
this.showOffset = true
},
handleOffsetOk () {
let selPolygonString = ""
let offsetPolygonString = ''//
this.subAgencyArray.forEach(element => {
if (element.id === this.selAgencyId && element.coordinates && element.coordinates.length > 0) {
selPolygonString = element.coordinates
}
});
if (selPolygonString) {
let tempArray = selPolygonString.split(',')
tempArray.forEach((element, index) => {
let aaa = 0
debugger
if (index % 2 === 0) {//
aaa = parseFloat(element) + this.xOffset
} else {
aaa = parseFloat(element) + this.yOffset
}
if (index % 2 !== 0) {//
}
offsetPolygonString = offsetPolygonString + aaa + ','
});
offsetPolygonString = offsetPolygonString.substring(0, offsetPolygonString.length - 1)
}
console.log('selPolygonString', selPolygonString)
console.log('offsetPolygonString', offsetPolygonString)
this.addPolygon(offsetPolygonString)
},
handleSetOffset () {
this.handleOffsetCancel = false
},
// //
handleAddPolygon () { handleAddPolygon () {
@ -732,6 +883,7 @@ const vueGis = {
}) })
.then(() => { .then(() => {
this.addPolygon(coorString) this.addPolygon(coorString)
}) })
.catch(err => { .catch(err => {
this.loadPolygon(this.subAgencyArray) this.loadPolygon(this.subAgencyArray)
@ -751,6 +903,7 @@ const vueGis = {
// //
async addPolygon (coorString) { async addPolygon (coorString) {
console.log(coorString)
const url = "/gov/org/agency/mapaddarea" const url = "/gov/org/agency/mapaddarea"
let params = { let params = {
@ -766,7 +919,9 @@ const vueGis = {
type: "success", type: "success",
message: "绘制成功" message: "绘制成功"
}); });
if (this.dialogVisible) {
this.dialogVisible = false
}
this.refreshMap(false) this.refreshMap(false)
} else { } else {
this.$message({ this.$message({
@ -846,7 +1001,7 @@ const vueGis = {
}, },
mapHeight () { mapHeight () {
return this.clientHeight - 120; return this.clientHeight - 170;
}, },
// zoom: { // zoom: {
@ -872,16 +1027,12 @@ export default vueGis;
<style scoped> <style scoped>
.div_search { .div_search {
z-index: 10; z-index: 10;
position: absolute;
top: 20px;
left: 20px;
display: flex; display: flex;
} }
.div_back { .div_back {
z-index: 10; z-index: 10;
position: absolute;
top: 20px;
right: 20px;
display: flex; display: flex;
} }
.div_tip { .div_tip {
@ -894,6 +1045,7 @@ export default vueGis;
font-size: 15px; font-size: 15px;
} }
.div_map { .div_map {
margin-top: 15px;
width: 100%; width: 100%;
} }
</style> </style>

Loading…
Cancel
Save