高德地图信息窗体设置

  1. 添加默认信息窗体

    //构建信息窗体中显示的内容
    var info = [];
    info.push(
    <div style="height: 36px; line-height: 45px; padding: 0px 20px; white-space:nowrap;">位置:北京</div>
    );
    info.push(
    <div style="height: 36px; line-height: 20px; padding: 0px 20px; white-space:nowrap;"> 联系人:袁磊 </div>
    );
    this.infoWindow = new AMap.InfoWindow({
    content: info.join("") //使用默认信息窗体框样式,显示信息内容
    });
    // // getCenter() 获取地图中心点(数组)
    // this.infoWindow.open(this.aMap, this.aMap.getCenter());
    // 设置点坐标为窗体坐标;例:[123.40340954550922, 41.7334550336356]
    this.infoWindow.open(this.aMap, e.data.lnglat);

  2. 使用自定义窗体(添加窗体)

    //构建信息窗体中显示的内容
    var info = [];
    info.push(
    <div style="height: 36px; line-height: 45px; padding: 0px 20px; white-space:nowrap;">位置:北京</div>
    );
    info.push(
    <div style="height: 36px; line-height: 20px; padding: 0px 20px; white-space:nowrap;"> 联系人:袁磊 </div>
    );
    that.infoWindow = new AMap.InfoWindow({
    isCustom: true, //使用自定义窗体
    content: <div style="background: #f00;">jdfghjdfihg</div> <div class="close-btn" style="float: right;margin-top: 3px; margin-right: 5px;" onclick="closeInfoWindow()">X</div> ,
    offset: new AMap.Pixel(16, -45)
    });
    // // getCenter() 获取地图中心点(数组)
    // this.infoWindow.open(this.aMap, this.aMap.getCenter());
    // 设置点坐标为窗体坐标;例:[123.40340954550922, 41.7334550336356]
    that.infoWindow.open(that.aMap, e.data.lnglat);

3关闭自定义窗体(closeInfoWindow方法也要挂在window)

复制代码
mounted() {
    window.closeInfoWindow = () => {
      this.aMap.clearInfoWindow();
    };
  },
相关推荐
Android系统攻城狮10 分钟前
Linux FFmpeg深度解析之avcodec_alloc_context3调用流程与实战(十四)
linux·运维·ffmpeg·车载音视频·音视频进阶·ffmpeg音视频进阶
LV技术派10 分钟前
【成为 AI Native Builder · 02】什么是 AI Native Builder:一个人 + AI,交付完整闭环
前端·程序员·ai编程
老李IT笔记11 分钟前
抹除之后机器上的受管应用可以留下:这一步省掉的是哪段时间
运维·服务器
#麻辣小龙虾#30 分钟前
网页布局css中flex+margin的组合布局技巧
开发语言·前端·javascript
自由彩虹32 分钟前
靶场通关15--bossplayersctf
linux·服务器·网络·安全·web安全·网络安全
叼烟扛炮34 分钟前
Linux 学习笔记(四十五):Web 安全基石——Cookie、Session 与 HTTPS 原理解析
linux·前端·网络·笔记·学习·tcp/ip·安全
2401_8685347836 分钟前
网络规划设计师之案例分析 - 网络安全与等级保护
服务器·网络
环境栈笔记41 分钟前
指纹浏览器安卓怎么用?从运行位置到功能验收,先把三种方案分清
前端·人工智能·后端·自动化
雾时之林41 分钟前
Nginx反向代理与proxy_cache缓存搭建CDN服务器
服务器·nginx·缓存
计算机魔术师1 小时前
Anthropic IPO 招股文件披露近 9000 亿美元隐性债务
前端