1、关联官网的https://github.com/iMobileforJavaScript/imobile_for_reactnative
2、视频教程http://support.supermap.com.cn/product/VedioPlay.aspx?id=186
3、自己的代码
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import {
Workspace,
SMMapView,
Utility
} from 'imobile_for_reactnative';
export default class App extends Component<{}> {
render() {
return (
<View style={styles.container}>
<SMMapView ref="mapView" style={styles.map}
onGetInstance={this._onGetInstance}/>
</View>
);
}
//Required funtion for obtaining the MapView object.
_onGetInstance = (mapView) => {
this.mapView = mapView;
this._addMap();
}
/**
* 初始化地图 Function for initiating the Map
* @private
*/
_addMap = () => {
try {
//创建workspace模块对象
//Create workspace object
var workspaceModule = new Workspace();
//加载工作空间等一系列打开地图的操作
//Operations for loading workspace and opening map
(async function () {
try {
this.workspace = await workspaceModule.createObj();
var filePath = '';
if (Platform.OS == 'ios') {
}else{
filePath = await Utility.appendingHomeDirectory('/SampleData/City/Changchun.smwu');
}
console.log('地图数据路径:' + filePath);
await this.workspace.open(filePath);
this.mapControl = await this.mapView.getMapControl();
this.map = await this.mapControl.getMap();
await this.map.setWorkspace(this.workspace);
var mapName = await this.workspace.getMapName(0);
await this.map.open(mapName);
await this.map.refresh();
} catch (e) {
console.error(e);
}
}).bind(this)();
} catch (e) {
console.error(e);
}
}
}
模拟器上运行后 报错 许可不存在。 我已经在模拟器的更目录创建了SuperMap/License/
这个问题怎么解决? 是不是还缺少Environment初始化设置许可路径的代码