import React from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, Image, TouchableOpacity, View, DeviceEventEmitter } from 'react-native'; import comStyles from '../assets/styles/com-style'; import { setMapConfig } from '../redux/actiions'; import { colors, onePx, px2dp, toast } from '../utils'; import { BjTypeMapConfig } from '../utils/types'; import redux from './../redux/store'; interface Props { } interface State { mapLayerType: 'outdoor' | 'satellite', mapConfig: BjTypeMapConfig } export default class MapTool extends React.Component { constructor(props: Props) { super(props); }; public _state = redux.getState(); public readonly state: Readonly = { mapLayerType: 'satellite', mapConfig: this._state.mapConfig }; switchMapType(type) { let { mapConfig } = this.state; mapConfig.layerType = type; this.saveMapConfig(mapConfig) }; switchRiverShow() { let { mapConfig } = this.state; mapConfig.showRiver = !mapConfig.showRiver; if (mapConfig.showRiver) { mapConfig.showVe = false; mapConfig.showVeLabel = false; } this.saveMapConfig(mapConfig) } switchVeShow() { let { mapConfig } = this.state; mapConfig.showVe = !mapConfig.showVe; if (mapConfig.showVe) { mapConfig.showRiver = false; mapConfig.showRiverLabel = false; } this.saveMapConfig(mapConfig) } switchResearchPlotShow() { let { mapConfig } = this.state; mapConfig.showResearchPlot = !mapConfig.showResearchPlot; this.saveMapConfig(mapConfig) } switchResearchLineShow() { let { mapConfig } = this.state; mapConfig.showResearchLine = !mapConfig.showResearchLine; this.saveMapConfig(mapConfig) } switchRiverLabelShow() { let { mapConfig } = this.state; mapConfig.showRiverLabel = !mapConfig.showRiverLabel; this.saveMapConfig(mapConfig) } switchVeLabelShow() { let { mapConfig } = this.state; mapConfig.showVeLabel = !mapConfig.showVeLabel; this.saveMapConfig(mapConfig) } saveMapConfig(mapConfig) { this.setState({ mapConfig }) DeviceEventEmitter.emit("map-config-change", { mapConfig }) redux.dispatch(setMapConfig(mapConfig)) } switchResearchDataShow() { let { mapConfig } = this.state; mapConfig.showResearchData = !mapConfig.showResearchData; this.saveMapConfig(mapConfig) } switchTrackShow() { let { mapConfig } = this.state; mapConfig.showTrackLine = !mapConfig.showTrackLine; this.saveMapConfig(mapConfig) } switchGridShow() { let { mapConfig } = this.state; mapConfig.showGridLine = !mapConfig.showGridLine; this.saveMapConfig(mapConfig) } switchResearchDataLabelShow() { let { mapConfig } = this.state; mapConfig.showResearchDataLabel = !mapConfig.showResearchDataLabel; this.saveMapConfig(mapConfig) } render() { const { mapConfig } = this.state;; return ( 选择底图 { mapConfig.layerType === 'outdoor' ? 普通地图 : this.switchMapType('outdoor')} style={styles.mapTypeBox}> 普通地图 } { mapConfig.layerType === 'satellite' ? 卫星地图 : this.switchMapType('satellite')} style={styles.mapTypeBox}> 卫星地图 } 添加图层 调查边界 toast("暂无图层数据")} style={styles.optionBtn}> 调查网格 toast("暂无图层数据")} style={styles.optionBtn} > {/* 湖泊水系 Lab */} {/* 步行路线 toast("暂不支持取消")} style={[styles.optionBtn]}> */} {/* 植被类型 Lab */} {/* 样地预设 样线预设 */} 调查数据 Lab {/* 轨迹记录 */} ) } } const styles = StyleSheet.create({ row: { width: '100%', height: px2dp(42), flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', paddingHorizontal: px2dp(12), paddingTop: px2dp(6) }, rowTitle: { fontSize: 14, color: colors.blackColor }, box: { width: '100%', backgroundColor: '#fff' }, col: { width: '100%', flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'center' }, optionRow: { width: px2dp(232), height: px2dp(72), flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', borderTopColor: '#d2d2d2', borderTopWidth: onePx, }, optionRowLeft: { height: '100%', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', }, mapTypeBoxContainer: { width: '100%', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: px2dp(12), paddingVertical: px2dp(12) }, mapTypeBox: { position: 'relative', width: px2dp(112), justifyContent: 'center', alignItems: 'center', }, mapTypeImgBox: { width: px2dp(112), height: px2dp(88), position: 'relative', borderWidth: 1, borderColor: 'rgba(0,0,0,0)', overflow: 'hidden', marginBottom: px2dp(6), borderRadius: px2dp(2) }, mapTypeImg: { width: px2dp(112), height: px2dp(88), borderColor: colors.borderColor, borderWidth: onePx, }, mapCheckedRow: { position: 'absolute', left: 0, bottom: 0, width: '100%', height: px2dp(18), zIndex: 999, backgroundColor: colors.themeColor, justifyContent: 'center', alignItems: 'center' }, mapCheckedIcon: { width: px2dp(18), height: px2dp(18), tintColor: '#FFF' }, rowIcon1: { width: px2dp(44), height: px2dp(44), borderRadius: px2dp(22) }, rowIcon: { width: px2dp(48), height: px2dp(48), }, optionBtn: { height: '100%', justifyContent: 'center', alignItems: 'center', paddingHorizontal: px2dp(12) }, optionRightIcon: { width: px2dp(28), height: px2dp(28), tintColor: '#909399' }, iconBorder: { width: px2dp(48), height: px2dp(48), borderRadius: px2dp(24), borderWidth: 2, borderColor: '#909399', justifyContent: 'center', alignItems: 'center', marginHorizontal: px2dp(6) } })