MarkerCollection(options)

标注集合类,参考添加标注

new MarkerCollection(options)

Parameters:
Name Type Description
options Object

包含以下参数的对象

Properties
Name Type Attributes Description
viewer Viewer

Motor.Viewer实例化对象

animated Boolean <optional>

标注集内是否带有动画

interval String <optional>

动画起止点,遵循ISO 8601时间格式标准,如"2019-08-04T16:00:00Z/2019-08-04T16:00:05Z"

loop Boolean <optional>

是否循环播放动画

Members

readonly length

获取标注数量

Methods

add(packets) → {Promise}

添加标注

Parameters:
Name Type Description
packets Object | Array.<Object>

标注的描述对象或对象数组

Returns:
Promise
Example
markers.add({
    //标注id
    id:"marker1",
    //标注位置
    position: {
        epoch:"2019-08-04T16:00:00Z",//标注动画起始时间
        cartographicDegrees : [
            0, 121, 31, 5, //从起始时间开始第0秒的位置
            1, 121, 31, 10, //从起始时间开始第1秒的位置
            2, 121, 31, 5, //从起始时间开始第2秒的位置
        ]
    },
    //标注文字内容
    label: {
        text: "文字内容",
        font: "12px 微软雅黑",
        style: "FILL_AND_OUTLINE",//文字样式
        fillColor:{
            rgba : [255, 255, 255, 255]
        },
        outlineColor:{
            rgba : [0, 0, 0, 255]
        },
        outlineWidth:2,
        showBackground: true,
        backgroundColor: {
            rgba : [255, 0, 0, 255]
        },
        verticalOrigin: 'CENTER', //垂直原点
        horizontalOrigin: 'CENTER',//水平原点
        pixelOffset:{
            cartesian2:[-10,-30]//左移10个像素,上移30个像素
        },
    },
    //添加始终面向用户的图片标注
    billboard:{
        image: 'path/to/image',//图片地址
        verticalOrigin: 'BOTTOM',
        horizontalOrigin: 'LEFT',
        scale:2,//缩放比例
        pixelOffset:{
            cartesian2:[-10,-30]
        },
        rotation: 0.1//逆时针旋转角度(弧度制)
    },
    //添加点
    point:{
        pixelSize:5, //点的像素大小
        color:{
            rgba:[255,0,0,255]
        },
        outlineWidth:2,
        outlineColor:{
            rgba:[255,255,0,255]
        }
    },
    //自定义属性,用于点击标注时的返回值
    properties:{
        "名称":"标注1",
        "类型":"图标",
        "关联构建id":"guid",
        "经度":121,
        "纬度":31,
        "高度":5,
    }
});

removeAll()

移除MarkerCollection中的所有标注

removeById(id)

根据id移除标注

Parameters:
Name Type Description
id String

marker的id

update(packet)

更新一个marker的状态

Parameters:
Name Type Description
packet Object

标注的描述对象