InfoWindow(object, param) → {InfoWindow}

new InfoWindow(object, param) → {InfoWindow}

构造函数

Parameters:
Name Type Description
object Object 需要标注的地理对象
param Object 参数列表
Properties
Name Type Attributes Default Description
relativePositionToDefault Array.<Number> <optional>
[0,0,0] 基于父物体默认label位置的偏移(例如GeoBuilding默认的label位置是建筑顶面中心点) 单位米 [x,y,z]分别代表三个轴偏移量 上下为y轴 左右为x轴 前后为z轴
visible Boolean <optional>
true 是否显示
text String 标注内容
pivot Array.<Number> <optional>
[0.5,0] 轴心点
type String <optional>
Standard 信息框的类型,支持InfoWindowType.Standard(标准)和InfoWindowType.Custom(自定义)两种类型, type为InfoWindowType.Standard 会读取fieldData中的信息设置弹窗内容 type为InfoWindowType.Custom 会根据customHtml设置弹窗内容
customHtml String <optional>
自定义信息框的html文本,仅在type为custom时生效
displayMode String <optional>
DisplayMode.Always 信息框显示方式,包括DisplayMode.MouseEnter(悬浮显示)、DisplayMode.Click(点击显示)、DisplayMode.Always(一直显示) DisplayMode.None(不显示)四种类型
title String <optional>
详细信息 信息框的标题
style String <optional>
Default 信息框的样式,包括InfoWindowStyle.Default、InfoWindowStyle.Blue和InfoWindowStyle.White三种类型
localPosition Array.<Number> <optional>
[0,0,0] 信息框的偏移量 [x,y,z]分别代表三个轴偏移量 上下为y轴 左右为x轴 前后为z轴
pivot Array.<Number> <optional>
[0.5,0] 信息框的轴心,以百分比表示界面轴心位置 [0,0] 代表界面左上;[1,1] 代表界面右下 默认[0.5,0] 数组每个值可以大于1用于控制像素级别的offset
fieldData Array <optional>
信息框中显示的字段、字段别名、超链接和弹出框方式四种数据
Returns:
InfoWindow - InfoWindow对象

Extends

  • THING.BaseObject

Members

customHtml :String

自定义信息框的html文本,仅当 type='custom'时生效

Example
//设置自定义信息框的html文本为 注{{}}包住的是需要标注对象的userData中的属性名称
//比如被标注物体的userData.name='花家地南街' 该例子信息框的html文本为'<div>站名:花家地南街</div>'
infoWindow.customHtml = '<div>站名:{{name}}</div>';

displayMode :THING.EARTH.DisplayMode

信息框的显示方式,有包括DisplayMode.MouseEnter(悬浮显示)、DisplayMode.Click(点击显示)、DisplayMode.Always(一直显示) DisplayMode.None(不显示)四种类型

Example
infoWindow.displayMode = THING.EARTH.DisplayMode.Click; //设置信息框的显示方式为点击显示

fieldData :Array

信息框中显示的信息

Example
//设置信息框的显示'OBJECTID'、'NAME'两个字段的信息,字段别名分别为'编号'、'姓名',点击姓名字段,在当前页面弹出400*300大小的页面
infoWindow.fieldData = [
   {field:'OBJECTID',alias:'编号' },
   {field:'NAME',alias:'姓名',url:'https://www.baidu.com', target:'current' ,width:400,height:300}
];
//fieldData中每一项都是一个对象
//例如 {field:'OBJECTID',alias:'编号',url:'https://www.baidu.com', target:'current' ,width:400,height:300 },
//field代表需要标注的字段名 可以在被标注物体的userData中找到
//alias代表在标注中显示该字段名的别名,该例子中,显示'编号'
//url 如果设置url,则点击标注中这一条记录会跳转到该url地址
//target 在设置url的情况下,代表跳转到新页面还是在当前页打开 target取值有两种 一种是current代表当前页 一种是new代表新页面
//width 在设置url并且target为current时,代表在当前页弹出口的宽度 默认800
//height 在设置url并且target为current时,代表在当前页弹出口的高度 默认600

style :THING.EARTH.InfoWindowStyle

信息框的样式,有Default(默认)、Blue(蓝色) 和 White(白色)

Default Value:
  • Default
Example
infoWindow.style = THING.EARTH.InfoWindowStyle.Blue; //设置信息框的样式是蓝色

title :String

信息框的标题

Default Value:
  • 详细信息
Example
infoWindow.title = '基本信息'; //设置信息框的标题是'基本信息'

type :THING.EARTH.InfoWindowType

信息框的类型,有 Standard(标准) 和 Custom(自定义) 两种类型,
type为Standard会读取fieldData中的信息设置弹窗内容 type为Custom 会根据customHtml设置弹窗内容

Default Value:
  • THING.EARTH.InfoWindowType.Standard
Example
infoWindow.type = THING.EARTH.InfoWindowType.Custom; //设置信息框的类型为“自定义类型”