问题描述
我正在Google地图应用程序上工作,在该应用程序中我在地图上绘制了多边形,但没有显示具有半透明颜色的多边形作为填充色。 以下是它的代码
int strokeColor = 0xffff0000;
int fillColor = 0x44ff0000;
Polygon polygon = map.addPolygon(new PolygonOptions()
.add(new LatLng(fences.get(northWestPoint).lat,
fences.get(northWestPoint).lng),
new LatLng(fences.get(northEastPoint).lat,
fences.get(northEastPoint).lng),
new LatLng(fences.get(southEastPoint).lat,
fences.get(southEastPoint).lng),
new LatLng(fences.get(southWestPoint).lat,
fences.get(southWestPoint).lng),
new LatLng(fences.get(northWestPoint).lat,
fences.get(northWestPoint).lng))
.strokeColor(strokeColor)
.strokeWidth(2)
.fillColor(fillColor));
这是渲染地图时的输出:
1楼
该代码似乎是正确的,也许问题出在调用顺序上? 在我的代码中,我这样做:
public PolygonOptions buildPolygonOptions() {
return new PolygonOptions().fillColor(fillColor).strokeColor(strokeColor).strokeWidth(strokeWidth).zIndex(zIndex);
}
我不知道这是否是真正的动机(我应该没有道理),但是值得一试。 此外,为了进行测试,填充和笔触使用两种不同的颜色,因此您可以更好地看到一种在哪里,另一种在哪里。