Class: LayerInfoWindow

CMAP.LayerInfoWindow(featureLayer, param)

图层弹窗类LayerInfoWindow

Constructor

new LayerInfoWindow(featureLayer, param)

构造函数
Parameters:
Name Type Description
featureLayer CMAP.FeatureLayer 需要标注的featureLayer
param Object 参数列表
Properties
Name Type Description
type String 信息框的类型,支持CMAP.InfoWindowType.Standard(标准)和CMAP.InfoWindowType.Custom(自定义)两种类型, type为CMAP.InfoWindowType.Standard 会读取fieldData中的信息设置弹窗内容 type为CMAP.InfoWindowType.Custom 会根据customHtml设置弹窗内容
customHtml String 自定义信息框的html文本,仅在type为custom时生效
displayMode String 信息框显示方式,包括CMAP.DisplayMode.MouseEnter(悬浮显示)、CMAP.DisplayMode.Click(点击显示)、CMAP.DisplayMode.Always(一直显示)CMAP.DisplayMode.None(不显示)四种类型
title String 信息框的标题
style String 信息框的样式,包括CMAP.InfoWindowStyle.Default、CMAP.InfoWindowStyle.Blue和CMAP.InfoWindowStyle.White三种类型
offset Array 信息框的偏移量 [x,y,z]分别代表三个轴偏移量 上下为y轴 左右为x轴 前后为z轴
pivot Array 信息框的轴心,以百分比表示界面轴心位置 [0,0] 代表界面左上;[1,1] 代表界面右下 默认[0.5,1] 数组每个值可以大于1用于控制像素级别的offset
fieldData Array 信息框中显示的字段、字段别名、超链接和弹出框方式四种数据

Members

customHtml :String

自定义信息框的html文本,当 type=“custom”时生效
Type:
  • String
Author:
Example
//设置自定义信息框的html文本为 注{{}}包住的是需要标注图层中对象的userData中的属性名称
layerInfoWindow.customHtml = '<div>站名:{{name}}</div>';

displayMode :String

信息框的显示方式,有clickShow 、mouseoverShow、oftenShow 和 none四种选项
Type:
  • String
Author:
Example
layerInfoWindow.displayMode = 'clickShow'; //设置信息框的显示方式为“clickShow”,即“点击显示”

fieldData :Array

信息框中显示信息的字段
Type:
  • Array
Author:
Example
//设置信息框的显示'OBJECTID'、'NAME'两个字段的信息,字段别名分别为'编号'、'姓名',点击姓名字段,在当前页面弹出400*300大小的页面
layerInfoWindow.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
Author:
Example
infoWindow.offset = [10,0,0]; // 设置信息框的向X正半轴方向偏移10米

pivot :Array

界面的轴心,以百分比表示界面轴心位置。[0,0] 代表界面左上;[1,1] 代表界面右下 默认[0.5,1]
Type:
  • Array
Author:

style :String

信息框的样式,有default、blue 和 white 三种选项
Type:
  • String
Author:
Example
layerInfoWindow.style = 'blue'; //设置信息框的样式是“蓝色”

title :String

信息框的标题
Type:
  • String
Author:
Example
layerInfoWindow.title = '基本信息'; //设置信息框的标题是'基本信息'

type :String

信息框的类型,有 standard(标准) 和 custom(自定义) 两种类型,type为standard会读取fieldData中的信息设置弹窗内容 type为custom 会根据customHtml设置弹窗内容
Type:
  • String
Author:
Example
layerInfoWindow.type = 'custom'; //设置信息框的类型为“自定义类型”

visible :Boolean

信息框的显示和隐藏状态,true时是显示,false时是隐藏
Type:
  • Boolean
Author:
Example
layerInfoWindow.visible = fasle; //隐藏信息框