Multiple Polygon On Map

前端 未结 1 1886
情书的邮戳
情书的邮戳 2021-01-17 06:15

how to make multiple polygon on Google Map I am using

List data = new Array List();

but its create only o

相关标签:
1条回答
  • 2021-01-17 06:30

    You can define a common method to draw polygon on google maps like this:

    public PolygonOptions addPolygon(ArrayList < LatLng > arg) {
    
        LatLng[] data = arg.toArray();
        PolygonOptions polygonOptions;
    
        for (int i = 0; i <= data.length; i++) {
            polygonOptions = new PolygonOptions();
            polygonOptions.add(data[i], data[i + 1], data[i + 2])).strokeColor(Color.RED).strokeWidth(2);
            polygonOptions.fillColor(Color.parseColor("#51000000"));
            return polygonOptions;
        }
    }
    

    and then add it to your GoogleMap like this:

    yourGoogleMap.addPolygon(addPolygon(data));
    
    0 讨论(0)
提交回复
热议问题