Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GMap .net offline

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.

like image 875
Damien Chaudois Avatar asked Sep 22 '15 08:09

Damien Chaudois


1 Answers

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)

like image 79
pm101 Avatar answered Oct 28 '22 18:10

pm101