Repository navigation
Expand file tree
/
Copy pathCallOut.js
More file actions
183 lines (172 loc) · 4.74 KB
/
Copy pathCallOut.js
File metadata and controls
183 lines (172 loc) · 4.74 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*********************************************************************************
Copyright © SuperMap. All rights reserved.
Author: Zihao Wang
E-mail: pridehao@gmail.com
Description:N/A
**********************************************************************************/
import {NativeModules} from 'react-native';
let C = NativeModules.JSCallOut;
/**
* @class Callout
* @description 点标注类,最多支持500条记录的显示。
* @property {number} TYPE(NONE) - 无对齐方式。
* @property {number} TYPE(LEFT) - 左对齐。
* @property {number} TYPE(TOP) - 上对齐。
* @property {number} TYPE(RIGHT) - 右对齐。
* @property {number} TYPE(BOTTOM) - 下对齐。
* @property {number} TYPE(CENTER) - 中心对齐。
* @property {number} TYPE(LEFTTOP) - 左上对齐。
* @property {number} TYPE(RIGHTTOP) - 右上对齐。
* @property {number} TYPE(LEFTBOTTOM) - 左下对齐。
* @property {number} TYPE(RIGHTBOTTOM) - 右下对齐。
*/
export default class CallOut {
/**
* 创建Callout对象
* @memberOf CallOut
* @param {object} mapControl
* @returns {Promise.<CallOut>}
*/
async createObj(mapCtrl,colorArr,alignment){
try{
if(arguments.length === 1){
var {_SMCalloutId} = await C.createObj(mapCtrl.mapControlId);
}else if(arguments.length === 3){
var {_SMCalloutId} = await C.createObjWithStyle(mapCtrl.mapControlId,colorArr,alignment);
}else{
throw new Error('input param number should be 1 or 3,please check your params');
}
var callout = new CallOut();
callout._SMCalloutId = _SMCalloutId;
return callout;
}catch (e){
console.error(e);
}
}
/**
* 在指定位置显示Callout
* @memberOf CallOut
* @param {object} point2D
* @returns {Promise.<boolean>}
*/
async showAtPoint2d(point2D){
try{
await C.showAtPoint2d(this._SMCalloutId,point2D.point2DId);
}catch (e){
console.error(e);
}
}
/**
* 在指定位置显示Callout
* @memberOf CallOut
* @param {number} x
* @param {number} y
* @returns {Promise.<boolean>}
*/
async showAtXY(x,y){
try{
await C.showAtXY(this._SMCalloutId,x,y);
}catch (e){
console.error(e);
}
}
/**
* 更新Callout标注位置
* @memberOf CallOut
* @param {object} point2D
* @returns {Promise.<boolean>}
*/
async updataPoint2d(point2D){
try{
await C.updataByPoint2d(this._SMCalloutId,point2D.point2DId);
}catch (e){
console.error(e);
}
}
/**
* 更新Callout标注位置
* @memberOf CallOut
* @param {number} x
* @param {number} y
* @returns {Promise.<boolean>}
*/
async updataXY(x,y){
try{
await C.updataByXY(this._SMCalloutId,x,y);
}catch (e){
console.error(e);
}
}
/**
* 设置Callout高度
* @memberOf CallOut
* @param {number} height
* @returns {Promise.<void>}
*/
async setHeight(height){
try{
await C.setHeight(this._SMCalloutId,height);
}catch (e){
console.error(e);
}
}
/**
* 设置Callout宽度
* @memberOf CallOut
* @param {number} width
* @returns {Promise.<void>}
*/
async setWidth(width){
try{
await C.setWidth(this._SMCalloutId,width);
}catch (e){
console.error(e);
}
}
static TYPE (type){
var value;
switch(type){
case 'NONE':
case 'none':
value = -1;
break;
case 'LEFT':
case 'left':
value = 0;
break;
case 'TOP':
case 'top':
value = 1;
break;
case 'RIGHT':
case 'right':
value = 2;
break;
case 'BOTTOM':
case 'bottom':
value = 3;
break;
case 'CENTER':
case 'center':
value = 4;
break;
case 'LEFTTOP':
case 'lefttop':
value = 5;
break;
case 'righttop':
case 'RIGHTTOP':
value = 6;
break;
case 'LEFTBOTTOM':
case 'leftbottom':
value = 7;
break;
case 'RIGHTBOTTOM':
case 'rightbottom':
value = 8;
break;
}
return value;
}
}