Remove route-markers

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

Hi,

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?

Coordinator
May 8, 2012 at 10:03 AM

"markers that belong to the marker" ?

May 8, 2012 at 11:17 AM

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.

Coordinator
May 8, 2012 at 1:33 PM

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

 

May 8, 2012 at 2: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 3:42 PM
Edited May 8, 2012 at 3: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
   route_overlay.Markers.Remove(m)
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.

Coordinator
May 8, 2012 at 4: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 12: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?

Coordinator
May 15, 2012 at 3:05 PM

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

foreach(var m in a)
{
   overlay.Markers.Remove(m);
}

a.Clear();

p.s. grab more fruit ;}

May 15, 2012 at 4:32 PM
Edited May 15, 2012 at 4: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 11:15 AM

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

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

we use gmap.net 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.
Coordinator
Dec 8, 2014 at 3:16 PM
you can add//remove any marker