移除谷歌Android地图API V2了一圈,但不清除地图地图、但不、移除、Android

2023-09-07 15:45:11 作者:感情白痴

我画一个圆圈在我的地图是这样的:

I am drawing a circle on my map like this:

CircleOptions circle=new CircleOptions();
circle.center(centre);
circle.strokeColor(0xFFFFA420);
circle.strokeWidth(2f);
circle.fillColor(0x11FFA420);
circle.radius(radius);
myMap.addCircle(circle);

要删除这个圈子里,我打电话 myMap.clear(),其中删除添加到地图中的所有项目。现在的问题是如何消除这个圈子没有在地图上删除所有其他项目?

To remove this circle, I am calling myMap.clear(), which removes all items added to the map. The question is how to remove this circle without removing all others items on the map?

推荐答案

尝试调用remove()在圆形对象,你得到回addCircle()。例如:

Try calling remove() on the Circle object that you get back from addCircle(). For Example

Circle mapCircle;
mapCircle = mapView.addCircle(circleOption);

当你想删除

现在调用此方法

Now when you want to remove Call this method

if(mapCircle!=null){
  mapCircle.remove();
}