![](/img/trans.png)
[英]Android: Algorithm to set zoom and location of Google map given a sets a points
[英]Drawing an empty polygon given a set of points on a Map Overylay (Android 2.1)
我設置了n
個點,我想用這些點繪制一個n-sided
多邊形。
我嘗試使用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
還有一個替代方案
謝謝。
定義Paint對象:
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.
然后繪制路徑:
yourCanvas.drawPath(path,mPaint);
你可以查看油漆文檔,但有很多選項可以控制它的繪制方式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.