Caching Maps

Sep 4, 2010 at 2:38 AM
Edited Sep 4, 2010 at 2:40 AM

Hi guys,

Part of the usage of the application I am developing is to allow a user to configure some settings on a remote controlled aircraft, fly it, and then download GPS data from the plane after (and possibly during) the flight. Once the person downlaods the data, I have a screen where the user can 'play' the flight he just did, which is a route being drawn on the map as he flys. (I am working on making it into a moving plane, but stuck..).

However, this app might be used at a flying field, or away from an internet connection. So, is there a way a user can cache a certain area, so that when he goes flying... he can bypass internet settings, and use the cached map data for that area?

That's what I have so far... BAsically, you can see the light grey line where the plane has been.. and then the blue line represents the last 5 GPS samples.... and the red cross os the plane. (Want to change that into a plane, showing direction of flight...)

Sep 4, 2010 at 2:59 AM

Here's what I am trying, but the latest code doersn't match the demo I had...

RectLatLng area = MainMap.CurrentViewArea;
            if (!area.IsEmpty)
            {
                for (int i = (int)MainMap.Zoom; i <= MainMap.MaxZoom; i++)
                {
                    List<GMap.NET.Point> x = MainMap.Projection.GetAreaTileList(area, i, 0);

                    DialogResult res = MessageBox.Show("Ready ripp at Zoom = " + i + " ? Total => " + x.Count, "GMap.NET", MessageBoxButtons.YesNoCancel);

                    if (res == DialogResult.Yes)
                    {
                        TilePrefetcher obj = new TilePrefetcher();
                        obj.ShowCompleteMessage = true;
                        obj.Start(area, null, i, MainMap.MapType, 100);
                    }
                    else if (res == DialogResult.No)
                    {
                        continue;
                    }
                    else if (res == DialogResult.Cancel)
                    {
                        break;
                    }

                    x.Clear();
                }
            }
            else
            {
                MessageBox.Show("Select map area holding ALT", "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
The

obj.Start(area, null, i, MainMap.MapType, 100);

part is wrong. Instead of a NULL, I should be passing something called a 'PureProjection'. What's that!?
Sep 4, 2010 at 3:07 AM

Wait, wait, wait.. :)

I seem to have it caching now... but .. where does the cache get stores, and how do you tell it to use the cache, instead of live internet?

Coordinator
Sep 4, 2010 at 9:18 AM

database is located here: map.CacheLocation

// set cache mode only if no internet avaible
try
{
   System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com");
}
catch
{
   MainMap.Manager.Mode = AccessMode.CacheOnly;
   MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

Sep 4, 2010 at 9:44 AM

radioman, that is fantatic!

Where is the cached data stored though?

Coordinator
Sep 4, 2010 at 9:56 AM

database is located here: map.CacheLocation