Quantcast
Channel: CSDN博客移动开发推荐文章
Viewing all articles
Browse latest Browse all 5930

高德地图--水波雷达动画

$
0
0
    private AMap aMap;
    private int minRadius = 100;
    private int maxRadius = 250;
    private int radius = minRadius;
    private int gap = 8;
    private int duration = 16;
    private List<Circle> listCircle = new ArrayList<>();

    /*雷达*/
    private void showRadar() {
        if (longClickLatlng != null) {
            /*Projection projection = aMap.getProjection();
            Point point = projection.toScreenLocation(longClickLatlng);*/

            clearCircle();
            // 绘制一个圆形 50-200
            final Circle circle = aMap.addCircle(new CircleOptions().center(longClickLatlng)
                    .radius(radius).strokeColor(Color.argb(100, 100, 149, 237))
                    .fillColor(Color.argb(100, 135, 206, 250)).strokeWidth(3));

            final Circle circle1 = aMap.addCircle(new CircleOptions().center(longClickLatlng)
                    .radius(radius-50).strokeColor(Color.argb(100, 100, 149, 237))
                    .fillColor(Color.argb(0, 135, 206, 250)).strokeWidth(3));

            final Circle circle2 = aMap.addCircle(new CircleOptions().center(longClickLatlng)
                    .radius(radius-100).strokeColor(Color.argb(100, 100, 149, 237))
                    .fillColor(Color.argb(0, 135, 206, 250)).strokeWidth(3));

            listCircle.add(circle);
            listCircle.add(circle1);
            listCircle.add(circle2);

            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (radius < maxRadius) {
                        radius = radius + gap;
                    } else {
                        radius = minRadius;
                    }
                    circle.setRadius(radius);
                    circle1.setRadius(radius-50);
                    circle2.setRadius(radius-100);
                    aMap.invalidate();

                    if (isMapLongCLick)
                        handler.postDelayed(this, duration);
                    else
                        clearCircle();
                }
            }, duration);

        }
    }

    private void clearCircle() {
        for (int i = 0; i < listCircle.size(); i++) {
            listCircle.get(i).remove();
            listCircle.remove(i);
        }
    }
作者:u010378579 发表于2017/3/14 18:09:44 原文链接
阅读:20 评论:0 查看评论

Viewing all articles
Browse latest Browse all 5930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>