Introduction
Google Maps are cool, yeah? But it's useful only in the browser, and is insufficient for real time tracking. It also does not have cache so Google servers are overloaded. This control removes all these deficiencies! It also gives the .NET developer unlimited ability to extend it!
GMap.NET is great and Powerful, Free, cross platform, open source .NET control. Enable use routing, geocoding, directions and maps from Google, Yahoo!, Bing, OpenStreetMap, ArcGIS, Pergo, SigPac, Yandex, Mapy.cz, Maps.lt, iKarte.lv, NearMap, OviMap, CloudMade, WikiMapia, MapQuest in Windows Forms & Presentation, supports caching and runs on windows mobile!
Background
The basic idea is simple: get the required data from Google/etc., cache it, and use it. Fast, simple, and practical.
Using the Code
It's more than easy. GMap.NET.dll and GMap.NET.WindowsForms.dll contain the user control. Add it to your project and simply use it.
Here are the basic control initial options:
public MainForm()
{
InitializeComponent();
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);
}
MainMap.MapProvider = GMapProviders.OpenStreetMap;
MainMap.Position = new PointLatLng(54.6961334816182, 25.2985095977783);
MainMap.MinZoom = 0;
MainMap.MaxZoom = 24;
MainMap.Zoom = 9;
{
MainMap.OnPositionChanged += new PositionChanged(MainMap_OnPositionChanged);
MainMap.OnTileLoadStart += new TileLoadStart(MainMap_OnTileLoadStart);
MainMap.OnTileLoadComplete += new TileLoadComplete(MainMap_OnTileLoadComplete);
MainMap.OnMapZoomChanged += new MapZoomChanged(MainMap_OnMapZoomChanged);
MainMap.OnMapTypeChanged += new MapTypeChanged(MainMap_OnMapTypeChanged);
MainMap.OnMarkerClick += new MarkerClick(MainMap_OnMarkerClick);
MainMap.OnMarkerEnter += new MarkerEnter(MainMap_OnMarkerEnter);
MainMap.OnMarkerLeave += new MarkerLeave(MainMap_OnMarkerLeave);
MainMap.OnPolygonEnter += new PolygonEnter(MainMap_OnPolygonEnter);
MainMap.OnPolygonLeave += new PolygonLeave(MainMap_OnPolygonLeave);
MainMap.OnRouteEnter += new RouteEnter(MainMap_OnRouteEnter);
MainMap.OnRouteLeave += new RouteLeave(MainMap_OnRouteLeave);
MainMap.Manager.OnTileCacheComplete += new TileCacheComplete(OnTileCacheComplete);
MainMap.Manager.OnTileCacheStart += new TileCacheStart(OnTileCacheStart);
MainMap.Manager.OnTileCacheProgress += new TileCacheProgress(OnTileCacheProgress);
}
}
As you can see, the control options are quite simple. And there is nothing more to add.
Points of Interest
Well, it was quite cryptic to figure out how Google manages tiles, what coordinate system it uses, the JSON decryption, etc.
History
Go to the project's CodePlex site to get a running update of any changes or improvements I've made.