# 初始化地图跳转
This commit is contained in:
parent
5d68f72890
commit
720b6a3b63
|
@ -1,12 +1,13 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<div id="map-container" tabindex="0"></div>
|
||||
<div v-if="flag" id="map-container" tabindex="0"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AMap from 'AMap'
|
||||
import moment from 'moment'
|
||||
import { fetchDeviceList } from '@/api/counter'
|
||||
export default {
|
||||
name: 'map2',
|
||||
data() {
|
||||
|
@ -73,12 +74,6 @@ export default {
|
|||
resizeEnable: true,
|
||||
zoom: 10
|
||||
})
|
||||
// 窗体信息
|
||||
// const infoWindow = new AMap.InfoWindow({
|
||||
// isCustom: true,
|
||||
// content: this.createInfoWindow(title, content.join("<br/>")),
|
||||
// offset: new AMap.Pixel(16, -45)
|
||||
// })
|
||||
// 标记点测试数据
|
||||
const markers = []
|
||||
this.defaultPositions.forEach((item, index) => {
|
||||
|
@ -155,10 +150,31 @@ export default {
|
|||
},
|
||||
closeInfoWindow() {
|
||||
this.map.clearInfoWindow()
|
||||
},
|
||||
getDevicesInitMap(params) {
|
||||
fetchDeviceList(params).then(response => {
|
||||
this.deviceList = response.data.results
|
||||
this.coordinate = this.deviceList[0].coordinate
|
||||
if (this.coordinate === null) {
|
||||
this.coordinate = [113.203460828994, 22.64902452257]
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.mapClick = this.$store.getters.mapClick
|
||||
if (!this.mapClick) {
|
||||
this.flag = true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initMap()
|
||||
const device_id = this.$store.getters.deviceID
|
||||
if (this.mapClick) {
|
||||
this.getDevicesInitMap({ device_id })
|
||||
this.flag = true
|
||||
} else {
|
||||
this.initMap()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue