Skip to content

Commit fe51bb2

Browse files
committed
init isurface project
0 parents  commit fe51bb2

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

‎script/App.js‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
});

0 commit comments

Comments
 (0)