Draw circle of certain radius on map view in Android

后端 未结 6 776
一向
一向 2020-12-08 11:55

I want to draw a circle on map view. I want the user to input the radius and for that radius I have to show circle on map. After that I have to display markers on some locat

6条回答
  •  囚心锁ツ
    2020-12-08 12:28

    If you put the following code in your overlay's draw method, it will draw a circle radius 20 px in the centre of your mapView

    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
    long when) {
        ....
        ....
    
        Paint lp4;
        lp4 = new Paint();
        lp4.setColor(Color.RED);
        lp4.setAntiAlias(true);
        lp4.setStyle(Style.STROKE);
        canvas.drawCircle(mapView.getWidth()/2, mapView.getHeight()/2, 20, lp4);
    
        ....
        ....
        mapView.invalidate();
    }
    

    You should be able to adapt it to suit your needs

提交回复
热议问题