GMap.NET Tutorial – Maps, markers and polygons

GMap.NETGMap.NET LogoThe following is a tutorial for using the excellent GMap.NET control. This text will explain how to place a map control on a form, how to initialize it to show the coordinates you want, how to add markers to it, and how to add polygons.

Download the GMap.NET library here (the so-called “hot build” from 2013 – the latest stable release is from 2011 and had some problems for me).

(Note that I have another tutorial up on how to add routes to GMap.NET).

Setting up

First, create a new C# Windows Forms project in Visual Studio 2010. In your GMap.NET download, you will find DLLs named GMap.NET.Core.dll and GMap.NET.WindowsForms.dll. Place them in a subfolder of your project, and add a reference to both.

Adding GMap.NET references
This will allow your code to access GMap.NET’s classes. Since GMap.NET is a user control, you can add it to your Toolbox. (Of course, you could simply instantiate the GMapControl from your code without ever adding it to your Toolbox, but then you would miss out on setting the control’s properties conveniently through the Properties panel). To add the control to your Toolbox, right-click the Toolbox and select “Choose Items.”

Adding the GMap control to your Visual Studio Toolbox

You’ll find the required assemblies by clicking Browse… and selecting the GMap.NET.WindowsForms DLL. This should contain the GMapControl. Verify that there’s a check next to this control, and when you click OK, the control should be in your Toolbox and can be dragged to a form.

Adding a GMap to a Windows Form

Now add a new form (your fresh C# Windows Application should already have one) and drag the GMapControl to it. Resize it to your liking and call it “gmap” instead of the cumbersome GMapControl1. The control will display as an empty rectangle:

Adding the GMap Control to a form

With the control selected, open the Properties panel. Apart from the usual Control properties, you’ll find some GMap-specific properties there. Now things will get interesting:

Properties for the GMapControl

I’ll explain some of the properties right away:

  • CanDragMap – If true, the user can drag the map using the right mouse button. You’ll probably want to keep this set to true.
  • MarkersEnabled – If true, any markers that you defined will be shown. If not, they won’t appear. Set this to true for now. If you forget, you may pull your hair out figuring out why your markers don’t appear (I did).
  • PolygonsEnabled – Same story here.
  • ShowTileGridLines – If true, GMap.NET will show tile coordinates on the tiles. Not something for a production environment, but it may help with debugging.
  • Zoom, MinZoom, MaxZoom – The Zoom level for Google Maps is somewhere between 0 (zoomed out to global level) to 18 (zoomed in to street level). Zoom is the current zoom level (5 would be good for country level), while MinZoom and MaxZoom should be set to 0 and 18 respectively if you want users to be able to zoom in and out fully. Zooming is done with the mouse wheel.

All these are interesting switches that allow us to define how the map will be shown and interacted with, but they don’t allow us to set where the map data is coming from. As we will see, this must be done in code. Running the program now will result in a persistently blank rectangle where the map is supposed to go.

Initializing the map

Add an onLoad event to your form, and add the following code to it:

private void Form1_Load(object sender, EventArgs e)
{
  // Initialize map:
  gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
  GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
  gmap.SetCurrentPositionByKeywords("Maputo, Mozambique");
}

Now run the program. A map should appear, centered on the city of Maputo, Mozambique. I’ve set the position using key words recognized by the map data provider, but you can also use latitude/longitude if you want:

gmap.Position = new PointLatLng(-25.971684,32.589759);

While running the program, you will notice that the map can be dragged with the right mouse button, and zooming is done with the mouse wheel. If these operations do not work, then check that you’ve set the GMapControl’s properties correctly in the Properties panel – you may have inadvertently turned off dragging, or fixed the zooming level.

Map Providers

The magic of the GMap.NET library is that is doesn’t merely work with Google Maps. There are other map data providers out there, and GMap.NET supports a slew of them while the gory API details are all neatly hidden away from you. In the example above, I’ve used the BingMapProvider, but other useful ones include:

  • CloudMadeMapProvider
  • GoogleMapProvider – map provider for Google Maps; there are street, satellite and hybrid variants
  • OpenCycleMapProvider
  • OpenStreetMapProvider
  • WikiMapiaMapProvider
  • YahooMapProvider

Interestingly, the Google Map provider is (for me, at least), the slowest one. The applications takes a good number of seconds to start, presumably because a connection with Google is being (slowly) made. The Bing Map provider was much faster. But, of course, the data shown will be different so it all depends on your preferences. At the very least, your map code could have fallback providers.

GMap.NET with Yahoo Provider

Yahoo provider

GMap.NET with Open Street Map provider

Open Street Map provider

GMap.NET with Google Maps provider

Google Maps provider

GMap.NET with Bing Maps provider

Bing Maps provider

The magic of GMap.NET goes further still. When we get to showing markers and polygons on a map, we’ll see that GMap.NET hides provider-specific implementation details away behind a common interface. That means that any marker and polygon code you write for GMap.NET will work with any of the providers. Awesome!

Adding markers

Markers are added in layers that are placed on top of your map, called overlays. You can place any number of markers in an overlay, then add that overlay to the map. The overlay can then be hidden en shown as necessary.

Here is a bit of code that adds an overlay called “markers” to the map, with a single marker in it:

GMapOverlay markersOverlay = new GMapOverlay("markers");
GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528),
  GMarkerGoogleType.green);
