GraphicCtrl的使用importReact, {useState, useEffect}from'react';import{View,Text,ScrollView,StyleSheet}from'react-native';import{Button,List,Switch}from'@ant-design/react-native';import{GraphicCtrl,GraphicLayerCtrl,LayerManager,MapManager,MapView}from'@haibalai/react-native-arcgis';import{connect}from'react-redux';importWidthDrawerfrom'../../../../components/WithDrawer/index';import{Colors}from'react-native/Libraries/NewAppScreen';constMapId='baseMap';constGraphicLayerId='graphic點';constMapImageLayerId='水閘-MapImageLayer';constFeatureLayerId='水閘-featurelayer';constMapImageLayerIds= ['水閘-MapImageLayer','原水管線-MapImageLayer','海堤-MapImageLayer','海洋環(huán)境區(qū)劃-MapImageLayer',];constFeatureLayerIds= ['水閘-featurelayer','原水管線-featurelayer','原水管線-featurelayer','海洋環(huán)境區(qū)劃-featurelayer',];constGraphicLayerIds= ['graphic點','graphic線','graphic面'];constGeoX=1.2664272368526626e7;constGeoY=2595847.2157473154;constGeo4490X=113.78868474700005;constGeo4490Y=22.693641836999973;constlayerName ='test';constgraphicStrs = [{geometry: {type:'point',x:113.868676,y:22.487838,z:0,spatialReference: {wkid:4326}}},{geometry: {type:'point',x:113.768676,y:22.587838,z:0,spatialReference: {wkid:4326}}},{geometry: {type:'point',x:113.868676,y:22.587838,z:0,spatialReference: {wkid:4326}}},];letgraphicId ='';letgraphicIds = [''];constsymbolStr = {angle:0,color: [40,135,255,255],outline: {color: [14,98,230,255],style:'solid',type:'esriSLS',width:1.5},size:9,style:'circle',type:'esriSMS',xoffset:0,yoffset:0,};constselected =true;constvisible =true;constgeometryStr ='';constattributesStr ='';constzIndex =1;/** sideBar組件*@param{*} renderCb renderCb是一個函數(shù), 每次觸發(fā)并且向里面?zhèn)髦?對象)垒玲,content組件就以sideBarData的屬性去接受*/constSideBar= ({renderCb, Home}: any) => {const[content, changeContent] =useState('');const[errorContent, changeErrorContent] =useState('');const[singleMapImageLayerStatus, setSingleMapImageLayerStatus] =useState(false);const[multiMapImageLayerStatus, setMultiMapImageLayerStatus] =useState(false);const[singleFeatureLayerStatus, setSingleFeatureStatus] =useState(false);const[multiFeatureLayerStatus, setMultiFeatureLayerStatus] =useState(false);const[singleGraphicLayerStatus, setSingleGraphicLayerStatus] =useState(false);const[multiGraphicLayerStatus, setMultiGraphicLayerStatus] =useState(false);useEffect(() =>{renderCb({content, errorContent});}, [content, errorContent, renderCb]);constgetGeoX= () => {letcoordinate =Home.coordinate;if(coordinate ==='4490') {returnGeo4490X;}else{returnGeoX;}};constgetGeoY= () => {letcoordinate =Home.coordinate;if(coordinate ==='4490') {returnGeo4490Y;}else{returnGeoY;}};constonSwitchSingleMapImageLayer= (e: boolean) => {if(e) {LayerManager.showLayer(MapId,MapImageLayerId);}else{LayerManager.hideLayer(MapId,MapImageLayerId);}setSingleMapImageLayerStatus(e);};constonSwitchMultiMapImageLayer= (e: boolean) => {if(e) {LayerManager.showLayers(MapId,MapImageLayerIds);}else{LayerManager.hideLayers(MapId,MapImageLayerIds);}setMultiMapImageLayerStatus(e);};constonSwitchSingleFeatureLayer= (e: boolean) => {if(e) {LayerManager.showLayer(MapId,FeatureLayerId);}else{LayerManager.hideLayer(MapId,FeatureLayerId);}setSingleFeatureStatus(e);};constonSwitchMultiFeatureLayer= (e: boolean) => {if(e) {LayerManager.showLayers(MapId,FeatureLayerIds);}else{LayerManager.hideLayers(MapId,FeatureLayerIds);}setMultiFeatureLayerStatus(e);};constonSwitchSingleGraphicLayer= (e: boolean) => {setSingleGraphicLayerStatus(e);//加載單個圖層的graphics};constonSwitchMultiGraphicLayer= (e: boolean) => {setMultiGraphicLayerStatus(e);//加載多個圖層的graphics};constonAddGraphics= () => {GraphicLayerCtrl.addGraphics(MapId, layerName, graphicStrs).then((r: any) =>{graphicIds = r;graphicId = graphicIds[0];changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonRemoveGraphic= () => {GraphicCtrl.removeGraphic(graphicId).then((r: any) =>{changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonRemoveGraphics= () => {GraphicCtrl.removeGraphics(graphicIds).then((r: any) =>{changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonGetSymbol= () => {GraphicCtrl.getSymbol(graphicId).then((r: any) =>{changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonSetSymbol= () => {GraphicCtrl.setSymbol(graphicId, symbolStr).then((r: any) =>{changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonIsSelected= () => {GraphicCtrl.isSelected(graphicId).then((r: any) =>{changeErrorContent('');changeContent(r.toString());}).catch((e: any) =>{changeErrorContent(e);});};constonSetSelected= () => {GraphicCtrl.setSelected(graphicId, selected).then((r: any) =>{changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonIsVisible= () => {GraphicCtrl.isVisible(graphicId).then((r: any) =>{changeErrorContent('');changeContent(r.toString());}).catch((e: any) =>{changeErrorContent(e);});};constonSetVisible= () => {GraphicCtrl.setVisible(graphicId, visible).then((r: any) =>{changeErrorContent('');changeContent(r);}).catch((e: any) =>{changeErrorContent(e);});};constonGetAttributes= () => {
React Native for Arcgis 地圖開發(fā) GraphicCtrl (十三)
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人蜀铲,你說我怎么就攤上這事边琉。” “怎么了记劝?”我有些...
- 文/不壞的土叔 我叫張陵变姨,是天一觀的道長。 經(jīng)常有香客問我厌丑,道長定欧,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任怒竿,我火速辦了婚禮砍鸠,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘耕驰。我一直安慰自己爷辱,他們只是感情好,可當我...
- 文/花漫 我一把揭開白布朦肘。 她就那樣靜靜地躺著饭弓,像睡著了一般。 火紅的嫁衣襯著肌膚如雪媒抠。 梳的紋絲不亂的頭發(fā)上弟断,一...
- 文/蒼蘭香墨 我猛地睜開眼锉桑,長吁一口氣:“原來是場噩夢啊……” “哼排霉!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起民轴,我...
- 正文 年R本政府宣布胁艰,位于F島的核電站,受9級特大地震影響智蝠,放射性物質(zhì)發(fā)生泄漏腾么。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一杈湾、第九天 我趴在偏房一處隱蔽的房頂上張望解虱。 院中可真熱鬧,春花似錦毛秘、人聲如沸饭寺。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至限煞,卻和暖如春抹恳,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背署驻。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- //針對arcgis的featurelayer 封裝FeatureLayerCtrl和案例 importReact...
- 針對TileLayer的封裝 importReact,{useState,useEffect}from'react...
- 關(guān)于矢量切片VectorTiledLayerCtrl importReact,{useState,useEffec...
- ClusterLayerCtrl聚合圖層調(diào)用封裝 importReact, {useEffect, useStat...
- RasterLayerCtrl的封裝調(diào)用 importReact, {useState, useEffect}fr...