GMap .net offline

帅比萌擦擦* 提交于 2020-01-22 20:15:08

问题


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:


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)




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/32711953/gmap-net-offline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!