UNPKG

rn_supermap

Version:

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

142 lines (132 loc) 3.36 kB
/********************************************************************************* Copyright © SuperMap. All rights reserved. Author: Wang zihao E-mail: pridehao@gmail.com Description: iOS中该类只是一个概念虚类,实际功能由mapControl完成。 **********************************************************************************/ import { NativeModules, Platform } from 'react-native'; let MV = NativeModules.JSMapView; import MapControl from './MapControl.js'; import Point2D from './Point2D.js'; /** * @class MapView * @description 地图显示控件容器类。 */ export default class JSMapView { static NAVIGATION_STARTPOINT = "startpoint"; static NAVIGATION_DESTPOINT = "destpoint"; /** * 获取地图控件。 * @memberOf MapView * @returns {Promise.<MapControl>} */ async getMapControl() { try { var { mapControlId } = await MV.getMapControl(this._SMMapViewId); var mapControl = new MapControl(); mapControl._SMMapControlId = mapControlId; return mapControl; } catch (e) { console.error(e); } } /** * 在地图上添加一个点标记 * @memberOf MapView * @param {object} point2D - 点标记 * @param {string} pointName - 点标记名称 * @returns {Promise.<Point2D>} */ async addPoint(point2D, pointName) { try { var { eth_point2DId } = await MV.addPoint(this._SMMapViewId, point2D._SMPoint2DId, pointName); var point2D = new Point2D(); point2D._SMPoint2DId = eth_point2DId; return point2D; } catch (e) { console.error(e); } } /** * 刷新地图 * @memberOf MapView * @returns {Promise.<void>} */ async refresh() { try { await MV.refresh(this._SMMapViewId); } catch (e) { console.error(e); } } /** * 添加callout层 * @memberOf MapView * @param {object} callOut - callOut对象 * @param {string} pointName - 点名称 * @returns {Promise.<void>} */ async addCallOut(x, y, pointName) { try { await MV.addCallOut(x, y, pointName); } catch (e) { console.error(e); } } /** * 显示callout * @memberOf MapView * @returns {Promise.<void>} */ async showCallOut() { try { await MV.showCallOut(this._SMMapViewId); } catch (e) { console.error(e); } } async openWorkspace(info) { try { await MV.openWorkspace(info); } catch (e) { console.error(e); } } /** * 打开地图 * @param target index / name * @param viewEntire * @param center * @returns {Promise.<void>} */ async openMap(target, viewEntire = true, center = null) { try { if (typeof target === 'number') { await MV.openMapByIndex(target, viewEntire, center); } else { await MV.openMapByName(target, viewEntire, center); } } catch (e) { console.error(e); } } /** * * @param params * @param value index / name * @returns {Promise.<void>} */ async openDatasource(params, value) { try { if (typeof value === 'number') { value = value >= 0 ? value : -1 await MV.openDatasourceWithIndex(params, value); } else { value = value || '' await MV.openDatasourceWithName(params, value); } } catch (e) { console.error(e); } } }