# up item
This commit is contained in:
parent
f452de76cd
commit
5d68f72890
|
@ -6,6 +6,7 @@
|
|||
|
||||
<script>
|
||||
import AMap from 'AMap'
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
name: 'map2',
|
||||
data() {
|
||||
|
@ -87,7 +88,7 @@ export default {
|
|||
title: item.title,
|
||||
map: this.map
|
||||
})
|
||||
const infoWindow = this.instantiateInforWindow(item.title)
|
||||
const infoWindow = this.instantiateInforWindow(item)
|
||||
AMap.event.addListener(marker, 'click', () => {
|
||||
infoWindow.open(this.map, marker.getPosition())
|
||||
})
|
||||
|
@ -134,19 +135,20 @@ export default {
|
|||
sharp.src = 'https://webapi.amap.com/images/sharp.png'
|
||||
bottom.appendChild(sharp)
|
||||
info.appendChild(bottom)
|
||||
console.log(info)
|
||||
// console.log(info)
|
||||
return info
|
||||
},
|
||||
instantiateInforWindow(title) {
|
||||
instantiateInforWindow(item) {
|
||||
const content = []
|
||||
content.push('<div class="count">339</div>')
|
||||
content.push('<div class="time">时间:2018年5月15日 14:33:25</div>')
|
||||
content.push('<div><span>信号:23</span><span class="energy">电量:4233</span></div>')
|
||||
const curTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
||||
content.push('<div class="count">' + item.count + '</div>')
|
||||
content.push('<div class="time">时间:' + curTime + '</div>')
|
||||
content.push('<div><span>信号:' + item.signal + '</span><span class="energy">电量:' + item.energy + '</span></div>')
|
||||
content.push('<div>区域:尖沙咀</div>\n')
|
||||
const infoWindow = new AMap.InfoWindow({
|
||||
isCustom: true,
|
||||
closeWhenClickMap: true,
|
||||
content: this.createInfoWindow(title, content.join('\n')),
|
||||
content: this.createInfoWindow(item.title, content.join('\n')),
|
||||
offset: new AMap.Pixel(16, -45)
|
||||
})
|
||||
return infoWindow
|
||||
|
@ -209,7 +211,7 @@ export default {
|
|||
margin: 0 0 .4rem 0;
|
||||
}
|
||||
.info-middle span.energy {
|
||||
margin-left: 2rem;
|
||||
margin-left: 1.8rem;
|
||||
}
|
||||
div.info-bottom {
|
||||
height: 0px;
|
||||
|
|
Loading…
Reference in New Issue