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