From 3fbc0b95c355edbef896da46f7945846ba1f32bc Mon Sep 17 00:00:00 2001 From: xianfuxing Date: Sat, 1 Sep 2018 11:41:23 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E4=BC=98=E5=8C=96=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=AA=97=E4=BD=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/counter/map2.vue | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/views/counter/map2.vue b/src/views/counter/map2.vue index 4f29f99..6a90f3a 100644 --- a/src/views/counter/map2.vue +++ b/src/views/counter/map2.vue @@ -66,6 +66,7 @@ export default { title: item.title, map: this.map }) + const infoWindow = this.instantiateInforWindow(item.title) AMap.event.addListener(marker, 'click', () => { infoWindow.open(this.map, marker.getPosition()) }) @@ -75,17 +76,6 @@ export default { this.map.addControl(new AMap.ToolBar()) this.map.addControl(new AMap.Scale()) }) - // 实例化信息窗体 - const title = '方恒假日酒店价格:318' - const content = [] - content.push("地址:北京市朝阳区阜通东大街6号院3号楼东北8.3公里") - content.push('电话:010-64733333') - content.push("详细信息") - const infoWindow = new AMap.InfoWindow({ - isCustom: true, - content: this.createInfoWindow(title, content.join('
')), - offset: new AMap.Pixel(16, -45) - }) }, createInfoWindow(title, content) { const info = document.createElement('div') @@ -125,6 +115,19 @@ export default { info.appendChild(bottom) return info }, + instantiateInforWindow(title) { + const content = [] + content.push("地址:北京市朝阳区阜通东大街6号院3号楼东北8.3公里") + content.push('电话:010-64733333') + content.push("详细信息") + const infoWindow = new AMap.InfoWindow({ + isCustom: true, + closeWhenClickMap: true, + content: this.createInfoWindow(title, content.join('
')), + offset: new AMap.Pixel(16, -45) + }) + return infoWindow + }, closeInfoWindow() { this.map.clearInfoWindow() }