Click here to Skip to main content
13,292,376 members (58,167 online)
Click here to Skip to main content
Add your own
alternative version

Stats

1M views
49 downloads
497 bookmarked
Posted 18 Jan 2009
MIT

GMap.NET - Great Maps for Windows Forms and Presentation

, 16 Apr 2013
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

You may also be interested in...

Comments and Discussions

 
QuestionHow to pass credentials for BingMaps? Linqpad sample? Pin
Member 1330860613-Jul-17 7:44
memberMember 1330860613-Jul-17 7:44 
SuggestionCould you provide links for examples of drawing a vector layer on top map source? Pin
Dan Randolph27-Apr-17 10:23
professionalDan Randolph27-Apr-17 10:23 
AnswerRe: Could you provide links for examples of drawing a vector layer on top map source? Pin
Dan Randolph27-Apr-17 12:12
professionalDan Randolph27-Apr-17 12:12 
QuestionUsing Satellite map other than Bing Pin
Member 1311876410-Apr-17 5:09
memberMember 1311876410-Apr-17 5:09 
QuestionGmap Control shows no more the "standard" openstreetmap Pin
Member 1271736112-Mar-17 4:10
memberMember 1271736112-Mar-17 4:10 
AnswerRe: Gmap Control shows no more the "standard" openstreetmap Pin
Member 956324312-Mar-17 4:36
memberMember 956324312-Mar-17 4:36 
GeneralRe: Gmap Control shows no more the "standard" openstreetmap Pin
Member 1271736129-Oct-17 9:45
memberMember 1271736129-Oct-17 9:45 
QuestionTilt Map Pin
Member 42973466-Aug-14 17:27
memberMember 42973466-Aug-14 17:27 
QuestionReally wished this worked. Pin
Daniel Krusky27-Jul-14 8:22
memberDaniel Krusky27-Jul-14 8:22 
AnswerRe: Really wished this worked. Pin
radioman.lt29-Jul-14 2:31
memberradioman.lt29-Jul-14 2:31 
Questionmultiple Marker Cursor freeze to "Hand" Pin
Member 1058111922-Feb-14 4:19
memberMember 1058111922-Feb-14 4:19 
AnswerRe: multiple Marker Cursor freeze to "Hand" Pin
radioman.lt22-Feb-14 8:52
memberradioman.lt22-Feb-14 8:52 
GeneralRe: multiple Marker Cursor freeze to "Hand" Pin
willi-5824-Feb-14 16:47
memberwilli-5824-Feb-14 16:47 
QuestionGood job! Pin
g0d20127-Jan-14 20:06
memberg0d20127-Jan-14 20:06 
GeneralMy vote of 5 Pin
ThatsAlok8-Nov-13 3:01
memberThatsAlok8-Nov-13 3:01 
GeneralMy vote of 1 Pin
davemaster995-Jul-13 13:58
memberdavemaster995-Jul-13 13:58 
GeneralRe: My vote of 1 Pin
radioman.lt7-Jul-13 11:12
memberradioman.lt7-Jul-13 11:12 
GeneralRe: My vote of 1 Pin
davemaster997-Jul-13 16:38
memberdavemaster997-Jul-13 16:38 
GeneralMy vote of 2 Pin
GregoryW29-Apr-13 0:26
memberGregoryW29-Apr-13 0:26 
QuestionCan't Browse at CP Pin
Alan Burkhart22-Apr-13 14:33
memberAlan Burkhart22-Apr-13 14:33 
AnswerRe: Can't Browse at CP Pin
SteveQ5622-Apr-13 22:33
memberSteveQ5622-Apr-13 22:33 
GeneralRe: Can't Browse at CP Pin
radioman.lt22-Apr-13 22:35
memberradioman.lt22-Apr-13 22:35 
GeneralRe: Can't Browse at CP Pin
Alan Burkhart23-Apr-13 14:06
memberAlan Burkhart23-Apr-13 14:06 
GeneralMy vote of 5 Pin
Prasad Khandekar16-Apr-13 10:15
memberPrasad Khandekar16-Apr-13 10:15 
QuestionHow to cache maps? Pin
S.Faizan.Ali15-Apr-13 20:34
memberS.Faizan.Ali15-Apr-13 20:34 
AnswerRe: How to cache maps? Pin
radioman.lt16-Apr-13 1:22
memberradioman.lt16-Apr-13 1:22 
QuestionMapControl does not contain the properties of MapType and CurrentPosition Pin
jhyap858-Apr-13 16:20
memberjhyap858-Apr-13 16:20 
AnswerRe: MapControl does not contain the properties of MapType and CurrentPosition Pin
radioman.lt8-Apr-13 21:17
memberradioman.lt8-Apr-13 21:17 
GeneralRe: MapControl does not contain the properties of MapType and CurrentPosition Pin
jhyap858-Apr-13 22:18
memberjhyap858-Apr-13 22:18 
GeneralRe: MapControl does not contain the properties of MapType and CurrentPosition Pin
radioman.lt8-Apr-13 23:23
memberradioman.lt8-Apr-13 23:23 
GeneralRe: MapControl does not contain the properties of MapType and CurrentPosition Pin
jhyap859-Apr-13 4:14
memberjhyap859-Apr-13 4:14 
GeneralRe: MapControl does not contain the properties of MapType and CurrentPosition Pin
jhyap859-Apr-13 16:19
memberjhyap859-Apr-13 16:19 
QuestionNo instance of MainMap or: is there any Documentation or How to? Pin
Member 99643874-Apr-13 0:33
memberMember 99643874-Apr-13 0:33 
AnswerRe: No instance of MainMap or: is there any Documentation or How to? Pin
radioman.lt4-Apr-13 5:13
memberradioman.lt4-Apr-13 5:13 
GeneralRe: No instance of MainMap or: is there any Documentation or How to? Pin
Member 99643874-Apr-13 6:14
memberMember 99643874-Apr-13 6:14 
I do not find any demo source or respective project. Can you give me the link?
How do I include the control, via toolbox?
How do I instatiate a respective control?
Thanks and regards

