绘制给定一组点在地图上Overylay(Android 2.1的)空的多边形

编程入门 行业动态 更新时间:2024-10-27 14:18:02
本文介绍了绘制给定一组点在地图上Overylay(Android 2.1的)空的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经设置了 N 点,我想提请使用这些点 n边多边形。

I've set of n points and I want to draw a n-sided polygon using these points.

我试图用android.graphics.path(请参见下文)。

I tried using android.graphics.path (please see below).

Path path = new Path(); Vertex currVtx; for (int j = 0; j < vertices.size(); j++) { currVtx = vertices.get(j); if (!currVtx.hasLatLong()) continue; Point currentScreenPoint = getScreenPointFromGeoPoint( currVtx, mapview); if (j == 0) path.moveTo(currentScreenPoint.x, currentScreenPoint.y); // vertex. else path.lineTo(currentScreenPoint.x, currentScreenPoint.y); }

目前,我得到一个固体(填充画布的颜色)的多边形与此code。有没有一种方法,我可以得到一个未填充的多边形。有一个替代 android.graphics.Path

Currently I'm getting a solid (filled with the color of the canvas) polygon with this code. Is there a way that I can get an unfilled polygon. There is an alternative to android.graphics.Path

感谢。

推荐答案

定义绘制对象:

Paint mPaint = new Paint(); mPaint.setStrokeWidth(2); //2 pixel line width mPaint.setColor(0xFF097286); //tealish with no transparency mPaint.setStyle(Paint.Style.STROKE); //stroked, aka a line with no fill mPaint.setAntiAlias(true); // no jagged edges, etc.

然后绘制路径有:

Then draw the path with:

yourCanvas.drawPath(path,mPaint);

您可以看一下油漆文档,但也有选项吨来控制它的绘制。

You can look up the paint documentation but there are tons of options to control how its drawn.

更多推荐

绘制给定一组点在地图上Overylay(Android 2.1的)空的多边形

本文发布于:2023-08-02 00:02:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1272890.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多边形   在地   图上   Overylay   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!