在地图覆盖层上给定一组点绘制一个空多边形(Android 2.1)
我设置了 n 个点,我想使用这些点绘制一个 n 边多边形。
我尝试使用 android.graphics.path (请参见下文)。
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);
}
目前我正在使用此代码获得一个实心(填充画布的颜色)多边形。有没有办法获得未填充的多边形。有一个替代 android.graphics.Path
谢谢。
I've set of n
points and I want to draw a n-sided
polygon using these points.
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);
}
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
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
定义一个 Paint 对象:
然后使用以下方法绘制路径:
您可以查找绘图文档,但有大量选项可以控制其绘制方式。
Define a Paint object:
Then draw the path with:
You can look up the paint documentation but there are tons of options to control how its drawn.