Remove a circle from Android Google Maps API v2 without clearing map

狂风中的少年 提交于 2019-12-04 16:03:35

问题


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);

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?


回答1:


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();
}



回答2:


Code could be useful.

drawnCircle = map.addCircle(circle);
drawnCircle.remove();



回答3:


Simplest way, you can use : circle.visible(false)



来源:https://stackoverflow.com/questions/15480997/remove-a-circle-from-android-google-maps-api-v2-without-clearing-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!