Simo
Simo

Reputation: 1230

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

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?

Upvotes: 25

Views: 15403

Answers (3)

Kamal Artly
Kamal Artly

Reputation: 1

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

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006924

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

Upvotes: 46

Selman Kahya
Selman Kahya

Reputation: 185

Code could be useful.

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

Upvotes: 8

Related Questions