This commit is contained in:
glj 2023-05-08 09:12:06 +08:00
commit d5181a32e4
2 changed files with 92 additions and 20 deletions

View File

@ -59,8 +59,8 @@ onMounted(() => {
const mapOperations = { const mapOperations = {
wktParseToMap: (res) => { wktParseToMap: (res) => {
let layer = omnivore.wkt.parse(res) let layer = omnivore.wkt.parse(res)
if(featureLayerG_area.getLayers().length != 0||featureLayerG_point.getLayers().length != 0){ if (featureLayerG_area.getLayers().length != 0 || featureLayerG_point.getLayers().length != 0) {
return; return;
} }
layer.addTo(featureLayerG_point) layer.addTo(featureLayerG_point)
@ -70,12 +70,12 @@ const mapOperations = {
// flyTo // flyTo
if (attr[0].feature.geometry.type.indexOf('Polygon') == -1) { if (attr[0].feature.geometry.type.indexOf('Polygon') == -1) {
homeMap.flyTo([attr[0].feature.geometry.coordinates[1], attr[0].feature.geometry.coordinates[0]], 3) homeMap.flyTo([attr[0].feature.geometry.coordinates[1], attr[0].feature.geometry.coordinates[0]], 3)
variableStore.layerGroupPoint=res; variableStore.layerGroupPoint = res;
return {'layer':layer,'location':[attr[0].feature.geometry.coordinates[1],attr[0].feature.geometry.coordinates[0]]} return { 'layer': layer, 'location': [attr[0].feature.geometry.coordinates[1], attr[0].feature.geometry.coordinates[0]] }
} }
// fly // fly
else { else {
variableStore.layerGroupPoly=res; variableStore.layerGroupPoly = res;
let polygons = []; let polygons = [];
for (let i = 0; i < attr[0].feature.geometry.coordinates.length; i++) { for (let i = 0; i < attr[0].feature.geometry.coordinates.length; i++) {
console.log(attr[0].feature.geometry.coordinates[i]) console.log(attr[0].feature.geometry.coordinates[i])
@ -90,7 +90,7 @@ const mapOperations = {
let final_center = turf.center(turf.featureCollection(features)) let final_center = turf.center(turf.featureCollection(features))
// console.log(final_center) // console.log(final_center)
homeMap.flyTo([final_center.geometry.coordinates[1], final_center.geometry.coordinates[0]], 3) homeMap.flyTo([final_center.geometry.coordinates[1], final_center.geometry.coordinates[0]], 3)
return {'layer':layer,'location':null} return { 'layer': layer, 'location': null }
} }
// return layer // return layer
@ -406,6 +406,9 @@ const mapOperations = {
}, },
deleteRectangle: () => { deleteRectangle: () => {
homeMap.removeLayer(layerRectangle) homeMap.removeLayer(layerRectangle)
},
removeEdit: () => {
homeMap.pm.toggleGlobalRemovalMode();
} }
} }
//omnivore.wkt.parse('POINT(-80 0)').addTo(homeMap); //omnivore.wkt.parse('POINT(-80 0)').addTo(homeMap);

View File

@ -310,17 +310,28 @@
</el-container> </el-container>
<el-container style="margin-top: 2%;margin-bottom: 2%;" <el-container style="margin-top: 2%;margin-bottom: 2%;"
v-if="state.radio === '3' ? true : false"> v-if="state.radio === '3' ? true : false">
<span style="line-height: 35px;"> Latitude</span> <el-row>
<el-input placeholder="wait……" <el-col :span="3">
style="height:35px;margin-right: 1%;" <span style="line-height: 35px;"> Latitude</span>
v-model="state.dislat" </el-col>
:onchange="manualCoordinate"> <el-col :span="7">
</el-input> <el-input placeholder="wait……"
<span style="line-height: 35px;">Longitude</span> style="height:35px;margin-right: 1%;"
<el-input placeholder="wait……" v-model="state.dislat"
style="height:35px;" :onchange="manualLat">
v-model="state.dislon" </el-input>
:onchange="manualCoordinate"></el-input> </el-col>
<el-col :span="2"></el-col>
<el-col :span="3">
<span style="line-height: 35px;">Longitude</span>
</el-col>
<el-col :span="7">
<el-input placeholder="wait……"
style="height:35px;"
v-model="state.dislon"
:onchange="manualLon"></el-input>
</el-col>
</el-row>
</el-container> </el-container>
<MapPage style="height:350px ; width:100% ;margin-bottom: 10px;" <MapPage style="height:350px ; width:100% ;margin-bottom: 10px;"
ref="mapRef"> ref="mapRef">
@ -371,7 +382,7 @@
<script setup name="userResponse"> <script setup name="userResponse">
import en from 'element-plus/dist/locale/en.mjs' import en from 'element-plus/dist/locale/en.mjs'
import { reactive, onMounted, ref, nextTick, watchEffect, defineAsyncComponent } from 'vue'; import { reactive, onMounted, ref, nextTick, watchEffect, defineAsyncComponent, h } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus'; import { ElMessageBox, ElMessage } from 'element-plus';
import { getList, review, responseEndedDisasterInfo } from '/@/api/disasterInfo/index'; import { getList, review, responseEndedDisasterInfo } from '/@/api/disasterInfo/index';
import { getDictionary, getList as getListNew } from '/@/api/system/dictbiz'; import { getDictionary, getList as getListNew } from '/@/api/system/dictbiz';
@ -452,7 +463,9 @@ const state = reactive({
dislon: '', dislon: '',
popupLat: null, popupLat: null,
popupLon: null, popupLon: null,
wktPoint_Poly: undefined wktPoint_Poly: undefined,
passLat: false,
passLon: false,
}); });
// //
const getTableData = () => { const getTableData = () => {
@ -508,6 +521,61 @@ const onOpenEditRole = (type, row) => {
} }
}; };
//
const manualLat = () => {
const latReg = /^(\-|\+)?([0-8]?\d{1}\.\d{0,6}|90\.0{0,6}|[0-8]?\d{1}|90)$/;
if (!latReg.test(state.dislat)) {
state.passLat = false
ElMessage({
message: h('p', null, [
h('span', null, 'Please enter the correct '),
h('span', { style: 'font-size: 15px;font-weight: bold;' }, 'latitude'),
]),
})
}
else {
state.passLat = true
}
if (state.passLat && state.passLon) {
mapRef.value.mapOperations.addInteractMarker(state.dislat, state.dislon)
const positionParam = {
x: state.dislon,
y: state.dislat,
zoom: 3
}
mapRef.value.mapOperations.goPosition(positionParam)
}
}
//
const manualLon = () => {
const lonReg = /^(\-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,6})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,6}|180)$/;
if (!lonReg.test(state.dislon)) {
state.passLon = false
ElMessage({
message: h('p', null, [
h('span', null, 'Please enter the correct '),
h('span', { style: 'font-size: 15px;font-weight: bold;' }, 'longitude'),
]),
})
}
else {
state.passLon = true
}
if (state.passLat && state.passLon) {
mapRef.value.mapOperations.addInteractMarker(state.dislat, state.dislon)
const positionParam = {
x: state.dislon,
y: state.dislat,
zoom: 3
}
mapRef.value.mapOperations.goPosition(positionParam)
}
}
const manualCoordinate = () => { const manualCoordinate = () => {
// const disLatLen = state.dislat.length // const disLatLen = state.dislat.length
// const disLonLen = state.dislon.length // const disLonLen = state.dislon.length
@ -531,11 +599,13 @@ const mapEvents = (ev) => {
mapRef.value.mapOperations.off("click", mapClick); mapRef.value.mapOperations.off("click", mapClick);
mapRef.value.mapOperations.off("mousemove", showLatLon) mapRef.value.mapOperations.off("mousemove", showLatLon)
mapRef.value.mapOperations.clearPolygon() mapRef.value.mapOperations.clearPolygon()
mapRef.value.mapOperations.removeEdit()
ev == '' ev == ''
} }
else if (ev == '2') { else if (ev == '2') {
mapRef.value.mapOperations.off("click", mapClick); mapRef.value.mapOperations.off("click", mapClick);
mapRef.value.mapOperations.off("mousemove", showLatLon) mapRef.value.mapOperations.off("mousemove", showLatLon)
mapRef.value.mapOperations.removeEdit()
// mapRef.value.mapOperations.drawPolygon() // mapRef.value.mapOperations.drawPolygon()
// mapRef.value.mapOperations.drawCreated() // mapRef.value.mapOperations.drawCreated()
ev == '' ev == ''
@ -545,7 +615,6 @@ const mapEvents = (ev) => {
mapRef.value.mapOperations.on("mousemove", showLatLon) mapRef.value.mapOperations.on("mousemove", showLatLon)
mapRef.value.mapOperations.Edit() mapRef.value.mapOperations.Edit()
ev == '' ev == ''
} }
}; };
const ClearSubmit = () => { const ClearSubmit = () => {