Constructor
new InfoWindow(geoObj, param)
构造函数
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
geoObj |
Object | 需要标注的地理对象 | |||||||||||||||||||||||||||
param |
Object | 参数列表
Properties
|
Members
customHtml :String
自定义信息框的html文本,仅当 type='custom'时生效
Type:
- String
Example
//设置自定义信息框的html文本为 注{{}}包住的是需要标注对象的userData中的属性名称
//比如被标注物体的userData.name='花家地南街' 该例子信息框的html文本为'<div>站名:花家地南街</div>'
infoWindow.customHtml = '<div>站名:{{name}}</div>';
displayMode :String
信息框的显示方式,有clickShow(点击显示) 、mouseoverShow(悬停显示)、oftenShow(一直显示) 和 none(不显示)四种选项
Type:
- String
Example
infoWindow.displayMode = 'clickShow'; //设置信息框的显示方式为'clickShow',即'点击显示'
fieldData :Array
信息框中显示的信息
Type:
- 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
offset :Array
信息框的UI偏移量[xOffset,yOffset,zOffset] xOffset代表左右偏移 左负右正 yOffset代表上下偏移 上正下负 zOffset代表前后偏移 前负后正
Type:
- Array
Example
infoWindow.offset = [10,0,0]; // 设置信息框的向X正半轴方向偏移10米
pivot :Array
界面的轴心,以百分比表示界面轴心位置。[0,0] 代表界面左上;[1,1] 代表界面右下 默认[0.5,1]
Type:
- Array
style :String
信息框的样式,有default(默认)、blue(蓝色) 和 white(白色) 三种选项
Type:
- String
Example
infoWindow.style = 'blue'; //设置信息框的样式是“蓝色”
title :String
信息框的标题
Type:
- String
Example
infoWindow.title = '基本信息'; //设置信息框的标题是'基本信息'
type :String
信息框的类型,有 standard(标准) 和 custom(自定义) 两种类型,type为standard会读取fieldData中的信息设置弹窗内容 type为custom 会根据customHtml设置弹窗内容
Type:
- String
Example
infoWindow.type = 'custom'; //设置信息框的类型为“自定义类型”
visible :Boolean
信息框的显示和隐藏状态,true时是显示,false时是隐藏
Type:
- Boolean
Example
infoWindow.visible = fasle; //隐藏信息框
Methods
destroy()
销毁信息框
Example
infoWindow.destroy(); //销毁已创建的信息框