Click here to Skip to main content
11,478,619 members (63,636 online)
Click here to Skip to main content

GMap.NET - Great Maps for Windows Forms and Presentation

, 16 Apr 2013 MIT 609K 17 478
Rate this:
Please Sign up or sign in to vote.
GMap.NET is a powerful, free, cross platform, Open Source .NET control. It enables the use of routing, geocoding, and maps from Google, Yahoo!, OpenStreet in Windows Forms and Presentation, and supports caching!

GMapNET/GMapNETv7cp.PNG

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);
}

// config map
MainMap.MapProvider = GMapProviders.OpenStreetMap;
MainMap.Position = new PointLatLng(54.6961334816182, 25.2985095977783);
MainMap.MinZoom = 0;
MainMap.MaxZoom = 24;
MainMap.Zoom = 9;

// add your custom map db provider
//GMap.NET.CacheProviders.MySQLPureImageCache ch = new GMap.NET.CacheProviders.MySQLPureImageCache();
//ch.ConnectionString = @"server=sql2008;User Id=trolis;Persist Security Info=True;database=gmapnetcache;password=trolis;";
//MainMap.Manager.SecondaryCache = ch;

// set your proxy here if need
//GMapProvider.WebProxy = new WebProxy("10.2.0.100", 8080);
//GMapProvider.WebProxy.Credentials = new NetworkCredential("ogrenci@bilgeadam.com", "bilgeada");

