Repository navigation
Expand file tree
/
Copy pathScene.js
More file actions
167 lines (156 loc) · 4.59 KB
/
Copy pathScene.js
File metadata and controls
167 lines (156 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*********************************************************************************
Copyright © SuperMap. All rights reserved.
Author: Will
E-mail: pridehao@gmail.com
**********************************************************************************/
import {NativeModules} from 'react-native';
let S = NativeModules.JSScene;
import Workspace from './Workspace';
/**
* @class Scene
* @description 三维场景类。
*/
export default class Scene {
/**
* 设置工作空间
* @memberOf Scene
* @param {object} workspace - 工作空间对象
* @returns {Promise.<void>}
*/
async setWorkspace(workspace){
try{
await S.setWorkspace(this._SMSceneId,workspace._SMWorkspaceId);
}catch (e){
console.error(e);
}
}
/**
* 返回三维场景所关联的工作空间。
* @memberOf Scene
* @returns {Promise.<Workspace>}
*/
async getWorkspace(){
try{
var {workspaceId} = await S.setWorkspace(this._SMSceneId);
var workspace = new Workspace();
workspace._SMWorkspaceId = workspaceId;
return workspace;
}catch (e){
console.error(e);
}
}
/**
* 根据提供的场景名称打开三维地图
* @memberOf Scene
* @param {string} [iserverUrl,] sceneName [,password] - 只有一个参数时: 场景名称。
* 两个参数时:(iserverUrl,sceneName) iserverUrl - 三维服务URL地址;sceneName - 场景名称。
* 三个参数时:(iserverUrl,sceneName,passWord ) iserverUrl - 三维服务URL地址;sceneName - 场景名称; passWord - 场景密码,默认密码是“supermap”。
* @returns {Promise.<boolean>}
*/
async open(){
try{
if(arguments.length == 1){
var {opened} = await S.open(this._SMSceneId,arguments[0]);
return opened;
}else if(arguments.length == 2){
var {opened} = await S.open2(this._SMSceneId,arguments[0],arguments[1]);
return opened;
}else if(arguments.length == 3){
var {opened} = await S.open3(this._SMSceneId,arguments[0],arguments[1],arguments[2]);
return opened;
}else{
throw new Error("Scene opened Error: Please input 1-3 arguments.read the specification please")
}
}catch (e){
console.error(e);
}
}
/**
* 根据经纬度范围显示场景。
* @memberOf Scene
* @param {object} visibleBounds - rectangle2D对象,包含如下属性:{top:--,left:--,right:--,bottom:--}
* @returns {Promise.<void>}
*/
async ensureVisible(visibleBounds){
try{
await S.ensureVisible(this._SMSceneId,visibleBounds);
}catch (e){
console.error(e);
}
}
/**
* 刷新三维场景
* @memberOf Scene
* @returns {Promise.<void>}
*/
async refresh(){
try{
await S.refresh(this._SMSceneId);
}catch (e){
console.error(e);
}
}
/**
* 平移三维场景。
* @memberOf Scene
* @param offsetLongitude - 指定的经向平移距离。
* @param offsetLatitude - 指定的纬向平移距离。
* @returns {Promise.<void>}
*/
async pan(offsetLongitude,offsetLatitude){
try{
await S.pan(this._SMSceneId,offsetLongitude,offsetLatitude);
}catch (e){
console.error(e);
}
}
/**
* 全幅显示此场景。
* @memberOf Scene
* @returns {Promise.<void>}
*/
async viewEntire(){
try{
await S.viewEntire(this._SMSceneId);
}catch (e){
console.error(e);
}
}
/**
* 根据给定的缩放比例,对三维地图场景进行缩放操作
* @memberOf Scene
* @param {double} ratio - 指定的缩放比例数值。
* @returns {Promise.<void>}
*/
async zoom(ratio){
try{
await S.zoom(this._SMSceneId,ratio);
}catch (e){
console.error(e);
}
}
/**
* 关闭当前场景
* @memberOf Scene
* @returns {Promise.<void>}
*/
async close(){
try{
await S.close(this._SMSceneId);
}catch (e){
console.error(e);
}
}
/**
* 释放该对象所占用的资源
* @memberOf Scene
* @returns {Promise.<void>}
*/
async dispose(){
try{
await S.dispose(this._SMSceneId);
}catch (e){
console.error(e);
}
}
}