Skip to content

YY. Popup

消息弹出框,用来消息提示,和操作交互,一般和覆盖物或者地图对象联合使用

creation

  • constructor(content, [options])
    • content {String} 文本内容
    • options {Object} 配置, 一般情况下无需配置
      • width {Number} 宽度
      • minHeight {Number} 最小高度
      • single {Boolean} 是否单例,默认 false

example

消息弹出框

js
   var point = new YY.Point(lnglat);

   point.bindPopup('hello world'); //点绑定弹出框,当点击点是会弹开

   //或者
   var popup = new YY.Popup('hello world', {
       single: true
   });
   popup.addTo(map); //将消息框添加到地图上并显示,点击地图时会弹开

   //或者
   var popup = new YY.Popup('hello world');
   if (condition) { //特定条件下动态的添加到地图上,并打开
       popup.addTo(map);

       popup.open(lnglat);
   }

警告

如果你的气泡内容是动态(需要查询后台数据),你应该异步显示并动态设置气泡内容 异步设置气泡弹框内容

method

open([lnglat])

  • 打开气泡
  • 参数
    • {YY.LngLat} lnglat: 显示,或者特定位置显示
  • 返回值: this

getContent()

  • 获取文本内容
  • 返回值: String

setContent(content)

  • 设置文本内容
  • 参数
    • {String} content:
  • 返回值: this

getTitle()

  • 获取标题文本
  • 返回值: String

setTitle(title)

  • 设置标题文本
  • 参数
    • {String} title:
  • 返回值: this

close()

  • 关闭气泡
  • 返回值: this

remove()

  • 移除气泡
  • 返回值: this

This document is generated by vitepress and Edit by deyihu