Remove route-markers

Topics: Windows Forms
May 8, 2012 at 10:58 AM


Removing a route is simple, but I can't think of a way how to remove the markers that belong to the marker. Any suggestions?

May 8, 2012 at 11:03 AM

"markers that belong to the marker" ?

May 8, 2012 at 12:17 PM

Yeah, I guess I'm not explaining myself very well.

Before I add the route I add a marker for begin and end of the route. So I need a solution to make it a part of the route.

- EDIT: Hmmmm, perhaps I have an idea.

May 8, 2012 at 2:33 PM

m1.Tag = route1;
m2.Tag = route2;


May 8, 2012 at 3:27 PM

Yep, that is (almost) exactly what I did, but struggling with the removal. The begin marker has the same tag as the end marker, but the code somehow isn't working. Have to dig a little deeper.

May 8, 2012 at 4:42 PM
Edited May 8, 2012 at 4:44 PM

This code obviously will only remove one marker, how do I modify it to remove more?

Dim m As GMapMarker = route_overlay.Markers.FirstOrDefault(Function(p) p IsNot Nothing AndAlso TryCast(p.Tag, String) = "1")
If m IsNot Nothing Then
End If

Have to use this kindof code, cause the "For Each" simply doesn't work if you want to remove multiple markers using the  tags.

May 8, 2012 at 5:28 PM

build list of wanted markers then use that list and remove one by one from overlay, clear the list

May 15, 2012 at 1:58 PM

He Radioman. Sorry for my late reply. Caught the flue last week. Still not 100%. Hope to feel better soon.

What do you mean with building a list?

May 15, 2012 at 4:05 PM

list a;
foreach(var m in overlay.Markers)
  if(int)m.Tag == 1)

foreach(var m in a)


p.s. grab more fruit ;}

May 15, 2012 at 5:32 PM
Edited May 15, 2012 at 5:41 PM

"An apple a day , keeps the doctor away...." Don't believe the one that is telling you this crap lol. Last weekend I died, but I remembered that I had a question left here.  It was a long journey, but hé, I'm back. :P

Thanks m8. Will have a look-see later. Now I'm going to climb the couch and have a rest ;)

May 20, 2012 at 12:15 PM

Things are finally getting better with me ;) and your solution is wonderful. Thank you.

Dec 8, 2014 at 1:20 PM
Edited Dec 8, 2014 at 1:20 PM
Hi radioman,

we use for windows from project. but we have a problem about removing markers and routes. we can only remove that last added marker.
how we solve this problem?
thanks for your hepls.
Dec 8, 2014 at 4:16 PM
you can add//remove any marker