Repository navigation
Expand file tree
/
Copy pathSceneControl.js
More file actions
87 lines (77 loc) · 2.77 KB
/
Copy pathSceneControl.js
File metadata and controls
87 lines (77 loc) · 2.77 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
/*********************************************************************************
Copyright © SuperMap. All rights reserved.
Author: Wang zihao
E-mail: pridehao@gmail.com
**********************************************************************************/
import {NativeModules,Platform} from 'react-native';
let SC = NativeModules.JSSceneControl;
import Scene from './Scene';
/**
* @class SceneControl
* @description 三维场景控件。
*/
export default class SceneControl {
/**
* 获取场景对象。
* @memberOf SceneControl
* @returns {Promise.<Scene>}
*/
async getScene(){
try{
var {sceneId} = await SC.getScene(this.sceneControlId);
var scene = new Scene();
scene.sceneId = sceneId;
return scene;
}catch (e){
console.error(e);
}
}
async initWithViewCtrl(tag){
try{
if(Platform.OS === 'ios'){
await SC.initWithViewCtrl(this.sceneControlId,tag);
}
}catch (e){
console.error(e);
}
}
async setGestureDetector(handlers){
try{
if(handlers){
await SC.setGestureDetector(this.sceneControlId);
}else{
throw new Error("setGestureDetector need callback functions as first two argument!");
}
//差异化
if(Platform.OS === 'ios'){
/*
if(typeof handlers.longPressHandler === "function"){
nativeEvt.addListener("com.supermap.RN.JSMapcontrol.long_press_event",function (e) {
// longPressHandler && longPressHandler(e);
handlers.longPressHandler(e);
});
}
if(typeof handlers.scrollHandler === "function"){
nativeEvt.addListener('com.supermap.RN.JSMapcontrol.scroll_event',function (e) {
scrollHandler && scrollHandler(e);
});
}
*/
}else{
if(typeof handlers.longPressHandler === "function"){
DeviceEventEmitter.addListener("com.supermap.RN.JSMapcontrol.long_press_event",function (e) {
// longPressHandler && longPressHandler(e);
handlers.longPressHandler(e);
});
}
if(typeof handlers.scrollHandler === "function"){
DeviceEventEmitter.addListener('com.supermap.RN.JSMapcontrol.scroll_event',function (e) {
scrollHandler && scrollHandler(e);
});
}
}
}catch (e){
console.error(e);
}
}
}