new Draw()
绘制类 eg:new zz3d.Draw(viewer, {})
Extends
- Evented
Methods
addBillboard(point, styleopt) → {Entity}
添加billboard点数据
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
point |
Cartesian3 | 点位置 |
||
style |
Object |
<optional> |
{}
|
样式信息 |
Returns:
- Type
- Entity
addPoint(point, styleopt) → {Entity}
添加billboard点数据
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
point |
Cartesian3 | 点位置 |
||
style |
Object |
<optional> |
{}
|
样式信息 |
Returns:
- Type
- Entity
addPolygon(coordinates, styleopt) → {Entity}
添加面数据
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
coordinates |
Array | 点组 点类型[经,纬,高] |
||||||||||||||||||||
style |
Object |
<optional> |
{}
|
样式信息 Properties
|
Returns:
- Type
- Entity
addPolyline(coordinates, styleopt) → {Entity}
添加线数据
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
coordinates |
Array | 点组 点类型[经,纬,高] |
||
style |
Object |
<optional> |
{}
|
样式信息 |
Returns:
- Type
- Entity
bindDeleteContextmenu(entity)
给entity绑定右键删除菜单
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
bindExtraEntity(entity, attributeopt)
绑定外部非Draw产生的entity到标绘
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
entity |
Entity | 外部实体 |
||
attribute |
Object |
<optional> |
{}
|
属性信息 |
bindSelectEvent()
绑定鼠标选中事件
clearDraw(bContinueDraw) → {Object}
删除所有绘制实体
Parameters:
Name | Type | Description |
---|---|---|
bContinueDraw |
Boolean | 是否继续现有绘制 |
Returns:
返回绘制对象本身
- Type
- Object
closeTooltip()
关闭提示框
deleteAll()
删除所有实体 等同于clearDraw 兼容不同习惯命名
deleteEntity(entity)
删除单个实体
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
deleteEntityById(id)
根据ID删除单个实体
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 目标实体ID |
deleteEntityByTypeId(id)
根据类型ID批量删除实体
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 类型id |
destroy()
销毁对象
destroySelectEvent()
销毁鼠标选中事件
endDraw() → {Object}
用于外部控制,完成绘制,比如手机端无法双击结束
Returns:
返回绘制对象本身
- Type
- Object
flyTo(entity, optsopt)
定位实体 实际调用的是ViewerEx.flyTo接口 opts详情参考ViewerEx.flyTo接口说明
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
entity |
Entity | 目标实体 |
||||||||||||
opts |
Object |
<optional> |
{}
|
带有以下属性的对象: Properties
|
getCoordinates(entity) → {Array}
获取实体的经纬度值 坐标数组
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
Returns:
- Type
- Array
getCurrentEntity() → {Object}
获取当前编辑的要素
Returns:
返回正在编辑的实体
- Type
- Object
getDataSource() → {Object}
获取数据源
Returns:
- Type
- Object
getEntityById(id, bContinueDraw) → {Entity}
根据ID获取实体
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 实体id |
bContinueDraw |
Boolean | 是否继续现有绘制 |
Returns:
- Type
- Entity
getEntityByTypeId(id, bContinueDraw) → {Array}
根据类型ID获取实体
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 类型id |
bContinueDraw |
Boolean | 是否继续现有绘制 |
Returns:
- Type
- Array
getEntitys(noStop) → {Array}
获取所有绘制的实体对象列表
Parameters:
Name | Type | Description |
---|---|---|
noStop |
Boolean | 是否不停止现有绘制 |
Returns:
- Type
- Array
getPositions(entity) → {Array}
获取实体的坐标数组 Cart3类型
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
Returns:
- Type
- Array
hasDraw() → {Boolean}
是否存在绘制
Returns:
- Type
- Boolean
hasDrawing() → {Boolean}
获取是否还在绘制中
Returns:
- Type
- Boolean
hasEdit(var)
设置是否允许编辑
Parameters:
Name | Type | Description |
---|---|---|
var |
Boolean | 是否允许编辑 |
initialize(viewer, optionsopt)
初始化
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
viewer |
Viewer | 场景对象 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
{}
|
带有以下属性的对象: Properties
|
isMyEntity(entity) → {Boolean}
是否为当前编辑器编辑的实体
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
Returns:
- Type
- Boolean
jsonToEntity(json, isClear, isFly) → {Array}
加载goejson数据 兼容旧版本方法名 等同于loadJson
Parameters:
Name | Type | Description |
---|---|---|
json |
JSON | json对象 |
isClear |
Boolean | 是否清除其他实体 |
isFly |
Boolean | 是否飞到实体位置 |
Returns:
实体数组
- Type
- Array
loadJson(json, optsopt) → {Array}
加载goejson数据 定位有两种选择 flyTo或flyToByBoundingSphere
区别在于flyTo最终是按照总区域中心点定位的 flyToByBoundingSphere是按照总区域的包围球来定位的 选择其中一个即可 一般来说包围球定位效果更好
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
json |
JSON | json对象 |
||||||||||||||||||||||||||||||
opts |
Object |
<optional> |
{}
|
含有以下属性的对象: Properties
|
Returns:
实体数组
- Type
- Array
remove(entity)
删除单个实体 兼容不同习惯命名
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
removeAll()
删除所有实体 等同于clearDraw 兼容不同习惯命名
setPositions(positions, entity) → {Entity}
修改坐标、高程
Parameters:
Name | Type | Description |
---|---|---|
positions |
Array | 点组信息 点类型Cart3 |
entity |
Entity | 目标实体 |
Returns:
返回修改的实体
- Type
- Entity
setTooltipPosOffset(arropt)
绘制时tooltip的显示位置相对鼠标位置的偏移量 eg:[30,-30]表示向右偏移30像素,向上偏移30像素
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
arr |
Array |
<optional> |
[30,0]
|
相对鼠标位置的偏移量,像素单位 |
setVisible(visible)
设置可见性
Parameters:
Name | Type | Description |
---|---|---|
visible |
Boolean | 是否显示 |
startDraw(attributeopt, drawOkCalbackopt) → {Entity}
开始绘制
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
attribute |
Object |
<optional> |
{}
|
带有以下属性的对象: Properties
|
|||||||||||||||||||||||||||||||||||
drawOkCalback |
function |
<optional> |
绘制完成回调 作用和success相同 |
Returns:
返回绘制的实体
- Type
- Entity
startEditing(entity)
开始编辑
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 编辑对象 |
stopDraw() → {Object}
停止绘制
Returns:
返回绘制对象本身
- Type
- Object
stopEditing()
停止编辑
toGeoJSON(entity, bContinueDraw, bClose) → {Object}
转换实体为geojson
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | 目标实体 |
bContinueDraw |
Boolean | 是否继续现有绘制 |
bClose |
Boolean | 导出点组是否闭合 |
Returns:
- Type
- Object
updateAttribute(attribute, entity, onlyAttributesopt) → {Entity}
修改属性
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
attribute |
Object | 带有以下属性的对象: Properties
|
|||||||||||||||||
entity |
Entity | 目标实体 |
|||||||||||||||||
onlyAttributes |
Boolean |
<optional> |
false
|
是否仅更新属性 |
Returns:
返回修改后的对象
- Type
- Entity
updateStyle(styleopt, entity)
修改实体样式
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
style |
Object |
<optional> |
{}
|
样式信息 |
entity |
Entity | 目标实体 |