MapGISLabelLayer

new Cesium.MapGISLabelLayer(labelUrl, scene, options, layerInfo, labelExtend)

An imagery layer that displays tiled image data from a single imagery provider on a Globe.
Name Type Default Description
labelUrl String 请求到的注记信息
scene Scene 场景对象
options Object Object with the following properties:
option.show Boolean true optional 注记可配置参数 显示性控制
option.translucency NearFarScalar 注记可配置参数 相机高度-透明度控制
option.distanceDisplayCondition DistanceDisplayCondition 注记可配置参数 相机高度-可见性控制
option.maxTextLength Number 255 optional 注记最大显示长度,默认255
option.isAllowTextOverlap Number true optional 是否允许注记压盖
option.swipeEnabled Boolean false optional 开启卷帘对比分析
option.swipeInverse Number 0 optional 单独控制该图层是否进行反转。小于0不反转,大于0时反转,等于0失效。该属性的控制优先级高于Scene#swipeController中的inverse属性.若要取消该属性对本图层的独立控制需要将该属性置为0。
layerInfo Object 从IGS查询到的图层的信息,如最大最小比例尺,避让等
labelExtend Object 参考Style.LabelNoteStyle
Example:
var url = 'http://webclient.smaryun.com:6163/igs/rest/g3d/HkPOI';
            viewer.scene.layers.appendSceneLayer(url, {
                autoReset: false,
                synchronous: true,
                // label选项
                labelExtend: new Cesium.Style.LabelNoteStyle({
                    symbol: {
                        type: 'label-symbol',
                        // 填充颜色 rgba or 16进制颜色
                        color: 'rgba(255,255,255,1)',
                        // 描边颜色
                        haloColor: 'rgba(0,0,0,0.5)',
                        // 描边宽度
                        haloSize: 1,
                        // 行高
                        lineHeight: 1.1,
                        // 行宽
                        lineWidth: 150,
                        // 最大行数
                        lineMaxNum: 3,
                        // 换行
                        textWraps: true,
                        // 文本间距
                        letterSpacing: '2px',
                        // x方向偏移
                        xoffset: 0,
                        // y方向偏移
                        yoffset: 0,
                        // 字体样式 参考css
                        font: {
                            size: 12,
                            family: '微软雅黑',
                            weight: 'normal',
                            style: 'normal'
                        },
                        // 是否开启填充背景
                        showBackground: false,
                        // 背景填充色
                        backgroundColor: 'rgba(42,42,42,1)',
                        // 背景边距 number or array
                        backgroundPadding: [5, 7],
                        // 背景图片 支持image对象、function
                        backgroundImage: undefined,
                        // 是否开启图标
                        showTextExtraIcon: false,
                        // 图标图片 支持image对象
                        textExtraIcon: undefined,
                        // 图标方位 "left" "right" "top" "bottom"
                        textExtraIconAnchor: 'top',
                        // 图标大小
                        textExtraIconSize: 14,
                        // 是否开启阴影
                        showTextShadow: false,
                        textShadowOffsetX: 1,
                        textShadowOffsetY: 1,
                        textShadowColor: '#ffffff',
                        textShadowBlur: 2,
                        // 文字删除线
                        showTextDecorationThroughline: false,
                        textDecorationThroughlineColor: 'rgba(255,255,255,1)',
                        textDecorationThroughlineWidth: 1,
                        // 文字下划线
                        showTextDecorationUnderline: false,
                        textDecorationUnderlineColor: 'rgba(255,255,255,1)',
                        textDecorationUnderlineWidth: 1
                    },
                    // 渲染类型
                    renderMode: 'canvas',
                    // 注记位置
                    labelPlacement: 'above-center',
                    // 缩放
                    scale: 1,
                    // 高度索引参考
                    heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                }),
                // 是否允许注记覆盖
                isAllowTextOverlap: false,
                getDocLayerIndexes: function (indexs) {
                    sceneIndex = indexs[0];
                    // 获取图层
                    var labelLayer = viewer.scene.layers.getLayer(sceneIndex).getLabelLayers()[0];
                    // 添加注记
                    labelLayer.appendLabel(114.2, 31, 200, '这是一个标签', {
                        symbol: {
                            font: {
                                size: 20,
                                family: '微软雅黑',
                                weight: 'normal',
                                style: 'normal'
                            }
                        },
                        // 渲染类型
                        renderMode: 'ground',
                        // 注记位置
                        labelPlacement: 'above-center',
                        // 缩放
                        scale: 100
                    });
                    // 图层删除方法
                    // viewer.scene.layers.removeLayerByID(sceneIndex, true);
                }
            });

Members

readonly layerInfo : Object

Example:
{layerIndex: 0, layerName: "构造名称_经纬度", layerType: "4", beginLevel: 0, endLevel: 20}

maxTextLength : Number

255

readonly readyPromise : Promise.<MapGISLabelLayer>

readonly show : Boolean

swipeEnabled : Boolean

开启卷帘对比分析
Default Value: false

swipeInverse : Number

单独控制该图层是否进行反转,小于0不反转,大于0时反转,等于0失效。该属性的控制优先级高于Scene#swipeController中的inverse属性.若要取消该属性对本图层的独立控制需要将该属性置为0.
Default Value: 0

Methods

appendLabel(lat, lon, height, lText, options)Label

添加文字标签
Name Type Description
lat Number 经度
lon Number 纬度
height Number 高程
lText String 标签内容
options Object 参考Style.LabelNoteStyle
Returns:
标签对象 (Label)
Example:
labelLayer.appendLabel(114.2, 31, 200, '这是一个标签', {
                symbol: {
                    font: {
                        size: 20,
                        family: '微软雅黑',
                        weight: 'normal',
                        style: 'normal'
                    }
                },
                // 渲染类型
                renderMode: 'ground',
                // 注记位置
                labelPlacement: 'above-center',
                // 缩放
                scale: 100
            });

contains(label)Boolean

查询Label是否在图层中
Name Type Description
label Label | Billboard | Primitive
Returns:
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.
Name Type Default Description
destroy Boolean true optional 是否销毁内存
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
MapGISLabelLayer = MapGISLabelLayer && MapGISLabelLayer.destroy();
See:

getCanvasLabelById(id)Billboard

通过Id获取图层中的Label
Name Type Description
id String
Returns:
通过Id获取图层中的Label
Name Type Description
id String
Returns:

getPrimitiveLabelById(id)Primitive

通过Id获取图层中的Label
Name Type Description
id String
Returns:

isDestroyed()Boolean

Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.
Returns:
True if this object was destroyed; otherwise, false.
See:

removeLabel(label)Boolean

移除图层中的Label
Name Type Description
label Label | Billboard | Primitive
Returns:
true为成功移除 false为label不存在