首页 / 浏览问题 / 移动GIS / 问题详情
imobile for reactNative 报许可不存在
77EXP 2018年10月18日

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初始化设置许可路径的代码

1个回答

首先确保许可放入设备的存储里,许可文件放入目录/SuperMap/License/里,其次确保设备的存储有读写权限,AndroidManifest.xml文件里检查下是否有权限,最后如果检查都没有问题,依然不行,那么建议在真机设备上使用,目前我个人没没有在模拟器上用过。
1,430EXP 2018年10月18日
1、默认的许可路径不是Supermap/License下,默认是从iTablet/license 下获取的
许可文件必须,放入/Supermap/License/目录下
...