Repository navigation
Expand file tree
/
Copy pathdataSets.js
More file actions
executable file
·144 lines (136 loc) · 4.63 KB
/
Copy pathdataSets.js
File metadata and controls
executable file
·144 lines (136 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import React from 'react'
import { Image, StyleSheet, FlatList, TouchableOpacity, Text, View,} from 'react-native'
import { Container ,ListSeparator} from '../../components'
import NavigationService from '../NavigationService'
import { DatasetType } from 'imobile_for_javascript'
import { scaleSize } from '../../utils'
import {color,size} from '../../styles'
const point = require('../../assets/map/icon-dot.png')
const line = require('../../assets/map/icon-line.png')
const text = require('../../assets/map/icon-text.png')
const cad = require('../../assets/map/icon-cad.png')
const region = require('../../assets/map/icon-polygon.png')
export default class DataSets extends React.Component {
props: {
navigation: Object,
}
constructor(props) {
super(props)
const { params } = this.props.navigation.state
this.datasource = params.datasource
this.workspace = params.workspace
this.mapControl=params.mapControl
this.map = params.map
this.name = params.name
this.state = {
data: [
{name:'点',type:DatasetType.POINT,imageSize:'small'},
{name:'线',type:DatasetType.LINE},
{name:'面',type:DatasetType.REGION},
{name:'CAD',type:DatasetType.CAD},
{name:'文本',type:DatasetType.TEXT},
],
}
}
_tosetlayer = (w, m, t) => {
NavigationService.navigate('AddLayer', { workspace: w, map: m, type: t ,mapControl:this.mapControl,datasource:this.datasource})
}
_renderItem = ({ item }) => {
if (item.type === DatasetType.POINT) {
return (<TouchableOpacity onPress={() => this._tosetlayer(this.workspace, this.map,item.type)} style={styles.itemclick}>
<Image source={point} style={item.imageSize === 'small' ? styles.imageSmall : styles.image} />
<Text style={styles.rowTitle}>{item.name}</Text>
</TouchableOpacity>)
}
else if (item.type === DatasetType.LINE) {
return (<TouchableOpacity onPress={() => this._tosetlayer(this.workspace, this.map, item.type)} style={styles.itemclick}>
<Image source={line} style={item.imageSize === 'small' ? styles.imageSmall : styles.image} />
<Text style={styles.rowTitle}>{item.name}</Text>
</TouchableOpacity>)
}
else if (item.type === DatasetType.TEXT) {
return (<TouchableOpacity onPress={() => this._tosetlayer(this.workspace, this.map, item.type)} style={styles.itemclick}>
<Image source={text} style={item.imageSize === 'small' ? styles.imageSmall : styles.image} />
<Text style={styles.rowTitle}>{item.name}</Text>
</TouchableOpacity>)
}
else if (item.type === DatasetType.CAD) {
return (<TouchableOpacity onPress={() => this._tosetlayer(this.workspace, this.map, item.type)} style={styles.itemclick}>
<Image source={cad} style={item.imageSize === 'small' ? styles.imageSmall : styles.image} />
<Text style={styles.rowTitle}>{item.name}</Text>
</TouchableOpacity>)
}
else if (item.type === DatasetType.REGION ) {
return (<TouchableOpacity onPress={() => this._tosetlayer(this.workspace, this.map, item.type)} style={styles.itemclick}>
<Image source={region} style={item.imageSize === 'small' ? styles.imageSmall : styles.image} />
<Text style={styles.rowTitle}>{item.name}</Text>
</TouchableOpacity>)
}
else {
return null
}
}
_renderItemSeparatorComponent = () => {
return <ListSeparator />
}
_keyExtractor = (item, index) => {
return index
}
render() {
return (
<Container
ref={ref => this.container = ref}
headerProps={{
title: '选择图层类型',
navigation: this.props.navigation,
}}>
<View style={styles.top}/>
<FlatList
ItemSeparatorComponent={this._renderItemSeparatorComponent}
style={styles.container}
data={this.state.data}
renderItem={this._renderItem}
keyExtractor={this._keyExtractor}
/>
</Container>
)
}
}
const styles = StyleSheet.create({
item: {
color: '#1296db',
fontSize: 20,
// margin:10,
paddingLeft: scaleSize(20),
// textAlign:'center'
},
itemclick: {
flex: 1,
height: scaleSize(80),
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: scaleSize(30),
},
cantainer: {
flex: 1,
backgroundColor: color.background,
},
itemseparator: {
height: scaleSize(8),
},
top:{
height: scaleSize(1),
},
rowTitle: {
fontSize: size.fontSize.fontSizeMd,
marginLeft: scaleSize(30),
},
image: {
height: scaleSize(40),
width: scaleSize(40),
},
imageSmall: {
height: scaleSize(20),
width: scaleSize(20),
},
})