Browse Source

管理图层调整1

V1.0
jiangyy 3 years ago
parent
commit
d9f4fc0f6a
  1. 57
      src/views/modules/communityService/sqzzz/cpts/edit.vue
  2. 5
      src/views/modules/shequzhili/csgltc/csgl.vue
  3. 137
      src/views/modules/shequzhili/csgltc/csglDetail.vue
  4. 238
      src/views/modules/shequzhili/csgltc/csglForm.vue
  5. 133
      src/views/modules/shequzhili/ggfwtc/ggfwDetail.vue
  6. 240
      src/views/modules/shequzhili/ggfwtc/ggfwForm.vue

57
src/views/modules/communityService/sqzzz/cpts/edit.vue

@ -133,16 +133,6 @@
label-width="150px" label-width="150px"
style="display: block"> style="display: block">
<div style="width: 500px"> <div style="width: 500px">
<!-- <el-input class="item_width_4"
maxlength="50"
placeholder="请输入关键字"
v-model="keyWords">
</el-input>
<el-button style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button> -->
<el-select v-model="searchValue" <el-select v-model="searchValue"
filterable filterable
style="width: 500px" style="width: 500px"
@ -160,21 +150,6 @@
</el-select> </el-select>
<div id="app" <div id="app"
class="div_map"></div> class="div_map"></div>
<!-- <div style="margin-top: 10px"
v-show="false">
<span>经度</span>
<el-input class="item_width_3"
maxlength="50"
placeholder="请输入经度"
v-model="dataForm.longitude">
</el-input>
<span style="margin-left: 20px">纬度</span>
<el-input class="item_width_3"
maxlength="50"
placeholder="请输入纬度"
v-model="dataForm.latitude">
</el-input>
</div> -->
</div> </div>
</el-form-item> </el-form-item>
@ -344,8 +319,8 @@ export default {
let lonlat = selPosition.lonlat.split(" ") let lonlat = selPosition.lonlat.split(" ")
map.setCenter(lonlat[1], lonlat[0]); map.setCenter(lonlat[1], lonlat[0]);
map.setMarker(lonlat[1], lonlat[0]); map.setMarker(lonlat[1], lonlat[0]);
this.dataForm.latitude = lonlat[0]; this.formData.latitude = lonlat[1];
this.dataForm.longitude = lonlat[1]; this.formData.longitude = lonlat[0];
this.dataForm.address = selPosition.address + selPosition.name this.dataForm.address = selPosition.address + selPosition.name
}, },
@ -455,19 +430,6 @@ export default {
}, },
// async handleSearchMap () {
// const { msg, data } = await map.searchNearby(this.keyWords);
// if (msg == "success") {
// const { lat, lng } = data;
// map.setCenter(lat, lng);
// map.setMarker(lat, lng);
// this.dataForm.latitude = lat;
// this.dataForm.longitude = lng;
// this.handleMoveCenter()
// } else {
// this.$message.error("");
// }
// },
async handleMoveCenter () { async handleMoveCenter () {
// //
@ -574,6 +536,21 @@ export default {
organizationPersonnel: [], organizationPersonnel: [],
}; };
}, },
// async handleSearchMap () {
// const { msg, data } = await map.searchNearby(this.keyWords);
// if (msg == "success") {
// const { lat, lng } = data;
// map.setCenter(lat, lng);
// map.setMarker(lat, lng);
// this.dataForm.latitude = lat;
// this.dataForm.longitude = lng;
// this.handleMoveCenter()
// } else {
// this.$message.error("");
// }
// },
// //
startLoading () { startLoading () {
loading = Loading.service({ loading = Loading.service({

5
src/views/modules/shequzhili/csgltc/csgl.vue

@ -52,7 +52,8 @@
style="margin-left:10px" style="margin-left:10px"
size="small" size="small"
@click="handleExportModule('room')">下载模板</el-button> @click="handleExportModule('room')">下载模板</el-button>
<el-upload :headers="$getElUploadHeaders()" ref="upload" <el-upload :headers="$getElUploadHeaders()"
ref="upload"
:multiple='false' :multiple='false'
:show-file-list='false' :show-file-list='false'
:before-upload="beforeUpload" :before-upload="beforeUpload"
@ -361,7 +362,7 @@ export default {
this.formShow = false this.formShow = false
}, },
diaDetailClose () { diaDetailClose () {
this.$refs.ref_detail.diaDestroy() // this.$refs.ref_detail.diaDestroy()
this.detailShow = false this.detailShow = false
}, },

137
src/views/modules/shequzhili/csgltc/csglDetail.vue

@ -33,7 +33,7 @@
</div> </div>
<div class="info-prop"> <div class="info-prop">
<span class="info-title-2">地理位置</span> <span class="info-title-2">所在位置</span>
<span>{{ formData.address }}</span> <span>{{ formData.address }}</span>
</div> </div>
@ -41,7 +41,7 @@
<span class="info-title-2">地图位置</span> <span class="info-title-2">地图位置</span>
<div class="div_map"> <div class="div_map">
<div id="app_detail"></div> <div id="app_csgl_detail"></div>
</div> </div>
</div> </div>
@ -61,6 +61,7 @@
<script> <script>
import { Loading } from 'element-ui' // Loading import { Loading } from 'element-ui' // Loading
import daiMap from "@/utils/dai-map";
var map var map
var search var search
@ -85,14 +86,14 @@ export default {
methods: { methods: {
handleCancle () { handleCancle () {
this.diaDestroy() // this.diaDestroy()
this.$emit('diaDetailClose') this.$emit('diaDetailClose')
}, },
diaDestroy () { diaDestroy () {
if (map) { if (map) {
map.destroy() // map.destroy()
} }
}, },
@ -100,17 +101,7 @@ export default {
this.startLoading() this.startLoading()
this.formData = { ...row } this.formData = { ...row }
this.initLoading = true this.initLoading = true
this.$nextTick(() => {
this.initMap()
})
this.endLoading()
},
// init
initMap () {
//
let { latitude, longitude } = this.$store.state.user; let { latitude, longitude } = this.$store.state.user;
console.log('lat' + latitude + ',lon' + longitude) console.log('lat' + latitude + ',lon' + longitude)
if (this.formData.latitude && this.formData.longitude) { if (this.formData.latitude && this.formData.longitude) {
@ -121,115 +112,37 @@ export default {
latitude = 39.9088810666821; latitude = 39.9088810666821;
longitude = 116.39743841556731; longitude = 116.39743841556731;
} }
// this.$nextTick(() => {
var center = new window.TMap.LatLng(latitude, longitude); this.initMap(latitude, longitude)
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app_detail'), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45 //
})
search = new window.TMap.service.Search({ pageSize: 10 })
//
markers = new TMap.MultiMarker({
map: map,
geometries: []
}) })
infoWindowList = Array(10) this.endLoading()
geocoder = new TMap.service.Geocoder(); //
//
map.on('panend', () => {
this.handleMoveCenter()
})
this.handleMoveCenter()
// this.convert()
}, },
setMarker (lat, lng) { // init
markers.setGeometries([]) initMap (latitude, longitude) {
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
}
])
},
handleSearchMap () { map = new daiMap(
infoWindowList.forEach((infoWindow) => { document.getElementById("app_csgl_detail"),
infoWindow.close() { latitude, longitude },
}) {
infoWindowList.length = 0 zoom: 16.2, //
markers.setGeometries([]) pitch: 43.5, //
// rotation: 45, //
search
.searchRectangle({
keyword: this.keyWords,
bounds: map.getBounds()
})
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
} }
}) );
},
handleMoveCenter () { // //
// // map.on("dragend", (e) => {
const center = map.getCenter() // this.handleMoveCenter(e);
const lat = center.getLat() // });
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
convert (lat, lng) { map.setCenter(latitude, longitude);
markers.setGeometries([]); map.setMarker(latitude, longitude);
// var input = document.getElementById('location').value.split(',');
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
// this.formData.address = result.result.address
//
});
}, },
// //
startLoading () { startLoading () {
loading = Loading.service({ loading = Loading.service({

238
src/views/modules/shequzhili/csgltc/csglForm.vue

@ -96,22 +96,41 @@
placeholder="请输入联系电话"></el-input> placeholder="请输入联系电话"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="地址" <el-form-item label="地图位置"
prop="longitude"
label-width="150px"
style="display: block">
<div style="width: 500px">
<el-select v-model="searchValue"
filterable
style="width: 500px"
remote
:reserve-keyword="true"
placeholder="请输入关键词"
:remote-method="remoteMethod"
:loading="loading">
<el-option v-for="(item,index) in searchOptions"
@click.native="handleClickKey(index)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<div id="app_csgl"
class="div_map"></div>
</div>
</el-form-item>
<el-form-item label="所在位置 "
prop="address" prop="address"
label-width="150px" label-width="150px"
style="display: block"> style="display: block">
<div class="item_width_1"> <el-input class="item_width_1"
<el-input style="width:420px" maxlength="50"
:placeholder="'请输入所在地址'" show-word-limit
placeholder="请输入位置 "
v-model="formData.address"> v-model="formData.address">
</el-input> </el-input>
<el-button style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button>
<div id="app"
class="div_map"></div>
</div>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -132,7 +151,7 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // Loading import { Loading } from 'element-ui' // Loading
import { requestPost } from '@/js/dai/request' import { requestPost } from '@/js/dai/request'
import daiMap from "@/utils/dai-map";
var map var map
@ -146,6 +165,10 @@ export default {
data () { data () {
return { return {
formType: 'add', // addeditdetail formType: 'add', // addeditdetail
searchOptions: [],
searchValue: '',
resultList: [],
loading: false,
btnDisable: false, btnDisable: false,
serviceList: [], serviceList: [],
@ -169,7 +192,7 @@ export default {
}, },
components: {}, components: {},
mounted () { mounted () {
this.initMap()
}, },
methods: { methods: {
@ -177,7 +200,7 @@ export default {
async initForm (type, icCityManagementId) { async initForm (type, icCityManagementId) {
this.startLoading() this.startLoading()
this.$refs.ref_form.resetFields(); this.$refs.ref_form.resetFields();
let { latitude, longitude } = this.$store.state.user;
// //
await this.loadService() await this.loadService()
@ -187,10 +210,12 @@ export default {
this.formData.icCityManagementId = icCityManagementId this.formData.icCityManagementId = icCityManagementId
await this.loadFormData() await this.loadFormData()
} else { } else {
// map.setCenter(new TMap.LatLng(36.0722275, 120.38945519)) this.formData.latitude = latitude
// this.setMarker(36.0722275, 120.38945519) this.formData.longitude = longitude
} }
// if (!map) {
this.initMap(this.formData.latitude, this.formData.longitude);
// }
this.endLoading() this.endLoading()
}, },
@ -231,10 +256,10 @@ export default {
// let { latitude, longitude } = this.$store.state.user; // let { latitude, longitude } = this.$store.state.user;
// const lat = this.formData.latitude === null || this.formData.latitude === '' ? latitude : this.formData.latitude; // const lat = this.formData.latitude === null || this.formData.latitude === '' ? latitude : this.formData.latitude;
// const lon = this.formData.longitude === null || this.formData.longitude === '' ? longitude : this.formData.longitude; // const lon = this.formData.longitude === null || this.formData.longitude === '' ? longitude : this.formData.longitude;
if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== '') { // if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== '') {
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude)) // map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude) // this.setMarker(this.formData.latitude, this.formData.longitude)
} // }
} else { } else {
this.$message.error(msg) this.$message.error(msg)
} }
@ -289,133 +314,90 @@ export default {
}, },
// init // init
initMap () { initMap (latitude, longitude) {
//
let { latitude, longitude } = this.$store.state.user;
console.log('lat' + latitude + ',lon' + longitude)
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;
}
this.formData.latitude = latitude map = new daiMap(
this.formData.longitude = longitude document.getElementById("app_csgl"),
// { latitude, longitude },
var center = new window.TMap.LatLng(latitude, longitude); {
// var center = new window.TMap.LatLng(36.52799, 120.7553)
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app'), {
center: center, //
zoom: 16.2, // zoom: 16.2, //
pitch: 43.5, // pitch: 43.5, //
rotation: 45 // rotation: 45, //
}) }
);
search = new window.TMap.service.Search({ pageSize: 10 }) //
// map.on("dragend", (e) => {
markers = new TMap.MultiMarker({ this.handleMoveCenter(e);
map: map, });
geometries: []
})
infoWindowList = Array(10)
geocoder = new TMap.service.Geocoder(); // map.setCenter(latitude, longitude);
map.setMarker(latitude, longitude);
//
map.on('panend', () => {
this.handleMoveCenter()
})
this.handleMoveCenter()
// this.convert()
}, },
setMarker (lat, lng) {
markers.setGeometries([])
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
}
])
},
handleSearchMap () { async handleMoveCenter () {
infoWindowList.forEach((infoWindow) => { //
infoWindow.close() const { lat, lng } = map.getCenter();
}) this.formData.latitude = lat;
infoWindowList.length = 0 this.formData.longitude = lng;
markers.setGeometries([]) map.setMarker(lat, lng);
//
search let { msg, data } = await map.getAddress(lat, lng);
.searchNearby({ if (msg == "success") {
keyword: this.formData.address, this.formData.address = data.address
radius: 1000, this.searchValue = data.address
autoExtend: true, this.searchOptions = []
center: map.getCenter(),
})
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
} }
})
}, },
async remoteMethod (query) {
handleMoveCenter () { if (query !== '') {
// this.loading = true;
const center = map.getCenter()
const lat = center.getLat()
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
convert (lat, lng) { const { msg, data } = await map.searchNearby(query);
markers.setGeometries([]); this.loading = false;
// var input = document.getElementById('location').value.split(','); this.resultList = []
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
// map.setCenter(location); if (msg == "success" && data.resultList && data.resultList.length > 0) {
markers.updateGeometries([
if (data.resultList && data.resultList.length > 0) {
this.resultList = data.resultList
this.searchOptions = this.resultList.map(item => {
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` };
});
}
} else {
this.searchOptions = [
{ {
id: 'main', // value: '0',
position: location, label: '未检索到结果'
}
]
}
} else {
this.searchOptions = [];
}
}, },
]);
geocoder handleClickKey (index) {
.getAddress({ location: location }) // let selPosition = this.resultList[index]
.then((result) => { let lonlat = selPosition.lonlat.split(" ")
// this.formData.address = result.result.address === '' || result.result.address === null ? this.formData.address : result.result.address map.setCenter(lonlat[1], lonlat[0]);
this.formData.address = this.formData.address !== '' && this.formData.address !== null && (this.formData.longitude === '' || this.formData.longitude === null) ? this.formData.address : result.result.address map.setMarker(lonlat[1], lonlat[0]);
// this.formData.latitude = lonlat[1];
}); this.formData.longitude = lonlat[0];
this.formData.address = selPosition.address + selPosition.name
}, },
resetData () { resetData () {
this.searchValue = ''
this.searchOptions = []
this.resultList = []
this.unitId = '' this.unitId = ''
this.keyWords = '' this.keyWords = ''
this.formData = { this.formData = {

133
src/views/modules/shequzhili/ggfwtc/ggfwDetail.vue

@ -42,7 +42,7 @@
<span class="info-title-2">地图位置</span> <span class="info-title-2">地图位置</span>
<div class="div_map"> <div class="div_map">
<div id="app_detail"></div> <div id="app_ggfw_detail"></div>
</div> </div>
</div> </div>
@ -62,6 +62,7 @@
<script> <script>
import { Loading } from 'element-ui' // Loading import { Loading } from 'element-ui' // Loading
import daiMap from "@/utils/dai-map";
var map var map
var search var search
@ -86,14 +87,14 @@ export default {
methods: { methods: {
handleCancle () { handleCancle () {
this.diaDestroy() // this.diaDestroy()
this.$emit('diaDetailClose') this.$emit('diaDetailClose')
}, },
diaDestroy () { diaDestroy () {
if (map) { if (map) {
map.destroy() // map.destroy()
} }
}, },
@ -101,15 +102,7 @@ export default {
this.startLoading() this.startLoading()
this.formData = { ...row } this.formData = { ...row }
this.initLoading = true this.initLoading = true
this.$nextTick(() => {
this.initMap()
})
this.endLoading()
},
// init
initMap () {
let { latitude, longitude } = this.$store.state.user; let { latitude, longitude } = this.$store.state.user;
console.log('lat' + latitude + ',lon' + longitude) console.log('lat' + latitude + ',lon' + longitude)
if (this.formData.latitude && this.formData.longitude) { if (this.formData.latitude && this.formData.longitude) {
@ -120,116 +113,38 @@ export default {
latitude = 39.9088810666821; latitude = 39.9088810666821;
longitude = 116.39743841556731; longitude = 116.39743841556731;
} }
//
var center = new window.TMap.LatLng(latitude, longitude);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app_detail'), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45 //
})
search = new window.TMap.service.Search({ pageSize: 10 }) this.$nextTick(() => {
// this.initMap(latitude, longitude)
markers = new TMap.MultiMarker({
map: map,
geometries: []
}) })
infoWindowList = Array(10) this.endLoading()
geocoder = new TMap.service.Geocoder(); //
//
map.on('panend', () => {
this.handleMoveCenter()
})
this.handleMoveCenter()
console.log('initMap')
// this.convert()
}, },
setMarker (lat, lng) { // init
markers.setGeometries([]) initMap (latitude, longitude) {
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
}
])
},
handleSearchMap () { map = new daiMap(
infoWindowList.forEach((infoWindow) => { document.getElementById("app_ggfw_detail"),
infoWindow.close() { latitude, longitude },
}) {
infoWindowList.length = 0 zoom: 16.2, //
markers.setGeometries([]) pitch: 43.5, //
// rotation: 45, //
search
.searchRectangle({
keyword: this.keyWords,
bounds: map.getBounds()
})
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
} }
}) );
},
handleMoveCenter () { // //
// // map.on("dragend", (e) => {
const center = map.getCenter() // this.handleMoveCenter(e);
const lat = center.getLat() // });
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
convert (lat, lng) { map.setCenter(latitude, longitude);
markers.setGeometries([]); map.setMarker(latitude, longitude);
// var input = document.getElementById('location').value.split(',');
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
// this.formData.address = result.result.address
//
});
}, },
// //
startLoading () { startLoading () {
loading = Loading.service({ loading = Loading.service({

240
src/views/modules/shequzhili/ggfwtc/ggfwForm.vue

@ -77,22 +77,41 @@
class="item_width_1" class="item_width_1"
placeholder="请输入联系电话"></el-input> placeholder="请输入联系电话"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="地址" <el-form-item label="地图位置"
prop="longitude"
label-width="150px"
style="display: block">
<div style="width: 500px">
<el-select v-model="searchValue"
filterable
style="width: 500px"
remote
:reserve-keyword="true"
placeholder="请输入关键词"
:remote-method="remoteMethod"
:loading="loading">
<el-option v-for="(item,index) in searchOptions"
@click.native="handleClickKey(index)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<div id="app_ggfw"
class="div_map"></div>
</div>
</el-form-item>
<el-form-item label="所在位置 "
prop="address" prop="address"
label-width="150px" label-width="150px"
style="display: block"> style="display: block">
<div class="item_width_1"> <el-input class="item_width_1"
<el-input style="width:420px" maxlength="50"
:placeholder="'请输入所在地址'" show-word-limit
placeholder="请输入位置 "
v-model="formData.address"> v-model="formData.address">
</el-input> </el-input>
<el-button style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button>
<div id="app"
class="div_map"></div>
</div>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -113,7 +132,7 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // Loading import { Loading } from 'element-ui' // Loading
import { requestPost } from '@/js/dai/request' import { requestPost } from '@/js/dai/request'
import daiMap from "@/utils/dai-map";
var map var map
@ -127,11 +146,15 @@ export default {
data () { data () {
return { return {
formType: 'add', // addeditdetail formType: 'add', // addeditdetail
searchOptions: [],
searchValue: '',
resultList: [],
loading: false,
btnDisable: false, btnDisable: false,
icPublicServiceId: '', icPublicServiceId: '',
keyWords: '',
formData: { formData: {
name: '',// name: '',//
category: '', category: '',
@ -149,7 +172,7 @@ export default {
}, },
components: {}, components: {},
mounted () { mounted () {
this.initMap()
}, },
methods: { methods: {
@ -157,7 +180,7 @@ export default {
async initForm (type, icPublicServiceId) { async initForm (type, icPublicServiceId) {
this.startLoading() this.startLoading()
this.$refs.ref_form.resetFields(); this.$refs.ref_form.resetFields();
let { latitude, longitude } = this.$store.state.user;
// //
await this.loadService() await this.loadService()
@ -167,10 +190,13 @@ export default {
this.formData.icPublicServiceId = icPublicServiceId this.formData.icPublicServiceId = icPublicServiceId
await this.loadFormData() await this.loadFormData()
} else { } else {
// map.setCenter(new TMap.LatLng(36.0722275, 120.38945519)) this.formData.latitude = latitude
// this.setMarker(36.0722275, 120.38945519) this.formData.longitude = longitude
} }
// if (!map) {
this.initMap(this.formData.latitude, this.formData.longitude);
// }
this.endLoading() this.endLoading()
}, },
@ -211,10 +237,10 @@ export default {
// let { latitude, longitude } = this.$store.state.user; // let { latitude, longitude } = this.$store.state.user;
// const lat = this.formData.latitude === null || this.formData.latitude === '' ? '' : this.formData.latitude; // const lat = this.formData.latitude === null || this.formData.latitude === '' ? '' : this.formData.latitude;
// const lon = this.formData.longitude === null || this.formData.longitude === '' ? '' : this.formData.longitude; // const lon = this.formData.longitude === null || this.formData.longitude === '' ? '' : this.formData.longitude;
if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== '') { // if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== '') {
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude)) // map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude) // this.setMarker(this.formData.latitude, this.formData.longitude)
} // }
} else { } else {
this.$message.error(msg) this.$message.error(msg)
} }
@ -270,130 +296,90 @@ export default {
}, },
// init // init
initMap () { initMap (latitude, longitude) {
let { latitude, longitude } = this.$store.state.user;
console.log('lat' + latitude + ',lon' + longitude) map = new daiMap(
if (!latitude || latitude == "" || latitude == "0") { document.getElementById("app_ggfw"),
latitude = 39.9088810666821; { latitude, longitude },
longitude = 116.39743841556731; {
}
this.formData.latitude = latitude
this.formData.longitude = longitude
//
var center = new window.TMap.LatLng(latitude, longitude);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app'), {
center: center, //
zoom: 16.2, // zoom: 16.2, //
pitch: 43.5, // pitch: 43.5, //
rotation: 45 // rotation: 45, //
}) }
);
search = new window.TMap.service.Search({ pageSize: 10 }) //
// map.on("dragend", (e) => {
markers = new TMap.MultiMarker({ this.handleMoveCenter(e);
map: map, });
geometries: []
})
infoWindowList = Array(10)
geocoder = new TMap.service.Geocoder(); // map.setCenter(latitude, longitude);
map.setMarker(latitude, longitude);
//
map.on('panend', () => {
this.handleMoveCenter()
})
this.handleMoveCenter()
// this.convert()
}, },
setMarker (lat, lng) {
markers.setGeometries([])
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
}
])
},
handleSearchMap () { async handleMoveCenter () {
infoWindowList.forEach((infoWindow) => { //
infoWindow.close() const { lat, lng } = map.getCenter();
}) this.formData.latitude = lat;
infoWindowList.length = 0 this.formData.longitude = lng;
markers.setGeometries([]) map.setMarker(lat, lng);
//
search let { msg, data } = await map.getAddress(lat, lng);
.searchNearby({ if (msg == "success") {
keyword: this.formData.address, this.formData.address = data.address
radius: 1000, this.searchValue = data.address
autoExtend: true, this.searchOptions = []
center: map.getCenter(),
})
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
} }
})
}, },
handleMoveCenter () { async remoteMethod (query) {
//
const center = map.getCenter()
const lat = center.getLat()
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
convert (lat, lng) { if (query !== '') {
markers.setGeometries([]); this.loading = true;
// var input = document.getElementById('location').value.split(',');
let location const { msg, data } = await map.searchNearby(query);
if (lat && lng) { this.loading = false;
location = new TMap.LatLng(lat, lng); this.resultList = []
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude); if (msg == "success" && data.resultList && data.resultList.length > 0) {
}
if (data.resultList && data.resultList.length > 0) {
this.resultList = data.resultList
this.searchOptions = this.resultList.map(item => {
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` };
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
console.log(this.formData)
// this.formData.address = result.result.address === '' || result.result.address === null ? this.formData.address : result.result.address
this.formData.address = this.formData.address !== '' && this.formData.address !== null && (this.formData.longitude === '' || this.formData.longitude === null) ? this.formData.address : result.result.address
//
}); });
}
} else {
this.searchOptions = [
{
value: '0',
label: '未检索到结果'
}
]
}
} else {
this.searchOptions = [];
}
}, },
handleClickKey (index) {
let selPosition = this.resultList[index]
let lonlat = selPosition.lonlat.split(" ")
map.setCenter(lonlat[1], lonlat[0]);
map.setMarker(lonlat[1], lonlat[0]);
this.formData.latitude = lonlat[1];
this.formData.longitude = lonlat[0];
this.formData.address = selPosition.address + selPosition.name
},
resetData () { resetData () {
this.searchValue = ''
this.searchOptions = []
this.resultList = []
this.icPublicServiceId = '' this.icPublicServiceId = ''
this.keyWords = '' this.keyWords = ''
this.formData = { this.formData = {

Loading…
Cancel
Save