微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在android中的地图视图中绘制某个半径的圆

我想在地图视图上画一个圆.我想要用户输入半径,对于那个半径,我必须在地图上显示圆.之后,我必须在该圈子的某些位置显示标记.

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

请帮助我在地图视图上绘制圆形,并在该圆形边界上显示标记.

这对我来说非常重要,我试图在互联网上找到提示,但我无法做到这一点.请帮助我……..

提前致谢..

解决方法

itemizedoverlay的实现中,从onDraw方法中执行类似于drawCircle的方法
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,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,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));
    }
}

原文地址:https://www.jb51.cc/android/312557.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