绘制一定半径的圆圈在Android的地图视图 [英] Draw circle of certain radius on map view in android

查看:688
本文介绍了绘制一定半径的圆圈在Android的地图视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要画在地图上查看了一圈。我希望用户输入半径和为半径的我要在地图上显示循环。从那以后,我要显示标记上那圈一些地方。

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 locations on that circle.

我知道如何在地图视图显示标记上。

I know how to display markers on on map view.

请帮我画圆形地图视图,并显示在那个圈子界桩。

please help me to draw circle on map view and to show markers on that circle boundary.

这对我很重要,我试图找到在互联网的提示,但我不能做this.please帮我........

It is very important for me , I am trying to find hints in Internet but I am not able to do this.please help me........

在此先感谢。

推荐答案

在实施的 ItemizedOverlay ,做类似的方法画圆的OnDraw 方法

In the implementation of the ItemizedOverlay, do something like the method drawCircle from the onDraw method

protected void drawCircle(Canvas canvas, Point curScreenCoords) {
    curScreenCoords = toScreenPoint(curScreenCoords);
    int CIRCLE_RADIUS = 50;
    // Draw inner info window
    canvas.drawCircle((float) curScreenCoords.x, (float) curScreenCoords.y, CIRCLE_RADIUS, getInnerPaint());
    // if needed, draw a border for info window
    canvas.drawCircle(curScreenCoords.x, curScreenCoordsy, CIRCLE_RADIUS, getBorderPaint());
}

private Paint innerPaint, borderPaint;

public Paint getInnerPaint() {
    if (innerPaint == null) {
        innerPaint = new Paint();
        innerPaint.setARGB(225, 68, 89, 82); // gray
        innerPaint.setAntiAlias(true);
    }
    return innerPaint;
}

public Paint getBorderPaint() {
    if (borderPaint == null) {
        borderPaint = new Paint();
        borderPaint.setARGB(255, 68, 89, 82);
        borderPaint.setAntiAlias(true);
        borderPaint.setStyle(Style.STROKE);
        borderPaint.setStrokeWidth(2);
    }
    return borderPaint;
}

@Override
protected void onDraw(Canvas canvas) {
    Point p = new Point();
    for(OverlayItem item : items) {
        drawCircle(canvas, getProjection().toPixels(item.getPoint(), p));
    }
}

这篇关于绘制一定半径的圆圈在Android的地图视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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