View

地图视图渲染类

View

Members

backgroundColor :string

视图背景色,如: '#ff0000'

maxPolarAngle :float

地图的最大倾斜角

minPolarAngle :float

最小倾斜角

polarAngle :float|object

视图的倾斜角度
Properties:
Name Type Description
angle float | object 倾斜角度或一个object
Properties
Name Type Attributes Description
angle float 倾斜角度
duration float <optional>
动画的过渡时间(毫秒)
callback function <optional>
回调方法

viewAngle :float|object

地图的平面角度,与正北方向的夹角
Properties:
Name Type Description
angle float | object 地图的平面角度或一个object
Properties
Name Type Attributes Description
angle float 地图的平面角度
duration float <optional>
动画的过渡时间(毫秒)
callback function <optional>
回调方法

viewCenter :Array.<float>

当前的视图中心点坐标数组, [x, y, z]

viewCenter

设置视图中心坐标

viewMode :string|object

地图的视图模式,'2d' | '3d'
Properties:
Name Type Attributes Default Description
mode string | object 视图模式
Properties
Name Type Attributes Description
mode string 视图模式:'2d' | '3d'
duratioin float <optional>
动画过渡时间(毫秒)
callback function <optional>
视图模式切换完成后的回调方法
toNorth boolean <optional>
true 是否在2d视图时地图回到正北方向
Example
map.viewMode = '2d'; // or '3d'

map.viewMode = {mode: '2d', duration: 1000, callback: function() {
	console.log('视图模式切换完成');
}}

zoom :float|object

地图比例尺, 单位:厘米, 表示:屏幕上的1厘米对应地图中的x厘米
Properties:
Name Type Description
data float | object 比例尺值或一个object
Properties
Name Type Attributes Description
zoom float 比例尺
duration float <optional>
动画过滤时间(毫秒)
callback function <optional>
比例尺变化完成后的回调
Example
// 将地图的比例尺设置为1:1000, 屏幕1CM对应地图场景中的1000厘米(10米)
map.zoom = 1000;

// 或使用高级设置方式
map.zoom = {zoom: 1000, duration: 1, callback: function() {
	console.log('比例尺变化完成');
}}

zoomLevel :int

得到当前的比例尺级别 1~29级
Properties:
Name Type Description
data int | object 比例尺级别或一个object
Properties
Name Type Attributes Description
level int 比例尺级别 1~29
duration float <optional>
动画过渡时间(毫秒)
callback function <optional>
比例尺级别变化完成之后的回调方法
Example
// 将地图的比例尺级别设置为19级
map.zoomLevel = 19;

// 或使用高级设置方式
map.zoomLevel = {level: 19, duration: 2, callback: function() { 
	consle.log('比例尺级别变化完成'); 
}}

Methods

dispose() → {null}

销毁view类
Returns:
null

getScreenShot(width, height) → {string}

得到当前ooomap场景的屏幕截图
Parameters:
Name Type Description
width int 像素宽度
height int 像素高度
Returns:
string - base64 image string

getViewState() → {object}

得到当前的视图状态
Returns:
object - 当前的视图状态:{viewMode, zoom, zoomLevel, viewAngle, polarAngle, viewCenter}

moveTo(viewCenter, cb)

移动视角中心
Parameters:
Name Type Description
viewCenter Vector3 | object | Array.<float> 目标点的场景坐标
Properties
Name Type Attributes Description
viewCenter Vector3 | Array.<float> 目标点的场景坐标
viewAngle float <optional>
地图的平面角度,与正北方向的夹角
zoom float <optional>
比例尺
zoomLevel float <optional>
比例尺级别
polarAngle float <optional>
地图的倾斜角度
duration float <optional>
动画的过渡时间(毫秒)
easing string <optional>
动画的过渡方式
callback function <optional>
移动完成后的回调方法
cb function 回调函数

onlyShow(buildingIDs, floorNumbers, options) → {null}

只显示某些个建筑,或某些建筑的某些楼层
Parameters:
Name Type Description
buildingIDs Array.<string> | undefined 要单独显示的建筑的id数组, undefined: 显示所有
floorNumbers Array.<int> | string 要单独显示的楼层编号数组, string: 'all', 表示显示所有层
options object 关于单独显示的一些配置参数
Properties
Name Type Default Description
focus boolean true 是否要聚焦到单独显示的对象
withScene boolean false 是否显示场景
Returns:
null

resize(w, h)

重新设置视图的大小
Parameters:
Name Type Description
w int width视图的宽度
h int height视图的高度

setConfig(config)

设置视图的配置,主要用于打开新的OMScene时,应用此场景的视图配置
Parameters:
Name Type Description
config object 视图配置

setViewState(config, durationopt, callback)

设置视图的状态,如:viewMode, zoom, zoomLevel, viewAngle, polarAngle
Parameters:
Name Type Attributes Description
config object 视图状态的配置信息
Properties
Name Type Attributes Description
viewMode string <optional>
视图模式
zoom float <optional>
视图的比例尺
zoomLevel float <optional>
视图的比例尺级别
viewAngle float <optional>
视图的平面角度(度数)
polarAngle float <optional>
视图的倾斜角度(度数)
viewCenter Array.<float> <optional>
当前视图的中心点坐标数组[x, y, z]
easing string <optional>
动画的缓动曲线
callback function <optional>
视图变换完成后的回调
duration float <optional>
视图状态过渡所用时间(毫秒数)
callback function 回调函数

setZoomLevelRange(minopt, maxopt)

设置比例尺级别范围
Parameters:
Name Type Attributes Description
min int <optional>
最小比例尺级别,默认为地图配置config中的minZoomLevel
max int <optional>
最大比例尺级别,默认为地图配置config中的maxZoomLevel

updateCamera2D(top, right, keepZoom)

传入 top, right来更新, camera2D
Parameters:
Name Type Default Description
top float top值
right float right值
keepZoom boolean false 是否保持之前的zoom

updateFrustum(forceopt)

更新视锥
Parameters:
Name Type Attributes Default Description
force Boolean <optional>
false 更新当前相机的Maxtrix