// map events
{
   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.  

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

radioman.lt
Software Developer
Lithuania Lithuania
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 Pin
Gun Gun Febrianza13-Oct-12 16:28
memberGun Gun Febrianza13-Oct-12 16:28 
GeneralRe: My vote of 5 Pin
Laurie Ayres23-Nov-12 14:10
memberLaurie Ayres23-Nov-12 14:10 
QuestionMain Map Pin
Qismet24-May-12 4:56
memberQismet24-May-12 4:56 
AnswerRe: Main Map Pin
radioman.lt24-May-12 6:31
memberradioman.lt24-May-12 6:31 
QuestionSOURCE CODE Pin
Qismet16-May-12 1:16
memberQismet16-May-12 1:16 
AnswerRe: SOURCE CODE Pin
radioman.lt16-May-12 1:20
memberradioman.lt16-May-12 1:20 
GeneralRe: SOURCE CODE Pin
Qismet16-May-12 1:35
memberQismet16-May-12 1:35 
QuestionI need to use address instead of lat and lng? Pin
Ben Paxton14-Mar-12 3:06
memberBen Paxton14-Mar-12 3:06 
AnswerRe: I need to use address instead of lat and lng? Pin
radioman.lt14-Mar-12 4:10
memberradioman.lt14-Mar-12 4:10 
GeneralRe: I need to use address instead of lat and lng? Pin
Ben Paxton14-Mar-12 5:34
memberBen Paxton14-Mar-12 5:34 
GeneralRe: I need to use address instead of lat and lng? Pin
radioman.lt14-Mar-12 6:22
memberradioman.lt14-Mar-12 6:22 
QuestionSome simple documentation for GMap.Net Pin
smartradio13-Mar-12 3:20
membersmartradio13-Mar-12 3:20 
QuestionExample don´t working in C# 2008 Pin
smartradio13-Mar-12 3:18
membersmartradio13-Mar-12 3:18 
AnswerRe: Example don´t working in C# 2008 Pin
radioman.lt13-Mar-12 3:30
memberradioman.lt13-Mar-12 3:30 
download the code, check the demo source
d{^__^}b - it's time to fly

GeneralRe: Example don´t working in C# 2008 Pin
smartradio13-Mar-12 5:16
membersmartradio13-Mar-12 5:16 
Questionoffline maps Pin
mojimoj29-Feb-12 1:25
membermojimoj29-Feb-12 1:25 
AnswerRe: offline maps [modified] Pin
radioman.lt29-Feb-12 2:44
memberradioman.lt29-Feb-12 2:44 
Questionnice app Pin
CIDev14-Feb-12 12:22
memberCIDev14-Feb-12 12:22 
AnswerRe: nice app Pin
radioman.lt14-Feb-12 23:11
memberradioman.lt14-Feb-12 23:11 
QuestionPb in using GMap contril in C++.NET Pin
gilmegviv31-Jan-12 12:11
membergilmegviv31-Jan-12 12:11 
AnswerRe: Pb in using GMap contril in C++.NET Pin
radioman.lt31-Jan-12 21:53
memberradioman.lt31-Jan-12 21:53 
GeneralRe: Pb in using GMap contril in C++.NET Pin
gilmegviv2-Feb-12 10:11
membergilmegviv2-Feb-12 10:11 
QuestionHow do I load a TMS that was created using maptiler and Geotiff Pin
Andrew Mellon20-Dec-11 13:58
memberAndrew Mellon20-Dec-11 13:58 
AnswerRe: How do I load a TMS that was created using maptiler and Geotiff Pin
radioman.lt20-Dec-11 21:34
memberradioman.lt20-Dec-11 21:34 
GeneralRe: How do I load a TMS that was created using maptiler and Geotiff Pin
Andrew Mellon21-Dec-11 10:24
memberAndrew Mellon21-Dec-11 10:24 
GeneralRe: How do I load a TMS that was created using maptiler and Geotiff Pin
Andrew Mellon22-Dec-11 10:37
memberAndrew Mellon22-Dec-11 10:37 
GeneralRe: How do I load a TMS that was created using maptiler and Geotiff Pin
radioman.lt22-Dec-11 10:56
memberradioman.lt22-Dec-11 10:56 
GeneralRe: How do I load a TMS that was created using maptiler and Geotiff Pin
kenzai27-Dec-11 23:12
memberkenzai27-Dec-11 23:12 
QuestionBlank Map Pin
Babsitz7-Dec-11 7:20
memberBabsitz7-Dec-11 7:20 
AnswerRe: Blank Map Pin
radioman.lt7-Dec-11 8:21
memberradioman.lt7-Dec-11 8:21 
GeneralMy vote of 5 Pin
Sergio Andrés Gutiérrez Rojas2-Nov-11 16:25
memberSergio Andrés Gutiérrez Rojas2-Nov-11 16:25 
QuestionIs it possible to get Google POI data and show them on the map ? Pin
Jimz Rend21-Aug-11 22:38
memberJimz Rend21-Aug-11 22:38 
AnswerRe: Is it possible to get Google POI data and show them on the map ? Pin
radioman.lt22-Aug-11 2:07
memberradioman.lt22-Aug-11 2:07 
GeneralRe: Is it possible to get Google POI data and show them on the map ? [modified] Pin
Jimz Rend22-Aug-11 19:00
memberJimz Rend22-Aug-11 19:00 
QuestionOutOfRangeException in TileMatrix.GetTileWithNoLock() Pin
BloodyBaron17-Aug-11 11:16
memberBloodyBaron17-Aug-11 11:16 
AnswerRe: OutOfRangeException in TileMatrix.GetTileWithNoLock() Pin
radioman.lt17-Aug-11 11:27
memberradioman.lt17-Aug-11 11:27 
GeneralRe: OutOfRangeException in TileMatrix.GetTileWithNoLock() Pin
BloodyBaron17-Aug-11 11:33
memberBloodyBaron17-Aug-11 11:33 
GeneralRe: OutOfRangeException in TileMatrix.GetTileWithNoLock() Pin
radioman.lt17-Aug-11 11:37
memberradioman.lt17-Aug-11 11:37 
GeneralRe: OutOfRangeException in TileMatrix.GetTileWithNoLock() Pin
BloodyBaron17-Aug-11 11:45
memberBloodyBaron17-Aug-11 11:45 
QuestionIs it possible to use custom marker like my own image ? Pin
Jimz Rend8-Aug-11 23:17
memberJimz Rend8-Aug-11 23:17 
AnswerRe: Is it possible to use custom marker like my own image ? Pin
radioman.lt9-Aug-11 1:26
memberradioman.lt9-Aug-11 1:26 
GeneralRe: Is it possible to use custom marker like my own image ? Pin
Jimz Rend9-Aug-11 18:31
memberJimz Rend9-Aug-11 18:31 
QuestionSVN repository available? Pin
BloodyBaron5-Aug-11 12:49
memberBloodyBaron5-Aug-11 12:49 
AnswerRe: SVN repository available? Pin
radioman.lt5-Aug-11 22:20
memberradioman.lt5-Aug-11 22:20 
QuestionAwesome control Pin
Mike Hankey31-Jul-11 9:32
memberMike Hankey31-Jul-11 9:32 
AnswerRe: Awesome control Pin
radioman.lt31-Jul-11 11:30
memberradioman.lt31-Jul-11 11:30 
QuestionGetplacemarkfromgeocoder problem Pin
p4t0722-Jul-11 5:29
memberp4t0722-Jul-11 5:29 
AnswerRe: Getplacemarkfromgeocoder problem Pin
radioman.lt25-Jul-11 10:09
memberradioman.lt25-Jul-11 10:09 
QuestionGmap Control Pin
victorm2nu3l25-Jun-11 14:54
membervictorm2nu3l25-Jun-11 14:54 
AnswerRe: Gmap Control Pin
radioman.lt25-Jun-11 15:25
memberradioman.lt25-Jun-11 15:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 16 Apr 2013
Article Copyright 2009 by radioman.lt
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid