• React Native for Arcgis 地图开发 MeasureCtrl (十六)


    移动端MeasureCtrl 测量工具

    import React, {useEffect, useState} from ‘react’;
    import {DeviceEventEmitter, ScrollView, StyleSheet, Text, View, Clipboard} from ‘react-native’;
    import {Button, List} from ‘@ant-design/react-native’;
    import {MapManager, MapView, MeasureCtrl} from ‘@haibalai/react-native-arcgis’;
    import {connect} from ‘react-redux’;
    import WidthDrawer from ‘…/…/…/…/components/WithDrawer/index’;
    import {MeasureEventType} from ‘…/…/…/…/…/nativeModules/core/MeasureEventType’;
    const MapId = ‘baseMap’;
    const TextSymbol = {
    angle: 0,
    backgroundColor: ‘#ffffff’,
    borderLineColor: ‘#ff0000’,
    borderLineSize: 0,
    color: ‘green’,
    font: {decoration: ‘none’, family: ‘宋体’, size: 9.75, style: ‘normal’, weight: ‘normal’},
    // haloColor: ‘#0000ff’,
    // haloSize: 0,
    horizontalAlignment: ‘left’,
    kerning: false,
    type: ‘text’,
    verticalAlignment: ‘middle’,
    xoffset: 6,
    yoffset: 12,
    };
    const PolygonSymbol = {color: [200, 0, 0, 125], style: ‘solid’, type: ‘esriSFS’};
    const PolylineSymbol = {color: [14, 200, 230, 255], style: ‘solid’, type: ‘esriSLS’, width: 4};
    const PointSymbol = {
    angle: 0,
    color: ‘#ff00ff’,
    outline: {color: [14, 98, 230, 255], style: ‘solid’, type: ‘esriSLS’, width: 1.5},
    size: 9,
    style: ‘circle’,
    type: ‘simple-marker’,
    xoffset: 0,
    yoffset: 0,
    };
    const LastPointSymbol = {
    angle: 0,
    color: [228, 71, 64, 255],
    outline: {color: [255, 255, 0, 255], style: ‘solid’, type: ‘esriSLS’, width: 1.5},
    size: 9,
    style: ‘circle’,
    type: ‘esriSMS’,
    xoffset: 0,
    yoffset: 0,
    };
    /** sideBar组件
    *

    @param {*} renderCb renderCb是一个函数, 每次触发并且向里面传值(对象),content组件就以sideBarData的属性去接受
    */
    const SideBar = ({renderCb, Home}: any) => {
    const [content, changeContent] = useState(‘’);
    const [errorContent, changeErrorContent] = useState(‘’);
    const [ListenerId, setListenerId] = useState(‘’);
    useEffect(() => {
    renderCb({content, errorContent});
    }, [content, errorContent, renderCb]);
    const onClearAll = () => {
    MeasureCtrl.clearAll(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onAddAreaListener = () => {
    MeasureCtrl.removeAllListeners(MapId, MeasureEventType.onArea)
    .then((r: any) => {
    console.log(r, ‘removeAllListeners成功’);
    })
    .catch((e: any) => {
    console.log(e, ‘removeAllListeners失败’);
    });
    MeasureCtrl.addListener(MapId, MeasureEventType.onArea)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    setListenerId®;
    DeviceEventEmitter.removeAllListeners(MeasureEventType.onArea);
    DeviceEventEmitter.addListener(MeasureEventType.onArea, r => {
    changeContent®;
    });
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onAddLengthListener = () => {
    MeasureCtrl.removeAllListeners(MapId, MeasureEventType.onLength);
    MeasureCtrl.addListener(MapId, MeasureEventType.onLength)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    setListenerId®;
    DeviceEventEmitter.removeAllListeners(MeasureEventType.onLength);
    DeviceEventEmitter.addListener(MeasureEventType.onLength, r => {
    changeContent®;
    });
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onRemoveListener = () => {
    MeasureCtrl.removeListener(MapId, ListenerId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onMeasureLength = () => {
    MeasureCtrl.measureLength(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onMeasureArea = () => {
    MeasureCtrl.measureArea(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onDispose = () => {
    MeasureCtrl.dispose(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onDoBack = () => {
    MeasureCtrl.doBack(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onGetTextSymbol = () => {
    MeasureCtrl.getTextSymbol(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    Clipboard.setString®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onGetPolygonSymbol = () => {
    MeasureCtrl.getPolygonSymbol(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    Clipboard.setString®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onGetPolylineSymbol = () => {
    MeasureCtrl.getPolylineSymbol(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    Clipboard.setString®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onGetPointSymbol = () => {
    MeasureCtrl.getPointSymbol(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    Clipboard.setString®;
    })
    .catch((e: any) => {
    changeErrorContent(e);
    });
    };
    const onGetLastPointSymbol = () => {
    MeasureCtrl.getLastPointSymbol(MapId)
    .then((r: any) => {
    changeErrorContent(‘’);
    changeContent®;
    Clipboard.setString®;
    })

  • 相关阅读:
    记录一个在写项目中遇到的Maven依赖无法导入的问题
    redis常识
    mobileNet v2 paper笔记
    【算法训练营】 - ⑨ 贪心算法
    【PPT】NET Conf China 2022,主题:C#在iNeuOS工业互联网操作系统的开发及应用
    图片系列(6)不同版本上 Bitmap 内存分配与回收原理对比
    Shell脚本文本三剑客之Sed
    如何隐藏自己的代码(很酷)
    ElasticSearch7.3学习(十九)---- deep paging
    Linux线程控制
  • 原文地址:https://blog.csdn.net/haibalai2009/article/details/127848756