Reputation: 13
I'm trying to download a MapProvider to use offline map but i dont know how to download. it works when i use ServerOnly. This is my code:
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
_map = new GMapControl();
Map.MapProvider = GMap.NET.MapProviders.BingHybridMapProvider.Instance;
Map.DragButton = MouseButton.Left;
Map.MinZoom = 2;
Map.MaxZoom = 18;
Map.Zoom = 5;
Map.CanDragMap = true;
Map.Position = new GMap.NET.PointLatLng(48.8589507, 2.2775175);
Map.ShowCenter = false;
Thank you everyone
Upvotes: 0
Views: 1338
Reputation: 1437
You can cache the map in the local storage using the ServerAndCache
found in GMap.NET.AccessMode
The following function will do the work:
private void gMapStoreOffline(int lat, int lng)
{
gMapControl1.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
GMap.NET.MapProviders.OpenStreetMapProvider.UserAgent = "IE";
gMapControl1.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
GMaps.Instance.OptimizeMapDb(null);
// Define the location to cache the file
gMapControl1.CacheLocation = @"C:\Users\<username>\..";
gMapControl1.Zoom = 14;
gMapControl1.Size = new Size(this.Width, this.Height);
gMapControl1.ShowCenter = false;
gMapControl1.Position = new GMap.NET.PointLatLng(lat, lng)
}
Upvotes: 0