【发布时间】:2016-03-28 14:20:33
【问题描述】:
我想在两个标记周围的 GoogleMaps 上应用一种色调。到目前为止,我得到的唯一可行的解决方案是在地图上实际绘制多边形
map.addPolygon(new PolygonOptions()
.addAll(createRectangle(SphericalUtil.interpolate(markerData.getStartPoint(), markerData.getEndPoint(), CENTER_POINT_INTERPOLATE), 90, 45))
.strokeColor(Color.TRANSPARENT)
.fillColor(resources.getColor(R.color.tint_black_40)));
其中createRectangle() 是来自https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/src/main/java/com/example/mapdemo/PolygonDemoActivity.java 的方法
private List<LatLng> createRectangle(LatLng center, double halfWidth, double halfHeight) {
return Arrays.asList(new LatLng(center.latitude - halfHeight, center.longitude - halfWidth),
new LatLng(center.latitude - halfHeight, center.longitude + halfWidth),
new LatLng(center.latitude + halfHeight, center.longitude + halfWidth),
new LatLng(center.latitude + halfHeight, center.longitude - halfWidth),
new LatLng(center.latitude - halfHeight, center.longitude - halfWidth));
}
【问题讨论】:
-
那么,你需要用半透明的颜色覆盖整个地图吗?
标签: android google-maps