React Native for Arcgis 地图开发 MapImageLayer (六)

针对MapImageLayer 的封装demo 案例

MapImageLayerCtrl

import React, {useEffect, useState} from 'react';
import {Clipboard, ScrollView, StyleSheet, Text, View} from 'react-native';
import {Button, List, Switch} from '@ant-design/react-native';
import {ImageFormat, LayerManager, MapImageLayerCtrl, MapManager, MapView} from '@haibalai/react-native-arcgis';
import {connect} from 'react-redux';
import WidthDrawer from '../../../../components/WithDrawer/index';

const MapId = 'baseMap';
// const MapImageLayerId3857 = '易涝点-MapServer';
// const MapImageLayerId4490 = '雨水口-MapImageLayer';
const MapImageLayerId3857 = '排水渠道-MapImageLayer';
// const MapImageLayerId3857 = '二级水源保护区';
const MapImageLayerId4490 = '排水渠道-MapImageLayer';

/** sideBar组件
*

@param {*} renderCb renderCb是一个函数, 每次触发并且向里面传值(对象),content组件就以sideBarData的属性去接受
@param Home
*/
const SideBar = ({renderCb, Home}: any) => {
const [content, changeContent] = useState('');
const [errorContent, changeErrorContent] = useState('');
const [singleMapImageLayerStatus, setMapImageLayerStatus] = useState(false);
const [PopupEnabled, setPopupEnabled] = useState(false);
const [LabelsEnabled, setLabelsEnabled] = useState(false);
const [ScaleSymbols, setScaleSymbols] = useState(false);
useEffect(() => {
renderCb({content, errorContent, changeContent, changeErrorContent});
}, [content, errorContent, renderCb]);
const getLayerId = () => {
let coordinate = Home.coordinate;
if (coordinate === '4490') {
return MapImageLayerId4490;
} else {
return MapImageLayerId3857;
}
};
const getRender = () => {
return {
field1: 'type',
fieldDelimiter: ',',
type: 'uniqueValue',
uniqueValueInfos: [
{
label: 'GS',
symbol: {
color: [235, 0, 0, 255],
style: 'esriSLSSolid',
type: 'esriSLS',
width: 1,
},
value: 'GS',
},
{
label: 'HS',
symbol: {
color: [0, 191, 77, 255],
style: 'esriSLSSolid',
type: 'esriSLS',
width: 1,
},
value: 'HS',
},
{
label: 'WS',
symbol: {
color: [255, 0, 135, 255],
style: 'esriSLSSolid',
type: 'esriSLS',
width: 1,
},
value: 'WS',
},
{
label: 'YS',
symbol: {
color: [0, 0, 255, 255],
style: 'esriSLSSolid',
type: 'esriSLS',
width: 1,
},
value: 'YS',
},
],
};
};
const getDefinitionExpression = () => {
return '';
};
const onSwitchVectorTiledLayerStatus = (e: boolean) => {
if (e) {
LayerManager.showLayer(MapId, getLayerId());
} else {
LayerManager.hideLayer(MapId, getLayerId());
}
setMapImageLayerStatus(e);
};
const onSwitchLabelsEnabled = (value: boolean) => {
MapImageLayerCtrl.setLabelsEnabled(MapId, getLayerId(), value)
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
setLabelsEnabled(value);
};
const onSwitchPopupEnabled = (value: boolean) => {
MapImageLayerCtrl.setPopupEnabled(MapId, getLayerId(), value)
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
setPopupEnabled(value);
};
const onSwitchScaleSymbols = (value: boolean) => {
MapImageLayerCtrl.setScaleSymbols(MapId, getLayerId(), value)
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
setScaleSymbols(value);
};
const onGetGeodatabaseVersion = (value: boolean) => {
MapImageLayerCtrl.getGeodatabaseVersion(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetImageFormat = (value: boolean) => {
MapImageLayerCtrl.getImageFormat(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetMapServiceInfo = (value: boolean) => {
MapImageLayerCtrl.getMapServiceInfo(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetDefinitionExpression = (value: boolean) => {
MapImageLayerCtrl.getDefinitionExpression(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetRefreshInterval = (value: boolean) => {
MapImageLayerCtrl.getRefreshInterval(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetRequestConfiguration = (value: boolean) => {
MapImageLayerCtrl.getRequestConfiguration(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetRenderer = (value: boolean) => {
MapImageLayerCtrl.getRenderer(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
Clipboard.setString('' + r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetId = (value: boolean) => {
MapImageLayerCtrl.getId(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetUri = (value: boolean) => {
MapImageLayerCtrl.getUri(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetSubUri = (value: boolean) => {
MapImageLayerCtrl.getSubUri(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent(r);
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onIsLabelsEnabled = (value: boolean) => {
MapImageLayerCtrl.isLabelsEnabled(MapId, getLayerId())
.then((r: any) => {
changeErrorContent('');
changeContent('' + r);
})
 更多参考 https://xiaozhuanlan.com/topic/7894205316
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
React Native是一种流行的跨平台移动应用开发框架,它可以让开发者使用React的语法和组件开发iOS和Android应用。以下是关于React Native开发指南的一些要点: 首先,需要掌握JavaScript和React的基础知识,因为React Native使用的是JavaScript语言。理解React的工作原理和基本概念,例如组件、状态和属性,对于React Native开发至关重要。 其次,熟悉React Native的核心组件和API。React Native提供了许多内置的组件和API,例如视图组件、文本组件、按钮组件等。理解这些组件和API的用法和特性,是构建React Native应用的基础。 接着,学习如何使用Flexbox布局来设计和排列React Native应用中的组件。Flexbox是一种用于布局元素的弹性盒模型,可以帮助开发者有效地管理应用界面的布局和风格。 然后,了解如何在React Native中处理用户交互和导航。React Native提供了处理点击事件和手势操作的手段,也提供了导航组件和路由库来实现页面之间的导航和切换。 此外,掌握调试React Native应用的技巧和工具也是非常重要的。React Native提供了一些调试工具,例如React Native Developer Tools和Reactotron,可以帮助开发者追踪和修复应用中的错误和问题。 最后,了解React Native的性能优化技巧和最佳实践也是必要的。因为React Native是使用JavaScript来执行应用逻辑和界面绘制的,所以在处理大数据量和复杂逻辑时需要注意性能方面的优化。 总之,熟悉JavaScript和React基础知识,掌握React Native的核心组件和API,学习flexbox布局和用户交互处理,掌握调试和性能优化技巧,将有助于开发者顺利地使用React Native构建跨平台移动应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值