2014-10-18 133 views
0

我設法在地圖上繪製了一個多邊形。代碼我用:地圖上的多個多邊形

private void drawPolygons() { 

    PolygonOptions polygonOptions = new PolygonOptions(); 
    polygonOptions.addAll(arrayPolygon); 
    polygonOptions.strokeColor(Color.CYAN); 
    polygonOptions.strokeWidth(4); 
    polygonOptions.fillColor(Color.CYAN); 
    Polygon polygon = googleMap.addPolygon(polygonOptions); 

} 

我想繪製另一個。我想是這樣的:

private void drawPolygons() { 

    PolygonOptions polygonOptions = new PolygonOptions(); 
    polygonOptions.addAll(arrayPolygon); 
    polygonOptions.addAll(arrayPolygonSecond); 
    polygonOptions.strokeColor(Color.CYAN); 
    polygonOptions.strokeWidth(4); 
    polygonOptions.fillColor(Color.CYAN); 
    Polygon polygon = googleMap.addPolygon(polygonOptions); 

} 

這兩個經緯度數組剛剛搞砸了(來自兩個陣列頂點得到了連接)。我需要將這兩個多邊形分開。

任何幫助將不勝感激。感謝advace。

回答

1

找到解決方案。我必須做兩個分開的功能。這裏是代碼:

private void drawPolygons() { 

    PolygonOptions polygonOptions = new PolygonOptions(); 
    polygonOptions.addAll(arrayPolygonOne); 
    polygonOptions.strokeColor(Color.CYAN); 
    polygonOptions.strokeWidth(4); 
    polygonOptions.fillColor(Color.CYAN); 
    Polygon polygon = googleMap.addPolygon(polygonOptions); 

} 

private void drawPolygonsOne() { 

    PolygonOptions polygonOptions = new PolygonOptions(); 
    polygonOptions.addAll(arrayPolygonOne); 
    polygonOptions.strokeColor(Color.CYAN); 
    polygonOptions.strokeWidth(4); 
    polygonOptions.fillColor(Color.CYAN); 
    Polygon polygon = googleMap.addPolygon(polygonOptions); 

}