markersOverlay.Markers.Add(marker);
gmap.Overlays.Add(markersOverlay);

Adding a marker to GMap.NET

A Google-type marker on a Bing Map provider

First, the overlay is created. You can give it a name (optionally), which you can use elsewhere to refer to it (or you could just keep a reference to the overlay instance). Next, an instance of GMarkerGoogle is created. It takes two arguments: a location (a PointLatLng instance) and a marker type.

The marker types are a variety of marker images normally available in the Google Maps API (big balloons in many colors, small balloons in many colors, etc.). Or, you can supply an instance of Bitmap with your own image:

GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528),
  new Bitmap("c:\\images\\mymarker.png");

The marker is added to the overlay, and finally the overlay is added to the map. These markers (and the GMarkerGoogleType instances) work with any map provider!

Of course, you can create additional markers and add them to your overlay. There’s no limit, except in performance. More markers mean that performance goes down.

Adding polygons

Markers may not always cut it. Sometimes you need to delimit an area of your map. For instance, you may need to indicate where new construction will take place, or who owns which land. Polygons allow you to show just that.

The following code shows how to create another overlay, and add a four-point polygon to it.

GMapOverlay polyOverlay = new GMapOverlay("polygons");
List points = new List();
points.Add(new PointLatLng(-25.969562,32.585789));
points.Add(new PointLatLng(-25.966205,32.588171));
points.Add(new PointLatLng(-25.968134,32.591647));
points.Add(new PointLatLng(-25.971684,32.589759));
GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
polygon.Stroke = new Pen(Color.Red, 1);
polyOverlay.Polygons.Add(polygon);
gmap.Overlays.Add(polyOverlay);

First, we create a new overlay. Next, we define a list with all the points in the polygon (this is a four-point polygon, but you can just as easily create many more points). Using these points, we create an instance of GMapPolygon. For good measure, we tell the polygon how to draw itself using a SolidBrush (semitransparent) for the fill, and a thin red Pen for the stroke. Finally, we add the polygon to the overlay, and the overlay to the map.

Tip: don’t forget to add overlays to the map, or they won’t show up.

Adding a GMap.NET polygon

A polygon showing the area covered by Maputo's Central Hospital

Conclusion

This tutorial should allow you to get started with GMap.NET. Here are some parting tips:

You can use different map providers. Some are faster than others. Also, some show more data than others. Depending on your location, this can make all the difference (Maputo, Mozambique is such as location – Yahoo Maps has almost no data).

When adding markers or polygons to an overlay, don’t forget to add the overlay to the map.

If your markers don’t show up, verify that you have MarkersEnabled set to True in the Properties panel for your GMapControl instance.

GMap.NET requires an internet connection to function properly. However, if no connection is available, you can still use cached information (if available) to show your maps. To do this,  do:

GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.CacheOnly;

