shehzy
shehzy

Reputation: 2281

Removing a polyline from google maps

Is it possible to remove a polyline from google maps through its id? Actually I have to draw a polyline in one activity and in a specific case have to remove it in the second activity, I trid to pass that polyline through intent but couldn't succeed, I was able to pass that polyline's id, now I am trying to remove the polyline through it's id, is it possible? Thanks for your help

Upvotes: 1

Views: 1291

Answers (1)

Spurdow
Spurdow

Reputation: 2043

This may not be a direct answer but in my case this is how I would do it

First keep track of polyline.

Map<String , Polyline> mHashMap = new HashMap<String , Polyline>();
...
Polyline polyline = this.mMap.addPolyline(new PolylineOptions().....);

mHashMap.put(polyline.getId() , polyline);

Now to remove it

//probably this would happen on `OnActivityResult` of first_activity

Polyline pl = mHashMap.get("polyline_id_from_first_activity_rerouted_from_second_activity");
pl.remove();

Hope it helps :)

Upvotes: 1

Related Questions