IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> React Native for Arcgis 地图开发 GraphicLayer (十二) -> 正文阅读

[移动开发]React Native for Arcgis 地图开发 GraphicLayer (十二)

GraphicLayer 的封装调用

import React, {useEffect, useState} from ‘react’;
import {ScrollView, StyleSheet, Text, View} from ‘react-native’;
import {Button, List, Switch} from ‘@ant-design/react-native’;
import {
FeatureLayerCtrl,
Graphic,
GraphicLayerCtrl,
LayerManager,
MapManager,
MapView,
RenderingMode,
} from ‘@haibalai/react-native-arcgis’;
import {connect} from ‘react-redux’;
import WidthDrawer from ‘…/…/…/…/components/WithDrawer/index’;
const MapId = ‘baseMap’;
const EditFeatureLayerId3857 = ‘水闸-featurelayer’;
const EditFeatureLayerId4490 = ‘水闸-featurelayer’;
const FeatureLayerIds3857 = [
‘水闸-featurelayer’,
‘原水管线-featurelayer’,
‘原水管线-featurelayer’,
‘海洋环境区划-featurelayer’,
];
const FeatureLayerIds4490 = [
‘水闸-featurelayer’,
‘原水管线-featurelayer’,
‘原水管线-featurelayer’,
‘海洋环境区划-featurelayer’,
];
const layerName = ‘test’;
let graphicId = ‘’;
let graphicIds = [‘’];
const graphicStr = {geometry: {type: ‘point’, x: 113.868676, y: 22.587838, z: 0, spatialReference: {wkid: 4326}}};
const graphicStrs = [
{
geometry: {type: ‘point’, x: 113.868676, y: 22.487838, z: 0, spatialReference: {wkid: 4326}},
symbol: {
type: ‘picture-marker’,
url: ‘https://static.arcgis.com/images/Symbols/Shapes/BlackStarLargeB.png’,
width: 20,
height: 20,
opacity: 1,
xOffset: 20,
yOffset: 20,
angle: 45,
},
},
{
geometry: {type: ‘point’, x: 113.768676, y: 22.587838, z: 0, spatialReference: {wkid: 4326}},
symbol: {
type: ‘picture-marker’,
url:
‘data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAACNklEQVRYR2NkGOSAcZC7j2HUgZTG0GgIjoYgpSFAqX6MNPj/lBqKTT8jIyNZ6X3oOjDu/g6qBOQiRQ+wOVQPwRHnQCKiQ5iRkfEdujqcaZDaIUjIga///LAXY+U8RHcHEnJYtqg+gzmPJMOj358K5Nn4Jw46B4YIqjL4CSgzPPj1aYEiO3/igDkQlpthDih6fJDhzZ/vDDY80gxporoMj359PiXPzmc+aBw46/VlhiNfnjKosQsw1EhZMLz88+21BCu32KBx4OHPTxlmv7nMwMfExjBF3onh278/f7mZWVkGjQPf/P7OUPTkINg9M+VdGDiZwG7DKGpoXszAQgQ9DYLEYemwScqKQYGdjwFbUTOgDoSlQ3xFzYA6EJYO8RU1A+pAWDrEV9TQzYH4ahR8Rc2gcCC+omZQOBAUurjajUPXgSBfPf31haHy6RGsyadd2oZBmo2HUGMFLE+KOegtb7x9kn///zNkPdoLqoZQHMLFxMIwTc6ZgYnIfhAp5hB0IMwlj39+vinDxqO24t1Nhm0f76M40ItfkSFCSJ3hya8vt2TZedXxBSOl5uDsCj778y1Ykplzzd///xhWvb/FcOTzM7A7bHilGMIE1RiYGZkYnv/9HiLFwrUWnwMpNQdvX/X+j08zFdh507A54MHPz7MUOfjSiUmElJhDsDP9/M9Xr7///k3iZ2KXBznm47+fD5mZmPIkWbi3EeM4mBpyzSHoQFIcQQu1ow6kNFRHQ3DYhyAAemZ0OAVReT8AAAAASUVORK5CYII=’,
width: 20,
height: 20,
opacity: 0.8,
angle: 45,
},
},
{geometry: {type: ‘point’, x: 113.868676, y: 22.587838, z: 0, spatialReference: {wkid: 4326}}},
];
const graphicPolygon = {
geometry: {
hasM: true,
hasZ: true,
rings: [
[
[12675573.621750494, 2588252.9668057943],
[12676290.673814166, 2586536.7438337253],
[12677536.698711697, 2585725.6521551451],
[12678100.936401144, 2584879.2956209742],
[12679194.146924447, 2584620.6866799775],
[12680310.867351478, 2584268.0381240733],
[12681286.528356148, 2584550.1569687966],
[12680169.807929117, 2586043.035855459],
[12679464.510817308, 2587183.2661862168],
[12679476.265769171, 2588711.4099284699],
[12679358.716250537, 2589969.1897778627],
[12676737.361984979, 2589287.4025697806],
[12675573.621750494, 2588252.9668057943],
],
],
spatialReference: {wkid: 102100, latestWkid: 3857},
},
symbol: {color: [164, 255, 102, 200], style: ‘solid’, type: ‘esriSFS’},
};
const visible = true;
const labelEnable = true;
const scaleSymbols = true;
const opacity = 0.5;
const maxScale = 5000;
const minScale = 500;
/** sideBar组件
*

@param {*} renderCb renderCb是一个函数, 每次触发并且向里面传值(对象),content组件就以sideBarData的属性去接受
*/
const SideBar = ({renderCb, Home}: any) => {
const [content, changeContent] = useState(‘’);
const [errorContent, changeErrorContent] = useState(‘’);
const [singleFeatureLayerStatus, setSingleFeatureStatus] = useState(false);
const [multiFeatureLayerStatus, setMultiFeatureLayerStatus] = useState(false);
const [PopupEnabled, setPopupEnabled] = useState(false);
const [LabelsEnabled, setLabelsEnabled] = useState(false);
const [ScaleSymbols, setScaleSymbols] = useState(false);
useEffect(() => {
renderCb({content, errorContent});
}, [content, errorContent, renderCb]);
const getNewFeautureLayerId = () => {
return ‘’;
};
const getNewFeautureLayerUrl = () => {
return ‘’;
};
const getLayerId = () => {
let coordinate = Home.coordinate;
if (coordinate === ‘4490’) {
return EditFeatureLayerId4490;
} else {
return EditFeatureLayerId3857;
}
};
const getLayerIds = () => {
let coordinate = Home.coordinate;
if (coordinate === ‘4490’) {
return FeatureLayerIds4490;
} else {
return FeatureLayerIds3857;
}
};
const getAddFeature = () => {
let graphic: Graphic = {
geometry: {},
attributes: {},
};
return graphic;
};
const getAddFeatures = () => {
let graphics = [];
let graphic: Graphic = {
geometry: {},
attributes: {},
};
graphics.push(graphic);
return graphics;
};
const getDeleteFeature = () => {
let graphic: Graphic = {
geometry: {},
attributes: {},
};
return graphic;
};
const getDeleteFeatures = () => {
let graphics = [];
let graphic: Graphic = {
geometry: {},
attributes: {},
};
graphics.push(graphic);
return graphics;
};
const getUpdateFeature = () => {
let graphic: Graphic = {
geometry: {},
attributes: {},
};
return graphic;
};
const getUpdateFeatures = () => {
let graphics = [];
let graphic: Graphic = {
geometry: {},
attributes: {},
};
graphics.push(graphic);
return graphics;
};
const getDefinitionExpression = () => {
return ‘’;
};
const getRender = () => {
return {};
};
const onSwitchSingleFeatureLayer = (e: boolean) => {
if (e) {
LayerManager.showLayer(MapId, getLayerId());
} else {
LayerManager.hideLayer(MapId, getLayerId());
}
setSingleFeatureStatus(e);
};
const onSwitchMultiFeatureLayer = (e: boolean) => {
if (e) {
LayerManager.showLayers(MapId, getLayerIds());
} else {
LayerManager.hideLayers(MapId, getLayerIds());
}
setMultiFeatureLayerStatus(e);
};
const onSwitchLabelsEnabled = (value: boolean) => {
FeatureLayerCtrl.setLabelsEnabled(MapId, getLayerId(), value)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
setLabelsEnabled(value);
};
const onSwitchPopupEnabled = (value: boolean) => {
FeatureLayerCtrl.setPopupEnabled(MapId, getLayerId(), value)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
setPopupEnabled(value);
};
const onSwitchScaleSymbols = (value: boolean) => {
FeatureLayerCtrl.setScaleSymbols(MapId, getLayerId(), value)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
setScaleSymbols(value);
};
const onAddGraphic = () => {
console.log(‘graphic图形为:’ + graphicPolygon);
GraphicLayerCtrl.addGraphic(MapId, layerName, graphicPolygon)
.then((r: any) => {
graphicId = r;
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onAddGraphics = () => {
GraphicLayerCtrl.addGraphics(MapId, layerName, graphicStrs)
.then((r: any) => {
graphicIds = r;
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onRemoveGraphic = () => {
GraphicLayerCtrl.removeGraphic(graphicId)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onRemoveGraphics = () => {
GraphicLayerCtrl.removeGraphics(graphicIds)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onRemoveGraphicsLayer = () => {
GraphicLayerCtrl.removeGraphicLayer(MapId, layerName)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onClearGraphics = () => {
GraphicLayerCtrl.clearGraphics(MapId, layerName)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetCount = () => {
GraphicLayerCtrl.getCount(MapId, layerName)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetSelectedGraphics = () => {
GraphicLayerCtrl.getSelectedGraphics(MapId, layerName)
.then((r: any) => {
graphicIds = r;
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onIsVisible = () => {
GraphicLayerCtrl.isVisible(MapId, layerName)
.then((r: any) => {
changeErrorContent(‘’);
changeContent?;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onSetVisible = () => {
GraphicLayerCtrl.setVisible(MapId, layerName, visible)
.then((r: any) => {
changeErrorContent(‘’);

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2022-11-05 00:39:30  更:2022-11-05 00:40:54 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 17:28:18-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码