Note: there’s more – see GMap.NET Tutorial – Routes to see how to show routes on your maps.


112 Comments

  1. cellurl says:

    Very nicely written. I need to figure out how to use Bearing….

  2. GT says:

    Thanks.
    I’m going to try it now

  3. anil says:

    GMapOverlay error???
    couldn’t be found.are u missing a using directive or an assembly reference

    • alex says:

      Try referencing the following namespaces:


      using GMap.NET;
      using GMap.NET.WindowsForms;
      using GMap.NET.WindowsForms.Markers;
      using GMap.NET.WindowsForms.ToolTips;

  4. anil says:

    no any changes

    the load portion in gmapProvider didnt worked and i tried gmapcontrol1.mapProvider then it worked

  5. Seb says:

    For example, if I have a route that consists of the following addresses:

    2 Dummy st., Some City , some state
    45 Dummy Av.,Some City , some state
    US1 Dummy st.Some City , some state
    US1 125 Dummy st.Some City , some state

    it should be able to sort it by distance and make the route so I don’t have to return to the same place twice, is there such a feature?if so, can you please post some code ?
    thank you

  6. Tristan says:

    Hi Alex! Really appreciated the tutorial you provided, it really helped me!
    Could you make a tutorial on Tooltips for map locations? For example, when you mouse over an icon, it will display a little bubble to display more information.

    Thanks!

    • alex says:

      Try this:

      marker.ToolTip = new GMapRoundedToolTip(marker);
      marker.ToolTipText = "hello";
    • JCarter says:

      Can you elaborate on your tooltips snippet? How do you associate the tooltip to the markers?

      • JCarter says:

        I answered my own question (I think). I changed this:

        overlayOne.Markers.Add(New GMapMarkerGoogleRed(New PointLatLng(lat, lon)))

        to this:

        Dim pos As System.Nullable(Of PointLatLng) = New PointLatLng(lst, lon)
        Dim m As New GMapMarkerGoogleRed(pos.Value)
        Dim overlayOne As New GMapOverlay(GMapControl1, “OverlayOne”)
        m.ToolTip = New GMapRoundedToolTip(m)
        m.ToolTipText = “Hello World”
        overlayOne.Markers.Add(m)
        GMapControl1.Overlays.Add(overlayOne)

        Is this the best way to handle this?

  7. Fm says:

    A great tutorial but i got a problem with Markers, actually i cannot show on the map..
    I am using the namespaces that you said but i got error when i type
    GMapOverlay markersOverlay = new GMapOverlay(“markers”);
    i get error in “markers”

  8. Fm says:

    I am sorry, i meant it doesntt contain any constructor that takes “1″ as argument

  9. Fm says:

    Hi Alex and thank you for the very fast reply, maybe is it a my mistake.
    i will try with last v. and i let you know.
    Thank you again for reply and great tutorial!

  10. Fm says:

    Totally my mistake (i didnt realize that i downloaded an old version) now it’s work well! Thank you for tutorial.
    I also try routing tutorial and it is good!
    It will be nice some tutorials about reverse geocoding, in my opion is a very importart chapter but actually i don’t know if gmap.net can reverse geocode

  11. klob says:

    HI sir, great tutorial. It really help me. Just want to ask. Is there anyway or any method in which it returns the long/lat of a given point from mouse click? Say I click anywhere in the map and then we can get the long/lat of the clicked area? Thank you very much sir.

    • Tomas says:

      I have a map called myMap. Add Click event and put this code.

      private void myMap_Click(object sender, EventArgs e)
      {
      MessageBox.Show(“position: ” + myMap.FromLocalToLatLng(MousePosition.X, MousePosition.Y).ToString());
      }

  12. Jonas says:

    Does this control be used for visualizing spatial data and integrate it to Desk Top application with ful mapping elements like legends,Title.Thank you.

  13. Jon says:

    Hi, I am working with Gmap and I like it very much. But i wonder, is it possible to get search suggestions? And also, how can you set correct bounds so that it fits your search?

  14. cxt_hut says:

    Hi everybody!

    I have a problem: I have a custom provider but I dont know using it. Please help me!

  15. radioman says:

    thanks ;} i’ll add the link to this tutorial, next time share it on the forum

  16. Tomas says:

    Hi sir,
    I am woking with Gmap and I want to simulate a car running between two points .can u give me some suggestions ? Please help me !

  17. Sid says:

    Hi Radioman –

    This looks very interesting. In my application I will not always have access to the internet. I would like to download and cache all of the maps from some provider, Google, or someone else, but I don’t how. Can you explain how to do this? I don’t really care which one(s) I use at this point. Thanks,

    GMap.NET requires an internet connection to function properly. However, if no connection is available, you can still use cached information (if available) to show your maps. To do this, do:

    GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.CacheOnly;

  18. Wayne Fu says:

    Very Helpful!Thank you!

  19. wael says:

    where to add markers part ???

  20. trung says:

    Hi, I am working with Gmap and I like it very much. but I don’t know how to display one icon in my position I want to. Can you help me.Thaks.

  21. Inez Bargar says:

    Google has decided that its users of their well-liked Google Maps service will begin becoming charged a fee for utilizing their service. Websites that are going embedding a Google Map of their location will be charged a fee for usage.This new Google Maps fee is going to hit mostly the bigger companies, particularly the Travel industry. I suspect that certain websites that are the heaviest users would be websites like TripAdvisor and Expedia..^

    Newest article content on our online site
    http://ideascollection.org/

  22. jjesz14 says:

    Hi.. very helpfull.. thx.
    By the way, i’m such as newbie in using Gmap.net.

    I try the program above. When initializing the map, why I can’t add “SetCurrentPositionbyKeywords” ?
    there’s only “SetPositionbyKeywords”, is that different?
    Thankyou for your help.

  23. Martin Dodd says:

    I have programmed the above examples up to the point of creating pointers. I managed to use GMapMarkerGoogleGreen or GMapMarkerGoogleRed to create a marker however

    GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528),
    new Bitmap(“c:\\images\\mymarker.png”);

    Yields the type or namespace name ‘GMarkerGoogle’ could not be found. I made reference to:
    using GMap.NET;
    using GMap.NET.WindowsForms;
    using GMap.NET.WindowsForms.Markers;
    using GMap.NET.WindowsForms.ToolTips;
    I look forward to hear any response.

    • Chris Nieass says:

      Martin,

      I believe that is a version issue. Download the latest hot build … GMarkerGoogle is supported.

  24. Kallol Pal says:

    Hi all,
    Thanks for the posts.It really helped me a lot.
    Can any one help me out how to add an image to my polygon in spite of using fill color..

    Thanks in advance

  25. Chris Nieass says:

    Thank you! This is a great tutorial for a very cool control.

    I would like to be able to add text to the actual marker, 2-3 characters only. Is this possible? Apart from color, what other attributes of the marker can be set?

    Thanks in advance.

  26. mario says:

    Como puedo cargar un mapa OpenStreetMap?

    • alex says:

      You should set a provider when you first initialize your map. Try something like this:

      gmap.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;

  27. spiralcb says:

    Hello,

    I use the last build (06/06/12) but SetCurrentPositionbyKeywords cannot be find ?

    Could you help me ?

  28. JCarter says:

    Given I’m a new gMap user this is by far the best documentation that I have found. Well done and thank you for taking the time to put this together. I love the control but I have found the documentation to be lacking.

  29. GgusS says:

    Hi, Please help me!!! my english is very bad, I’m from Paraguay, and I have a vb.net Solutions with Gmap.net, at my work we have proxy server, and my application have errors, I dont know.. I need authentication with the proxy server and sockets.

    Thks!

  30. Wayller says:

    Hello!

    How I can capture points? No idea?

    Thanks.

  31. Sumit says:

    Hi,
    I am using GMap, its a great app to use,
    i have one doubt about it, is there any solution to find near places on map, and show marker on it
    (for example, say if i want to search hospital in pune, then is it possible to show markers on each hospital located in pune)

  32. Raymond says:

    Hey nice post … everything is working fine … but the marker position doesnt change even wen i change d lat long position … plz cud sum1 help me out with dis ??

  33. Andrey says:

    After this portion of code (in the Mainform.Load event handler):

    GMapOverlay markersOverlay = new GMapOverlay(“markers”);
    GMarkerGoogle marker0 = new GMarkerGoogle(this.gmapMain.Position, GMarkerGoogleType.arrow);
    GMarkerGoogle marker1 = new GMarkerGoogle(new PointLatLng(55.851847D, 37.362D), GMarkerGoogleType.arrow);
    GMarkerGoogle marker2 = new GMarkerGoogle(new PointLatLng(55.851847D, 37.360D), GMarkerGoogleType.arrow);
    markersOverlay.Markers.Add(marker0);
    markersOverlay.Markers.Add(marker1);
    markersOverlay.Markers.Add(marker2);
    this.gmapMain.Overlays.Add(markersOverlay);

    all three markers appear at the same place! They look like only one marker near the center og the map. But when I change zoom level of map with mouse wheel, they immediately take their real position! Is it a bug? Or I did something wrong?

    • Ruwantha007 says:

      hay its not rocket science, when the map is small (the zoom is set to low value) it happens.

      the marker is already placed correctly issue is you can see it only when you enlarge it :)

  34. Andrey says:

    Additional info:

    In my program:
    GMap.Dock = Fill;

    1) If I change the size of the program’s window (and hence the GMapControl) – all markers take the right positions.

    2) if I place the line

    GMarkerGoogle marker0 = new GMarkerGoogle((new PointLatLng(55.851847D, 37.360D), GMarkerGoogleType.arrow));

    3) GMap.Invalidate() and GMap.Refresh – does not solve the problem…

    after the abovementioned fragment, the markers appear in right positions.

  35. Andrey says:

    2) if I place the line

    GMarkerGoogle marker0 = new GMarkerGoogle((new PointLatLng(55.851847D, 37.360D), GMarkerGoogleType.arrow));

    just after markers definition, all markers appear at right places

    Sorry for mistake in second post and bad English…

  36. Jim says:

    Hey guys,

    I wanna integrate GMap maps into my existing C# app, which statically displays the map image and bunch of stuff on top of that. What would be the fastest way of swapping my old displaying of a single tile map image with a new GMap overlay? Can GMap control render to a bitmap/image, so I don’t change other things I already render on top of the map? Or is it better/possible to use this control and somehow apply my other drawing calls (Graphics.DrawImage, Graphics.DrawLine, etc.) to be drawn on top of a Gmap control? How do I do that? Any examples? Thanks!

    • alex says:

      You can’t integrate your GDI code with GMap.NET, since GMap.NET wouldn’t know where to draw your elements. If the map scrolls, or zooms, then everything will be off. I think your best bet is to recode your drawing in GMap.NET terms, i.e. polygons and markers.

      Of course, you could use a static map that can’t scroll or zoom, and you could project a transparent bitmap over that. But then, what use is GMap.NET if you turn off this functionality? You might as well take a screenshot of Google Maps and use that.

  37. Cool says:

    it’s good. and i try it.
    it’s no error but i can’t see the map. (no picture at all)

  38. Yeraldin Guzman says:

    hola
    Me parece interesante el tutorial yo estoy usando GMAP.NET en un sistemas que se llama TEAN DEVELOPER 6.2 estoy ensamblando el archivo GMap.NET.WindowsPresentation.dll es una aplicacion WPF me busca por direcciones pero yo quiero agregarles marcas y no me es posible noce si pudieras hacer un tutorial de como agregarlos pero para GMap.NET.WindowsPresentation o ayudarme porque realmente hay muy poca informacion sobre esto.
    Perdon por mi Ingles tan feo soy MEXICANA..

  39. Yeraldin Guzman says:

    hello
    I find it interesting the tutorial I’m using a systems GMAP.NET called DEVELOPER 6.2 TEAN’m joining GMap.NET.WindowsPresentation.dll file is a WPF application I looking for directions but I want agregarles brands and I can not noce if you could do a tutorial on how to add them but for GMap.NET.WindowsPresentation or help me because there really is very little information about this.
    Sorry for my English so ugly I’m MEXICAN ..

  40. Raymond says:

    Hey i solved the marker issue which i had asked ..but now there is another problem … the markers always appear to be at the centre when the map loads .. then wen i scroll in or out it takes its actual place … am i doing something wrong or is it like that only ?

  41. YG says:

    hello I’m using GMAP.NET and achieve do what the tutorial, I want to do is create a new user form1 where search by address and display it on the map. if you could help me and I would also like to add another form2 to search by latitude and longitude where the user of the coordenas, just another form3 for the user to make a polygon with the data they indicate

  42. renee says:

    Hi guys.

    People talk about adding Markers. We know that we can add markers to an overlay, and keep adding marker

    markersOverlay.Markers.Add(marker0);
    markersOverlay.Markers.Add(marker1);
    markersOverlay.Markers.Add(marker2);

    bla bla…

    But how about deleting markers? I only managed to delete one marker on an overlay – using overlay.clear(), or overlay.markers.clear() but only the last added marker was deleted. How to actually delete all markers, either at once or one by one.

  43. Hugo says:

    Hi,
    thank you for making this available on the public domain. Is it possible to use UTM coordinates in stead of Geodetic? Thanks.

  44. mahsa says:

    Hi!
    A great tutorial! :)
    But I have a problem in adding the GmapControl component to my form. And I added all using statements that you wrote. It gives this error: ” ‘System.MissingMethodException:Method not found: ‘System.String System.Data.SQLite.SQLiteConnection.get_DefineConstants()’.
    at GMap.Net.CacheProviders.SQLitePureImageCache.Ping()
    at GMap.Net.GMaps.SQLitePing()
    at GMap.Net.WindowsForms.GMapControl.cctor()’

    Would you please help me?
    Thanks in advance!

  45. mahsa says:

    heh! I closed visual studio and opened it again and the problem is solved! :)

  46. jakfar says:

    sory i’m new in c# and got this error
    “error CS0103: The name ‘gmap’ does not exist in the current context”

  47. ravan says:

    I tried to remove all the markers and then add another markers based on search criteria.

    I tried
    markersOverlay.Markers.Remove(marker0);
    markersOverlay.Markers.Clear();

    But my markers are still present in the map. can you tell me why?

  48. Malo says:

    Hey!

    Thank you, great tutorial!

    But I have a problem. I have an error with this code:
    GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528), new Bitmap(“c:\\images\\mymarker.png”);

    GMarkerGoogle error

    couldn’t be found Are you missing a using directive or an assembly reference

    And I have the latest version of GMap! Thank you in advance

    the GMarkerGoogle is not

  49. CommSter says:

    Hi,

    congratulations for the great work.
    We can add polygons but I wonder if it’s possible to add tracks to an overlay. I mean, is it possible to add a simple polyline which is not closed automatically to the first point.
    I tried to use the polygon with a fill brush with 0 alpha which overrides the filling but the lines gets closed from end to start which i would like to prevent.

    Any workarounds here? THX in advance

    • CommSter says:

      Arrrgh, sorry my fault. I thought the route object does not accept a list of points but only a start and an end point. GMapRoute is the solution.

  50. prat says:

    I have downloaded the hot build but still I am getting “debug build” message in the windows form. Plz help.

  51. Hi,

    I’m trying do add markers after the maps is set up. I’m dealing with two problems:
    1- Whenever the zoom is changed, all markers are lost.
    2- The markers are placed in the same spot, always.

    The code is the following:

    ***
    PointLatLng pos = new PointLatLng(long, lat);
    Marker.GMapMarkerRect marker = new Marker.GMapMarkerRect(pos, t, h);
    markersOverlay = new GMapOverlay(“markersTest”+mark);
    markersOverlay.Markers.Add(marker);
    gmap.Overlays.Add(markersOverlay);
    ***

    The GMapMarkerRect’s constructor has been change to accept two new parameters.

    appreciate your help!

  52. ankita says:

    Hi all,
    I have followed as below: 1. created windowsForms application. Added these 2 dlls for GMap.Core.dll and GMap.Presentation.dll. 2. Added user control in tool box. 3. Written below code:
    gMapControl1.MapProvider = GMap.NET.MapProviders.YahooMapProvider.Instance;
    GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
    gMapControl1.Position = new PointLatLng(32.641218, 51.67576);

    But while running it gives “we are sorry but we don’t have imagery at this zoom level for this region”.

    This same error occurs when I run “Demo.WindowsPresentation.exe” and “Demo.WindowsForms.exe” and it also interrupts saying “no internet connection available, going to cache mode only.” while I have internet connection.
    May be I am missing something.

    Regards,
    Ankita

  53. Raymond says:

    Hey is there any way how do i make the marker move according to the co ordinates of the gps … so i need a marker which would be constantly updated with d new position … plz help me out

  54. Mediel says:

    Hello, i have question, how can I ZoomAndCenter all my markers? I try use ZoomAndCenterMarkers(“markers”); But this is not work… Here is code:

    private void DrawSelectedDataForm_Load(object sender, EventArgs e)
    {
    StartDrawSelectedData start = new StartDrawSelectedData();
    string Ids = “”;
    if (H.SelectedRecordIDs() == null)
    Ids = H.CurrentRecordID().ToString();
    else
    Ids = H.SelectedRecordIDs();

    List subjectsToDraw = start.Start(Ids);

    // inicialize map
    gmap.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
    GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;

    GMapOverlay markersOverlay = new GMapOverlay(gmap, “markers”); // skupina značek zvaná “markers”

    foreach (EntitySubject es in subjectsToDraw)
    {
    GMapMarkerGoogleGreen marker = new GMapMarkerGoogleGreen(new PointLatLng(double.Parse(es.Latitude), double.Parse(es.Longitude)));
    marker.ToolTipText = es.Nazev;

    markersOverlay.Markers.Add(marker);
    }

    gmap.Overlays.Add(markersOverlay);
    gmap.ZoomAndCenterMarkers(“markers”);
    //if (H.SelectedRecordIDs() != null)
    // gmap.Zoom = 7;
    gmap.Refresh();
    }

  55. Ruwantha007 says:

    hi i download “GMap.NET Build 35bb833b03a1″ the latest Version

    but i do not have GMarkerGoogle type what i have is GMapMarker. any problem with what i use ?
    and
    i need to show some details on every marker i add, haw to do it ?
    Thanks for support in advance :)

  56. ruwan says:

    hi,
    how to add number to GMapMarker ? (on marker to be visible)

  57. Tim says:

    All the functionality appears to be working, but no map is displayed. Instead there are just blue panels with the text “Exception: The operation has timed out. We are sorry, but we don’t have imagery at this zoom level for this region.” I’ve tried different versions, different zoom levels and different regions. Is this just down to poor connection?

  58. jean says:

    hi, I have a problem on putting the markers. simply put, if I copy the code, it gives me error, something that is not declared. I don’t know what am I missing, pls help, or email me. thanks dev

  59. David says:

    Hello I seem to be stuck with every tutorial i follow for GMap .NET.

    I am able to run the program but i dont see the map. I can drag the map but i see nothing.

    Screenshot: http://i.imgur.com/tDrMGcn.png

    This also happend when i tried this tutorial: http://myactivities-mazen.blogspot.nl/2012/01/simple-example-of-gmapnet-with-c.html

    Any help would be great. I tried different mapproviders.

  60. tarek says:

    hello ,

    i am working with vb.net not c# and i downloaded the latest release of 22 october but in vb.net i managed to create a map but starting from adding markers it is not working at all for instance GMapOverlay method doesnt exist at all in vb.net 2012 ,can you please advise how to do it in vb.net ?

  61. tarek says:

    ok i managed to solve the problem it is just i have to import u GMap.NET.WindowsForms.Markers;
    and GMap.NET.WindowsForms.ToolTips; just one more question how to draw lines between 2 points ?

    • dave says:

      hi tarek
      i see that you managed adding markers but i do like you qnd it s not working
      a second quest do you succed drawing between 2 points
      i am also working with vb.net
      thanks a lot
      Dave

  62. tarek says:

    your gmap is no longer working after de-activation of google api 2 ,can you prepare an equivalent one for google api 3 ?
    man try to get it to live again

  63. tarek says:

    sorry remote server error 403 ,came for a while now it is ok

  64. jerome zhu says:

    It’s a great job, but it seems that the OnClickPolygon and OnClickRoute do not trig as well as the OnClickMarker work well. Anyboy can solve this problem?

  65. dave says:

    hi
    somn tell me why in vb.net we can use this GMarkerGoogle marker = new GMarkerGoogle
    it is not recognize
    i whant to do a marker as a vehicle/a building
    please help me !!!!!!!
    David

  66. Panos says:

    Hi
    very good article.

    Could you create for the public a working sample project with all stuff of articles (for GMap.Net) ?

  67. afei200815 says:

    Hi
    Thanks for the article.
    I’m trying to use GMap.net in my vc++ project.I can draw a GMapControl in my dialog by adding references to GMap.NET.WindowsForms.dll and GMap.NET.Core.dll, and it’s working .But the thing is, problems appreared when I tried to add polygons into the mapcontrol.I don’t know how to set the value of members of
    GMapPolygon,ie, Fill and Stroke.Someone tell how? Or show me any clue about using GMap.Net in VC++.thanks a lot

  68. Dragan says:

    Hi,
    how can I binding through the server? I’d like to find places using like method!
    And how can I obtain a long and lat from the keyword?
    Thanx in advance!

  69. Dragan says:

    Is it possible to do the job offline? thnx…

  70. Dragan says:

    If somebody want to find location with the timers in vb.net, here is the code:

    Private Sub FindLocation(ByVal location As String)
    GMapControl1.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance
    GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly
    GMapControl1.SetPositionByKeywords(location)
    End Sub
    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
    GMapControl1.Zoom -= 1
    If GMapControl1.Zoom = 5 Then
    With Timer1
    .Stop()
    .Enabled = False
    End With
    If TextBox1.Text > Nothing Then
    FindLocation(TextBox1.Text)
    End If
    With Timer2
    .Enabled = True
    .Interval = 250
    .Start()
    End With
    End If
    End Sub
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    With Timer1
    .Enabled = True
    .Interval = 250
    .Start()
    End With
    End Sub
    Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
    GMapControl1.Zoom += 1
    If GMapControl1.Zoom = 14 Then
    With Timer2
    .Stop()
    .Enabled = False
    End With
    End If
    End Sub

  71. orçun says:

    do not work amına sokiim. not work examples on c#
    amını yurdunu siktiklerimin!

  72. GoGoGoGo---Bomb! says:

    Hi there,
    Thanks for your tutorial, very useful!
    Im having problem when put markers on the map. Markers do not appear at the exact position where I clicked on the map, the difference is quite significant. My code is as following:

    private void gmap_MouseClick(object sender, MouseEventArgs e)
    {
    markersOverlay.Markers.Add(new GMarkerGoogle(gmap.FromLocalToLatLng(MousePosition.X, MousePosition.Y), GMarkerGoogleType.blue_pushpin));
    textBox1.AppendText(gmap.FromLocalToLatLng(MousePosition.X, MousePosition.Y).ToString() + “\r\n”);
    }

    Thank you!

  73. ME says:

    Ok, how can i add a ANIMATED GIF to a marker????
    Image transparent background of weather condition….

    GMapOverlay markersOverlay = new GMapOverlay(“markers”);
    GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528), new Bitmap(“c:\\sunny.gif”));

    If not how can i use a picturebox to do this????

  74. Simon says:

    Great tool. I have a database of postcodes and associated polygons in an SQL geometry field. I would like to plot a post code area. Is this possible ?

  75. Ravan says:

    Great tool.

    But I want to know how to remove a polygon??

  76. Amnanmirza says:

    sir how to cout number of tag images in map at top level .when zoom out images is exple show number of images on city level.

  77. dennis reyes says:

    how can i retrieve latitude and longitude from sql database form the locations on markers? and how can i put multiple markers?.


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">