Class: ShapeFileLayer

ShapeFileLayer

ShapeFileLayer矢量图层对象相关的操作


<protected> new ShapeFileLayer()

一般通过api.ShapeFileLayer调用其方法

See:
  • DigitalTwinAPI#ShapeFileLayer

Extends

Methods


add(data, fn)

添加一个或多个ShapeFileLayer对象
数据类型分三种:Polygon、Polyline、Point,对应不同对象属性

Parameters:
Name Type Description
data object | array

数据结构,支持对象或数组,对于每一个对象支持以下属性:

  • id (string) 字符串类型的ID

  • groupId (string) 可选,Group分组

  • userData (string) 可选,用户自定义数据

  • file (String) ShapeFileLayer的文件路径,支持本地路径和网络路径

  • offset (array) 偏移量:[X,Y,Z],数组元素类型:(number),默认值[0.000000, 0.000000, 0.000000]

  • rotation (array) 旋转:[Pitch,Yaw,Roll],数组元素类型:(number),取值范围:[任意数值],默认值[0.000000, 0.000000, 0.000000]

  • defaultColor (Color) 支持四种格式,取值示例 默认颜色:[0.000000, 0.000000, 1.000000, 1.000000] RGBA

  • polygonColorFieldName (String) 当type==Polygon时此属性可选,多边形颜色字段

  • polygonHeightFieldName (String) 当type==Polygon时此属性可选,多边形高度字段

  • polygonGroundHeightFieldName (String) 当type==Polygon时此属性可选,底面高度字段

  • polygonTopHeightFieldName (String) 当type==Polygon时此属性可选,顶面高度字段

  • polygonStyle (number) 当type==Polygon时此属性可选,多边形样式,共6种,取值范围:[0~5],分别为 0:体块(半透明) 1:圆点 2:单色 3:体块(纯色)4:纯色(半透明) 5:X光

  • polygonDefaultHeight (number) 当type==Polygon时此属性可选,多边形高度,单位米

  • cacheAllField (boolean) 当type==Polygon时此属性可选,Polygon支持缓存所有字段,以便于高效动态更新Polygon不同字段的效果,默认值:false,注意:仅在只更新Polygon字段时生效

  • polylineDefaultThickness (number) 当type==Polyline时此属性可选,折线宽度,单位米

  • pointTextContentFieldName (String) 当type==Point时此属性可选,文本内容(点字段)

  • pointDisplayMode (number) 当type==Point时此属性可选,显示模式,取值说明如下:

    0:相机移动不显示,参与避让聚合

    1:相机移动时显示,参与避让聚合

    2:相机移动时显示,不参与避让聚合

  • clusterByImage (boolean) 当type==Point时此属性可选,是否按相同图片路径(pointImage)聚合显示

  • pointImage (String) 当type==Point时此属性可选,图片路径

  • pointContentRange (number) 当type==Point时此属性可选,文本可见距离,单位米

  • pointRange (array) 当type==Point时此属性可选,可见距离(米)点坐标:[X,Y]

  • pointFontColor (Color) 当type==Point时此属性可选,字体颜色 ,支持四种格式,取值示例

  • pointFontOutlineColor (Color) 当type==Point时此属性可选,字体轮廓颜色 ,支持四种格式,取值示例

  • pointBackgroundColor (Color) 当type==Point时此属性可选,字体背景颜色 ,支持四种格式,取值示例

  • pointShowLine (boolean) 当type==Point时此属性可选,是否显示线 默认false

  • pointOcclusionCull (boolean) 当type==Point时此属性可选,是否参与遮挡 默认true

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


clear(fn)

删除场景中所有的ShapeFileLayer

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


delete(ids, fn)

删除一个或多个ShapeFileLayer对象

Parameters:
Name Type Description
ids string | array

要删除的ShapeFileLayer对象的ID或者ID数组(可以删除一个或者多个)

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


focus(ids, distance, flyTime, rotation, fn)

自动定位到合适的观察距离

Parameters:
Name Type Description
ids string | array

ShapeFileLayer对象的ID或者ID数组

distance number

可选参数,观察点距离目标点(被拍摄物体)的距离,取值范围:[0.01~任意正数],如果设置为0或者不设置,系统自动计算

flyTime number

可选参数,相机飞行的时间,取值范围:[0~任意正数],单位:秒,默认值2秒

rotation array

可选参数,相机旋转的欧拉角:[Pitch,Yaw,Roll],数组元素类型:(number),取值范围:Pitch[-90~90] Yaw[-180~180] Roll[0]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


focusFeature(shapeFileLayerId, featureId, distance, flyTime, rotation, fn)

定位到ShapeFileLayer的要素区域

Parameters:
Name Type Description
shapeFileLayerId string

ShapeFileLayer对象的ID

featureId number

要素区域Feature的ID

distance number

可选参数,观察点距离目标点(被拍摄物体)的距离,取值范围:[0.01~任意正数],如果设置为0或者不设置,系统自动计算

flyTime number

可选参数,相机飞行的时间,取值范围:[0~任意正数],单位:秒,默认值2秒

rotation array

可选参数,相机旋转的欧拉角:[Pitch,Yaw,Roll],数组元素类型:(number),取值范围:Pitch[-90~90] Yaw[-180~180] Roll[0]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


get(ids, fn)

根据ID获取ShapeFileLayer的详细信息 包含模型属性和值

Parameters:
Name Type Description
ids string | array

要获取的ShapeFileLayer对象ID或者ID数组(可以获取一个或者多个)

fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Example
返回ShapeFileLayer的详细信息
{
            "id":	"sp1",
            "groupId":	"",
            "userData":	"",
            "type":	"Polygon",
            "file":	"G:\\TEMP\\Explorer\\SDK\\JS/media/ShapeFileLayer/polygonColor.shp",
            "polygonColorFieldName":	"RGB",
            "polygonHeightFieldName":	"",
            "polygonGroundHeightFieldName":	"",
            "polygonTopHeightFieldName":	"",
            "polygonStyle":	0,
            "polygonDefaultHeight":	200.000000,
            "defaultColor":	[0.000000, 0.000000, 1.000000, 1.000000],
            "offset":	[0.000000, 0.000000, 0.000000],
            "rotation":	[0.000000, 0.000000, 0.000000],
            "scale":	[1.000000, 1.000000, 1.000000]
        }

getFeature(data, fn)

获取ShapeFileLayer内部要素区域的详细信息

Parameters:
Name Type Description
data object | array

数据结构,支持对象或数组,对于每一个对象支持以下属性:

  • shpId (string) ShapeFileLayer对象的ID

  • featureIds (array) ShapeFileLayer对象内部的要素区域ID,数组元素类型为number

fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Example
ShapeFileLayer内部要素区域的详细信息
	{
        "sp1":	{
            "29":	{
                "Type":	"shapefilelayer",
                "Id":	"sp1",
                "featureId":	"29",
                "height":	200.000000,
                "groundHeight":	0.000000,
                "Fields":	[{
                        "CMColor":	"4294901760"
                    }, {
                        "SLColor":	"255"
                    }, {
                        "RGB":	"255,0,0"
                    }]
            },
            "30":	{
                "Type":	"shapefilelayer",
                "Id":	"sp1",
                "featureId":	"30",
                "height":	200.000000,
                "groundHeight":	0.000000,
                "Fields":	[{
                        "CMColor":	"4294901760"
                    }, {
                        "SLColor":	"255"
                    }, {
                        "RGB":	"255,0,0"
                    }]
            },
            "32":	{
                "Type":	"shapefilelayer",
                "Id":	"sp1",
                "featureId":	"32",
                "height":	200.000000,
                "groundHeight":	0.000000,
                "Fields":	[{
                        "CMColor":	"4294901760"
                    }, {
                        "SLColor":	"255"
                    }, {
                        "RGB":	"255,0,0"
                    }]
            }
        }
    }

hide(ids, fn)

隐藏ShapeFileLayer

Parameters:
Name Type Description
ids string | array

ShapeFileLayer对象的ID或者ID数组

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


hideAll(fn)

隐藏所有ShapeFileLayer

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


highlightFeature(shapeFileLayerId, featureId, fn)

高亮ShapeFileLayer对象内部的某一块要素区域

Parameters:
Name Type Description
shapeFileLayerId string

ShapeFileLayer对象的ID

featureId number

ShapeFileLayer对象内部的要素区域ID

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


highlightFeatures(data, fn)

高亮ShapeFileLayer对象内部的多块要素区域

Parameters:
Name Type Description
data object | array

数据结构,支持对象或数组,对于每一个对象支持以下属性:

  • shapeFileLayerId (string) ShapeFileLayer对象的ID

  • featureIds (array) ShapeFileLayer对象内部的要素区域ID,数组元素类型为number

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


open(data, fn)

打开ShapeFileLayer 返回模型包含的所有属性

Parameters:
Name Type Description
data object | array

数据结构,支持对象或数组,对于每一个对象支持以下属性:

  • file (string) ShapeFileLayer文件的路径
fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Example
返回模型包含的所有属性
{ "fieldName":	["CMColor", "SLColor", "RGB"]	}

show(ids, fn)

显示ShapeFileLayer

Parameters:
Name Type Description
ids string | array

ShapeFileLayer对象的ID或者ID数组

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


showAll(fn)

显示所有ShapeFileLayer

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


stopHighlightFeature(shapeFileLayerId, featureId, fn)

取消高亮ShapeFileLayer对象内部的某一块要素区域

Parameters:
Name Type Description
shapeFileLayerId string

ShapeFileLayer对象的ID

featureId number

ShapeFileLayer对象内部的要素区域ID

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


stopHighlightFeatures(data, fn)

取消高亮ShapeFileLayer对象内部的多块要素区域

Parameters:
Name Type Description
data object | array

数据结构,支持对象或数组,对于每一个对象支持以下属性:

  • shapeFileLayerId (string) ShapeFileLayer对象的ID

  • featureIds (array) ShapeFileLayer对象内部的要素区域ID,数组元素类型为number

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


update(data, fn)

修改一个或多个ShapeFileLayer对象

Parameters:
Name Type Description
data object | array

数据结构,请参考add方法

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


updateBegin()

用于批量多次修改对象的属性

在开始修改之前调用updateBegin,然后可以多次调用setXXX方法,最后调用updateEnd提交修改更新数据
注意:
updateBegin不是异步调用,不需要await,也没有回调函数参数

Inherited From:
Overrides:
Example
__g.xxx.updateBegin();
for (let i = 0; i < 1000; i++) {
     __g.xxx.setColor(i, Color.Yellow);
} 
__g.xxx.updateEnd(function () {
     log('update finished!');
});

updateEnd(fn)

用于批量多次修改对象的属性,与updateBegin配套使用
注意:
updateEnd是异步调用,可以用回调函数也可以await

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Inherited From:
Overrides: