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

3

25

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?

Divide answered 18/3, 2013 at 15:47 Comment(0)
D
46

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();
}
Dirac answered 18/3, 2013 at 15:58 Comment(0)
P
8

Code could be useful.

drawnCircle = map.addCircle(circle);
drawnCircle.remove();
Previous answered 18/4, 2014 at 4:27 Comment(1)
adding a null check on drawCircle will be perfectLeitao
T
0

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

Traverse answered 18/6, 2018 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.