React Native for Arcgis 地图开发 TileLayer 切片(八)
针对TileLayer的封装
import React, {useState, useEffect} from 'react';
import {View, Text, ScrollView, StyleSheet, Clipboard} from 'react-native';
import {Button, List, Switch} from '@ant-design/react-native';
import {TiledLayerCtrl, LayerManager, MapManager, MapView} from '@haibalai/react-native-arcgis';
import {connect} from 'react-redux';
import WidthDrawer from '../../../../components/WithDrawer/index';
const MapId = 'baseMap';
const EditLayerId3857 = 'BP_BADXT_SZ_20191202_GRID_3857';
const EditLayerId4490 = 'BP_BADXT_SZ_20191202_GRID_4490';
/** sideBar组件
*
@param {*} renderCb renderCb是一个函数, 每次触发并且向里面传值(对象),content组件就以sideBarData的属性去接受
*/
const SideBar = ({renderCb, Home}: any) => {
const [baseMapTDTStatus, setBaseMapTDTStatus] = useState(false);
const [content, changeContent] = useState('');
const [errorContent, changeErrorContent] = useState('');
const [singleTiledLayerStatus, setSingleTiledLayerStatus] = useState(false);
useEffect(() => {
renderCb({content, errorContent});
}, [content, errorContent, renderCb]);
const getLayerId = () => {
let coordinate = Home.coordinate;
if (coordinate === '4490') {
return EditLayerId4490;
} else {
return EditLayerId3857;
}
};
const onSwitchBaseMapTDTStatus = (e: any) => {
if (!e) {
MapManager.switchBaseMap(MapId, '矢量1202')
.then((r: any) => {
changeErrorContent('');
changeContent('' + r);
Clipboard.setString('' + r);
})
.catch((