Marker not showing with timer

Topics: Windows Forms
May 19, 2011 at 1:04 AM

Hi all,

I have successfully added custom markers on my map, three different custom markers in their own overlay.

However, I still need to add 2 more overlays with markers which are updated every 5 seconds in a timer.

I have tried with no luck to see my markers using a timer.

This is what I have tried

The latitude and longitude are working fine I have looked at them during debugging.

What am i doing wrong?

private void tmrAI_Tick(object sender, EventArgs e)
        {
            aircraft.Markers.Clear();
            PointLatLng mpoint = new PointLatLng(latitude, longitude);
            GMapMarkerGoogleGreen gg = new GMapMarkerGoogleGreen(mpoint);
            gg.ToolTipText = "TEST";
            aircraft.Markers.Add(gg);
}
Mike

May 19, 2011 at 1:55 AM

Never mind I found the issue.

Seems that you have to add the overlay first LOLOLOL!!!!!!!!!!!!!!!

Weird though that I did not have to on my other checkbox clicked to show markers code.

May 19, 2011 at 9:14 AM

..one point, if you constantly create new marker and 'forget' the old one in the loop, sooner or later you'll get memory leak, the solution is to reuse objects, and just change it's properties/visibility/position/etc...

May 19, 2011 at 3:50 PM

Thanks radio I will try that today. The one aircraft can be reused for sure however I have other aircraft that are constantly changing and dropping off the map which will be a little more difficult but I should be able to figure it out.

May 19, 2011 at 3:56 PM

if object tend frequently appear/disappear use property IsVisible = true/false, if the timespan is long enough you can remove it from markers and keep it in memory until it again appears, need some tuning i guess ;}

May 19, 2011 at 6:31 PM

I definitely need some tuning.

I used your older control about 2 years ago in my app and was doing the same type of map. That application used about 35 to 55MB of RAM. This current application is going up to 750MB of RAM (ouch).

So, time to tag each marker, reuse it if it is there and drop just the marker from the overlay if it is no longer there. Think of the application as an air traffic map where the traffic drops off when they are out of scope (about 40 miles from the main marker which is on another overlay layer).

I will figure it out to get it using less resources for sure before I release this memory hog LOL (my fault not yours).

Thanks for the help and I will update you on how it is going.