MapGISLabelLayer

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

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 DistanceDisplayCondition 255 optional 注记最大显示长度,默认255
option.labelExtend Object 注记可配置参数 注记对象参数 Label
layerInfo Object 从IGS查询到的图层的信息,如最大最小比例尺,避让等
Example:
var url = 'http://localhost:6163/igs/rest/g3d/label88204';
    var options = {
        labelExtend: { scale: 2.0 },
        getDocLayerIndexes: function (indexs) {
            console.log(indexs);
            // 存储单图层
            layerIndex = indexs[0];
            layer = viewer.scene.layers.getLayer(layerIndex);
            console.log(layer);
            // 存储图层索引数组
            // layerIndex=indexs;
        }
    };
    viewer.scene.layers.appendSceneLayer(url, options);

Members

readonly layerInfo : Object

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

maxTextLength : Number

255

readonly readyPromise : Promise.<MapGISLabelLayer>

readonly show : Boolean

Methods

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

添加文字标签
Name Type Description
lat Number 经度
lon Number 纬度
height Number 高程
lText String 标签内容
options Object
Name Type Default Description
id String optional 标签id,不设置则使用默认顺序id
font String '14pt monospace' optional 字体
fillColor Color Cesium.Color.WHITE optional 字体的填充色
outlineColor Color Cesium.Color.WHITE optional 字体的填充色
style LabelStyle Cesium.LabelStyle.FILL_AND_OUTLINE optional 样式
outlineWidth Number 1 optional 外边线宽度
heightReference Number Cesium.HeightReference.NONE optional 外边线宽度
verticalOrigin VerticalOrigin Cesium.VerticalOrigin.CENTER optional 标签位置 Cesium.VerticalOrigin.Cesium.VerticalOrigin.LEFT Cesium.VerticalOrigin.RIGHT
horizontalOrigin HorizontalOrigin Cesium.HorizontalOrigin.CENTER optional 标签位置 Cesium.HorizontalOrigin.Cesium.HorizontalOrigin.LEFT Cesium.HorizontalOrigin.RIGHT
description String optional 属性描述
Returns:
标签对象 (Label)
Example:
var url = 'http://localhost:6163/igs/rest/g3d/label88204';
    var options = {
        labelExtend: { scale: 2.0 },
        getDocLayerIndexes: function (indexs) {
            console.log(indexs);
            // 存储单图层
            layerIndex = indexs[0];
            layer = viewer.scene.layers.getLayer(layerIndex);
            console.log(layer);
            var label = layer.appendLabel(114.2, 31, 200, '这是一个标签', {
                font:'14pt 楷体',
                style:Cesium.LabelStyle.FILL_AND_OUTLINE,
                verticalOrigin:Cesium.VerticalOrigin.BOTTOM,
                pixelOffset:new Cesium.Cartesian2(0, -9)});
        }
    };
    viewer.scene.layers.appendSceneLayer(url, options);

contains(label)Boolean

查询Label是否在图层中
Name Type Description
label Label
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:
通过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
Returns:
true为成功移除 false为label不存在