CJC
GeneralRe: No instance of MainMap or: is there any Documentation or How to? Pin
radioman.lt4-Apr-13 21:45
memberradioman.lt4-Apr-13 21:45 
GeneralMy vote of 1 Pin
rocket4225-Feb-13 23:52
memberrocket4225-Feb-13 23:52 
GeneralRe: My vote of 1 Pin
radioman.lt26-Feb-13 0:01
memberradioman.lt26-Feb-13 0:01 
Questionsaid Pin
rocket4225-Feb-13 23:51
memberrocket4225-Feb-13 23:51 
AnswerRe: said Pin
radioman.lt25-Feb-13 23:57
memberradioman.lt25-Feb-13 23:57 
GeneralMy vote of 2 Pin
Guillaume Waser23-Jan-13 23:47
memberGuillaume Waser23-Jan-13 23:47 
GeneralRe: My vote of 2 Pin
radioman.lt15-Feb-13 9:46
memberradioman.lt15-Feb-13 9:46 
GeneralRe: My vote of 2 Pin
rocket4226-Feb-13 0:37
memberrocket4226-Feb-13 0:37 
QuestionDEM data Pin
desire839-Jan-13 9:08
memberdesire839-Jan-13 9:08 
AnswerRe: DEM data Pin
radioman.lt15-Feb-13 9:41
memberradioman.lt15-Feb-13 9:41 
QuestionUse MAP in my project Pin
NimrodMazalTov28-Nov-12 1:35
memberNimrodMazalTov28-Nov-12 1:35 
AnswerRe: Use MAP in my project Pin
radioman.lt28-Nov-12 1:49
memberradioman.lt28-Nov-12 1:49 
GeneralRe: Use MAP in my project Pin
NimrodMazalTov28-Nov-12 2:19
memberNimrodMazalTov28-Nov-12 2:19 
GeneralRe: Use MAP in my project Pin
radioman.lt28-Nov-12 2:43
memberradioman.lt28-Nov-12 2:43 
GeneralRe: Use MAP in my project Pin
NimrodMazalTov28-Nov-12 3:06
memberNimrodMazalTov28-Nov-12 3:06 

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

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

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