File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * Sample React Native App
3+ * https://github.com/facebook/react-native
4+ * @flow
5+ */
6+
7+ import React , { Component } from 'react' ;
8+ import {
9+ StyleSheet ,
10+ View ,
11+ Platform ,
12+ TouchableHighlight ,
13+ Text ,
14+ Alert ,
15+ } from 'react-native' ;
16+ import {
17+ Workspace ,
18+ SMMapView ,
19+ Utility ,
20+ } from 'imobile_for_reactnative' ;
21+
22+ export default class App extends Component < { } > {
23+
24+ _onGetInstance = ( mapView ) => {
25+ this . mapView = mapView ;
26+ this . _addMap ( ) ;
27+ }
28+
29+ render ( ) {
30+ return (
31+ < View style = { styles . container } >
32+ < SMMapView style = { styles . map } onGetInstance = { this . _onGetInstance } />
33+ </ View >
34+ ) ;
35+ }
36+
37+ _addMap = ( ) => {
38+ var workspaceModule = new Workspace ( ) ;
39+ ( async function ( ) {
40+ this . workspace = await workspaceModule . createObj ( ) ;
41+ this . mapControl = await this . mapView . getMapControl ( ) ;
42+ this . map = await this . mapControl . getMap ( ) ;
43+
44+ var filePath = '' ;
45+ if ( Platform . OS === 'ios' ) {
46+ filePath = await Utility . appendingHomeDirectory ( '/Documents/China400.smwu' ) ;
47+ } else {
48+ filePath = await Utility . appendingHomeDirectory ( '/SampleData/China400/China400.smwu' ) ;
49+ }
50+
51+ var openWk = await this . workspace . open ( filePath ) ;
52+ await this . map . setWorkspace ( this . workspace ) ;
53+ var mapName = await this . workspace . getMapName ( 0 ) ;
54+ await this . map . open ( mapName ) ;
55+ await this . map . refresh ( ) ;
56+ } ) . bind ( this ) ( ) ;
57+ }
58+ }
59+
60+ const styles = StyleSheet . create ( {
61+ container : {
62+ flex : 1 ,
63+ justifyContent : 'center' ,
64+ alignItems : 'center' ,
65+ backgroundColor : '#F5FCFF' ,
66+ } ,
67+ map : {
68+ flex : 1 ,
69+ alignSelf : 'stretch' ,
70+ } ,
71+ button : {
72+ top :50 ,
73+ left :50 ,
74+ position :'absolute' ,
75+ flex :1 ,
76+ } ,
77+ highlight :{
78+ height :50 ,
79+ width :100 ,
80+ backgroundColor :'red' ,
81+ }
82+ } ) ;
You can’t perform that action at this time.
0 commit comments