UNPKG

imobile_for_javascript

Version:

iMobile for JavaScript,是SuperMap iMobile推出的一款基于React-Native框架的移动应用开发工具。基于该开发工具,用户可以使用JavaScript开发语言,开发出在Android和IOS操作系统下运行的原生移动GIS应用,入门门槛低,一次开发,处处运行。

72 lines (63 loc) 2.39 kB
import {NativeModules,Platform} from 'react-native'; let SC = NativeModules.JSSceneControl; import Scene from './Scene'; export default class SceneControl { 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); } } }