EasyMap平台-08-测量功能实现

一、概述

测量操作:长度、面积

(1)效果

(2)数据下载地址

链接:https://pan.baidu.com/s/1ggfytWZ 密码:nq0o

二、实现逻辑

前期基础数据加载过程(数据加载、许可设置)参见如下链接:

http://blog.youkuaiyun.com/weixin_37027518/article/details/79331487

设置地图动作具体实现:

//设置地图监听
        mMapView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()){
                    case MotionEvent.ACTION_DOWN:{

                    }break;
                    case MotionEvent.ACTION_UP:{
                        addOnePoint(motionEvent.getX(), motionEvent.getY());
                    }break;
                    case MotionEvent.ACTION_MOVE:{

                    }break;
                }
                return true;
            }
        });
 /**
     * 添加一个点
     * @param x
     * @param y
     */
    private void addOnePoint(float x, float y){
        //获得新的点
        Point point = new Point();
        point.x = (int)x;
        point.x = (int)y;
        Point2D point2D = mMapView.DeviceToMapPoint(point);
        lstMeasureDatas.add(point2D);
        if(measuerOpt == MEASUER_LINE){
            if(lstMeasureDatas.size() > 1){
                //显示
                Point2D[] arrDatas = (Point2D[]) lstMeasureDatas.toArray();
                GeoLine geometry = new GeoLine().Make(arrDatas);
                double result = geometry.GetLength(mMapView.GetPrjCoordSys());
                showGeometry(geometry);
            }
        }else if(measuerOpt == MEASUER_AREA){
            if(lstMeasureDatas.size() > 2){
                //显示
                Point2D[] arrDatas = (Point2D[]) lstMeasureDatas.toArray();
                GeoRegion geometry = new GeoRegion().Make(arrDatas);
                showGeometry(geometry);
            }
        }
    }
/**
     * 显示
     * @param geometry
     */
    public void showGeometry(Geometry geometry){
        if(geometry != null){
            Style style = new Style();
            style.fillForeColor = Color.RED;
            style.lineColor = Color.RED;
            style.lineWidth = Color.RED;
            mMapView.GetTrackingLayer().Add(geometry);
            mMapView.Refresh(true);
        }
    }

三、代码工程

https://github.com/junqinghaha/EasyMapDemos

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

简易生活520

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值