在我的应用程序中,我在用户周围显示一个圆圈。当用户移动时,圆圈也必须相应移动。现在,为了执行该任务,我在 onLocationChange
方法中调用以下函数:
public void drawCircleOnMap(GoogleMap googleMap, double lat, double lng) {
if(circle != null) {
circle.remove();
}
circle = googleMap.addCircle(new CircleOptions().center(new LatLng(lat, lng)).radius(CIRCLE_RADIUS)
.fillColor(Color.argb(100,88, 214, 141)).strokeColor(Color.GREEN));
}
但是问题是,每次更新后,圆圈都会闪烁。我想删除自身然后创建一个新的。让它窒息的最好方法是什么?
最佳答案
您只需要设置 center 属性,而不是在位置更新时删除并再次绘制圆圈,只需设置 center 属性,如下所示
circle.setCenter(newlatlng)
关于android - 如何更新 Google map 上的 Circle 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47494179/