Android Google Maps平滑更改圆半径 [英] Android google maps change circle radius smoothly

查看:150
本文介绍了Android Google Maps平滑更改圆半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张需要画圆的地图.问题是圆应该是可调整大小的(例如,我有一个seekbar,并且基于seekbar值,我应该看看我的圆大小(半径)如何变化).我知道如何绘制圆,但是我无法想象如何使圆动态调整大小.有可能吗?

I have a map where I need to draw circle. Problem is that circle should be resizable (for example I have an seekbar and based on seekbar values I should see how my circle size (radius) is changing). I know how to draw a circle but I can't imagine how to make circle dynamically resizable. Is it possible?

在此处编辑如何将圆添加到地图中

EDIT here how I add circle to my map

@Override
    public void onMapClick(LatLng latLng) {
        mMap.addCircle(new CircleOptions()
                .center(latLng)
                .radius(100)
                .strokeWidth(0)
                .fillColor(0x66aaaFFF));
    }

如您所见,每次单击地图时,我都会将半径设置为100.但是,半径应该改变,圆环应该根据搜寻杆的值平滑绘制

as you can see I set radius to 100 each time when i click on map. However radius should change and circle should be drawn smoothly based on seekbar values

推荐答案

您可以使用OnSeekBarChangeListeneronProgressChanged上的setRadius方法,使圆半径在大小上可动态调整:

You can make it dinamycally resizable changing the circle radius using the setRadius method on the onProgressChanged of the OnSeekBarChangeListener:

private Circle circle;

circle = mMap.addCircle(new CircleOptions()
    .center(new LatLng(52, 5))
    .fillColor(Color.RED)
    .radius(100));

AppCompatSeekBar progress = (AppCompatSeekBar) findViewById(R.id.progress);
progress.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        circle.setRadius(progress);
    }

    @Override
    public void onStartTrackingTouch(final SeekBar seekBar) {
    }

    @Override
    public void onStopTrackingTouch(final SeekBar seekBar) {
    }
});

但是,有一个尚未解决的已知Google Maps相关错误(问题5707:错误:圆形填充闪烁在快速的圆弧半径和中心更新处发生),导致填充闪烁.

However there is a related unresolved known Google Maps bug (Issue 5707: Bug: Circle filling flickers on fast circle radius and center update) causing filling flickering.

更新:

问题5707已于2016年10月24日解决

这篇关于Android Google Maps平滑更改圆半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