首页 / 浏览问题 / 移动GIS / 问题详情
iMobileforReactNative加载3D数据
1EXP 2018年06月27日

使用产品:iMobile for ReactNative@1.6.0  操作系统:win7 x64

数据类型:.swmu

问题详细描述:加载3维本地数据场景是,只显示地球,没有加载3维数据(2维地图已验证)

代码如下:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {
  Workspace,
  SMSceneView,
  Utility
} from 'imobile_for_reactnative';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  _onGetInstance = (sceneControl) => {
    this.sceneControl = sceneControl;
    this._addScene();
  }
  _addScene = () => {
    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') {
            filepath = await Utility.appendingHomeDirectory('/Docmuments/Shanghai.smwu')
          } else {
            filepath = await Utility.appendingHomeDirectory('/SuperMap/demo/CBD.smwu')
          }
          console.log('filepath', filepath)
          var openMk = await this.workspace.open(filepath)
          console.log('openMk', openMk)
          this.scene = await this.sceneControl.getScene()
          await this.scene.setWorkspace(this.workspace)
          var sceneName = await this.workspace.getSceneName(0)
          console.log('sceneName', sceneName)
          await this.scene.open(sceneName)
          await this.scene.refresh()
          await this.scene.viewEntire()
          // this.mapControl = await this.sceneView.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);
    }
  }

  render() {
    return (
      <View style={styles.container}>
        <SMSceneView style={styles.map} onGetScene={this._onGetInstance}/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F500FF',
  },
  map: {
    width: 100,
    height: 200,
    backgroundColor: '#ed2211'
  },
});

1个回答

您好!目前移动端只支持在场景中加载场景缓存,不能直接去读取数据源,所以需要先切场景缓存,然后加载场景缓存!
663EXP 2018年06月28日
大神可以指导下不
您需要指导什么?是不知道怎么切场景缓存?
...