8

I'm developing an application using Gmap in c# (great API, btw), not to confuse with google-map API, and I did some really cool and useful stuff ever since.

My problem is that some of my clients won't have an internet connection, and that is why I need to be able to display the background (the map) offline. I used to use the property GMap.NET.AccessMode.ServerAndCache; to get my data from the server, and now I would like to be able to use GMap.NET.AccessMode.CacheOnly with a full cache.

Letting them load the cache with a connection to prepare for an offline use is not an option, the PCs will never be connected to the internet. After some research, I learned OpenStreetMap is the only open source map that would allow me to use their map for free (and that is good because they have very good maps). I downloaded a 20GB map of Europe, but I have no idea how to specify it as the cache (I know how to locate the cache folder).

Most of the time, my Google searches showed me people trying to create a virtual sqlite server with all the map's tiles in a DB accessed via localhost, but honestly I think this is very complex and I would like to know if anybody has an idea to allow me to use those maps offline or a link for the doc of this api, impossible to find on the net (I found the sources, but almost no comment and no explanation).

Thanks in advance, and sorry for my bad English.

réponses en français bienvenues.

1
  • "some of my clients won't have an internet connection". They also can't access intranet? If they can access intranet, you can setup your own OpenStreetMap tile server. Sep 30, 2015 at 8:54

3 Answers 3

3

You can create a separate program to prefetch tiles for offline use. Or use the GMap NET demo program (https://github.com/radioman/greatmaps/tree/master/Demo.WindowsPresentation)

The code below is for a button press after you've selected an area using ALT + mouse first button.

RectLatLng area = mapView.SelectedArea;
if (!area.IsEmpty)
{
    for (int i = (int)mapView.Zoom; i <= mapView.MaxZoom; i++)
    {
        TilePrefetcher obj = new TilePrefetcher();
        obj.Title = "Prefetching Tiles";
        obj.Icon = this.Icon;
        obj.Owner = this;
        obj.ShowCompleteMessage = false;
        obj.Start(area, i, mapView.MapProvider, 100);
    }
    DialogResult = true;
    Close();
}
else
{
    MessageBox.Show("No Area Chosen", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}

(mostly copied from Gmap NET Demo source)

https://github.com/radioman/greatmaps/tree/master/Demo.WindowsPresentation

The files are stored in

C:\Users\[your user name]\AppData\Local\GMap.NET\TileDBv5\en

Once you've successfully prefetched the tiles you can copy the files to the same location in the offline pc and it should use it (or just copy the whole GMap.NET folder to the offline pc via usb or whatever).

0

use gmap.CacheLocation = @"C:\Users\xxx\Desktop\"; to specify the cache location.

Just copy the cache to different machine under the same directory will work.

To cache the map data, check my github https://github.com/williamwdu/GMap.NETChacher

The cache directory will look like this TileDBv5\en\Data.gmdb

0

Pay attention that the Provider of the MAP that you have downloaded be the same provider that you have used in your code. eq: GMap.NET.MapProviders.GMapProviders.OpenStreetMap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.