首页 > 其他分享 >React Native for Arcgis 地图开发 LocationDisplayCtrl (十四)

React Native for Arcgis 地图开发 LocationDisplayCtrl (十四)

时间:2022-11-05 14:03:29浏览次数:51  
标签:const changeErrorContent MapId React Arcgis import LocationDisplayCtrl any


定位展示LocationDisplayCtrl 封装

import React, {useState, useEffect} from ‘react’;
import {View, Text, ScrollView, StyleSheet, DeviceEventEmitter} from ‘react-native’;
import {Button, List, Switch} from ‘@ant-design/react-native’;
import {
LocationCtrl,
MapManager,
MapView,
LocationDisplayCtrl,
PictureMarkerSymbol,
SimpleMarkerSymbol,
} from ‘@haibalai/react-native-arcgis’;
import {connect} from ‘react-redux’;
import WidthDrawer from ‘…/…/…/…/components/WithDrawer/index’;
const DefaultIcon = require(‘…/…/…/…/image/defaultIcon.jpeg’);
const MapId = ‘baseMap’;
const DefineSymbol: PictureMarkerSymbol = {
type: ‘picture-marker’,
width: 15,
height: 15,
url: DefaultIcon,
};
const DefineAccuracySymbol: SimpleMarkerSymbol = {
type: ‘simple-marker’,
style: ‘circle’,
color: ‘rgba(8,255,4,0.7)’,
size: 10,
};
/** sideBar组件
*f@param {*} renderCb renderCb是一个函数, 每次触发并且向里面传值(对象),content组件就以sideBarData的属性去接受
*/
const SideBar = ({renderCb, Home}: any) => {
const [content, changeContent] = useState(‘’);
const [errorContent, changeErrorContent] = useState(‘’);
const [locationDisplayVisible, setSingleMapImageLayerStatus] = useState(false);
useEffect(() => {
renderCb({content, errorContent});
}, [content, errorContent, renderCb]);
useEffect(() => {
console.log(‘’ + DefaultIcon, ‘symbol测试’);
}, []);
const onSwitchLocationDisplayStatus = (e: boolean) => {
LocationDisplayCtrl.setVisible(MapId, e);
setSingleMapImageLayerStatus(e);
};
const onGetSymbol = () => {
LocationDisplayCtrl.getSymbol(MapId)
.then((r: any) => {
console.log(JSON.stringify®);
changeErrorContent(‘’);
changeContent(‘’ + r);
})
.catch((e: any) => {
changeErrorContent(‘’ + e);
});
};
const onSetSymbol = () => {
LocationDisplayCtrl.setSymbol(MapId, DefineSymbol)
.then((r: any) => {
changeErrorContent(‘’);
changeContent®;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onGetAccuracySymbol = () => {
LocationCtrl.getAccuracySymbol(MapId)
.then((r: any) => {
changeErrorContent(‘’);
changeContent®;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onSetAccuracySymbol = () => {
LocationDisplayCtrl.setAccuracySymbol(MapId, DefineAccuracySymbol)
.then((r: any) => {
changeErrorContent(‘’);
changeContent®;
})
.catch((e: any) => {
changeErrorContent(e);
});
};
const onZoomToCurrent = () => {
LocationDisplayCtrl.zoomToCurrent(MapId)
.then((r: any) => {
changeErrorContent(‘’);
changeContent®;
})
.catch((e: any) => {
changeErrorContent(e);

React Native for Arcgis 地图开发 LocationDisplayCtrl (十四) - 小专栏


标签:const,changeErrorContent,MapId,React,Arcgis,import,LocationDisplayCtrl,any
From: https://blog.51cto.com/u_15142957/5825948

相关文章

  • web3-react基本用法
    背景:web3真会玩,除了web3js,etherjs外,又搞出来一个web3-react,看不懂原来是知识盲区。 唤起metamask只需要一个activate方法const{activate}=useWeb3React();cons......
  • react组件传值
    1.父传子1.1父组件准备数据,父组件通过属性age直接传递给子组件父importReact,{useState}from'react'importChildsfrom'./Childs'exportdefaultfunctio......
  • 前端框架学习react还是vue?
    究竟如何正确使用?作为小白的我们从何学起比较好?带着一系列问题来看看吧。这篇主要介绍:1、从出身背景、优势、缺点、适合场景、开发模式、实践情况进行对比2、相似之处......
  • React Markdown Documentation Generator All In One
    ReactMarkdownDocumentationGeneratorAllInOneSSGhttps://github.com/topics/static-site-generatornext.jshttps://github.com/vercel/next.jsgatsbyhttps:......
  • react生命周期(详细版)
    首先生命周期分为三个阶段:挂载:已经插入真实dom渲染(更新):正在被重新渲染卸载:已经移出真实dom一、挂载:在组件实例被创建并插入到dom中时,生命周期调用顺序......
  • ArcGIS JS API 添加要素图层 点击时获取图层属性
    //需要引入:"esri/layers/FeatureLayer"模块//要素图层被点击时弹出图层属性的模板定义{为字段}varTuCeng03TC={"title":"ID:{objectid}",......
  • 细说React组件性能优化
    React组件性能优化最佳实践React组件性能优化的核心是减少渲染真实DOM节点的频率,减少VirtualDOM比对的频率。如果子组件未发生数据改变不渲染子组件。组件卸载前......
  • React-Hook最佳实践
    ReactHook新出现背景类组件的问题复用组件状态难,高阶组件+渲染属性providerscustomers,等一堆工具都是为了解决这个问题,但是造成了很严重的理解成本和组件嵌套地狱......
  • 详解React的Transition工作原理原理
    Transition使用姿势Transition是react18引入的新概念,用来区分紧急和非紧急的更新。紧急的更新,指的是一些直接的用户交互,如输入、点击等;非紧急的更新,指的是UI界面......
  • 通俗易懂的React事件系统工作原理
    前言React为我们提供了一套虚拟的事件系统,这套虚拟事件系统是如何工作的,笔者对源码做了一次梳理,整理了下面的文档供大家参考。在React事件介绍中介绍了合成事件对象以......