ShpLayer

ShpLayer

new ShpLayer()

Shp图层

Extends

Methods

add()

Overrides:

添加

addEntity(entitys)

添加外部自定义entitys

Parameters:
Name Type Description
entitys Array.Object

centerAt()

Overrides:

定位至数据区域

create()

Inherited From:

创建图层,可以在图层的Config中定义 OnCreate(viewer) 方法, 当图层创建时调用

getEntitys()

得到所有entity

Returns:

Array.object

getLayer()

得到渲染数据

Returns:

dataSource

getVisible() → {boolean}

Inherited From:

得到图层是否显示

Returns:

图层是否显示

Type
boolean

initialize(cfg)

Overrides:

初始化,new图层时调用

Example
var layer = new zz3d.layer.ShpLayer({
                "id": 1987,
                "name": "安徽各市",
                "url": serverURL_file + "/anhui.shp",
                "symbol": {
                    "styleOptions": {
                        "fill": true,
                        "randomColor": true, //随机色
                        "opacity": 0.3,
                        "outline": true,
                        "outlineColor": "#FED976",
                        "outlineWidth": 3,
                        "outlineOpacity": 1,
                        "label": { //面中心点,显示文字的配置
                            "text": "{name}", //对应的属性名称
                            "opacity": 1,
                            "font_size": 40,
                            "color": "#ffffff",

                            "font_family": "楷体",
                            "border": true,
                            "border_color": "#000000",
                            "border_width": 3,

                            "background": false,
                            "background_color": "#000000",
                            "background_opacity": 0.1,

                            "font_weight": "normal",
                            "font_style": "normal",

                            "scaleByDistance": true,
                            "scaleByDistance_far": 20000000,
                            "scaleByDistance_farValue": 0.1,
                            "scaleByDistance_near": 1000,
                            "scaleByDistance_nearValue": 1,

                            "distanceDisplayCondition": false,
                            "distanceDisplayCondition_far": 10000,
                            "distanceDisplayCondition_near": 0
                        }
                    }
                },
                "popup": "{name}",
                // "tooltip": "{name}",
                "click": function (entity, position) { //单击 
                    console.log('你单击了:' + entity.properties.name._value);

                },
                "mouseover": function (entity) { //移入
                    console.log('你鼠标移入到:' + entity.properties.name._value);

                    if (entity && entity.polygon)
                        highlightedEntity(entity);
                },
                "mouseout": function (entity) { //移出
                    console.log('你鼠标移出了:' + entity.properties.name._value);

                    if (entity && entity.polygon)
                        clearLastHighlightedEntity();
                },
                "visible": true,
                "flyTo": true
            }, viewer);
            viewer.zz.addOperationalLayer(layer);
Parameters:
Name Type Description
cfg Object
Properties
Name Type Attributes Default Description
id Number

图层id

name String

图层名称

url String

图层数据的url

symbol Object

图层符号化规则

tooltip String <optional>

tooltip字段

click function <optional>

鼠标点击事件的处理函数

mouseover function <optional>

鼠标移入的处理函数

mouseout function <optional>

鼠标移出的处理函数

visible Boolean <optional>
true

是否可见

flyTo Boolean <optional>
false

是否定位到这个图层,整个场景只能有一个

flyToDuration Number <optional>
0

定位到这个图层需要的时间(秒)

remove()

Overrides:

移除

removeEntity(entity)

删除指定entity

Parameters:
Name Type Description
entity object

setOpacity(value)

Overrides:

设置透明度

Parameters:
Name Type Description
value Number
Returns:

none

setVisible(val)

Inherited From:

设置图层是否显示

Parameters:
Name Type Description
val boolean

图层是否显示

setZIndex(value)

Inherited From:

设置叠加顺序

Parameters:
Name Type Description
value Number

叠加顺序, int值