Problem with integrating GMaps API to my winForm !

Topics: Windows Forms
Dec 8, 2012 at 2:18 AM

I am a beginner with GMaps, so I almost have no idea how to integrate GMaps into my c# code. I downloaded 'GMap.NET.WindowsForms.dll' and 'GMap.NET.Core.dll' and referenced them in my code. this is so far my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;

namespace MapView
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            // set cache mode only if no internet avaible
            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.MapType = MapType.MapsLT_Map;
            MainMap.MaxZoom = 11;
            MainMap.MinZoom = 1;
            MainMap.Zoom = MainMap.MinZoom + 1;
            MainMap.CurrentPosition = new PointLatLng(54.6961334816182,
            25.2985095977783);

            // map events
            MainMap.OnCurrentPositionChanged += new
            CurrentPositionChanged(MainMap_OnCurrentPositionChanged);
            MainMap.OnTileLoadStart += new TileLoadStart(MainMap_OnTileLoadStart);
            MainMap.OnTileLoadComplete += new
            TileLoadComplete(MainMap_OnTileLoadComplete);
            MainMap.OnMarkerClick += new MarkerClick(MainMap_OnMarkerClick);
            MainMap.OnMapZoomChanged += new MapZoomChanged(MainMap_OnMapZoomChanged);
            MainMap.OnMapTypeChanged += new MapTypeChanged(MainMap_OnMapTypeChanged);
            MainMap.MouseMove += new MouseEventHandler(MainMap_MouseMove);
            MainMap.MouseDown += new MouseEventHandler(MainMap_MouseDown);
            MainMap.MouseUp += new MouseEventHandler(MainMap_MouseUp);
            MainMap.OnMarkerEnter += new MarkerEnter(MainMap_OnMarkerEnter);
            MainMap.OnMarkerLeave += new MarkerLeave(MainMap_OnMarkerLeave);
        }

 

but I am getting a red line under MainMap with the following error: The name 'MainMap' does not exist in the current context. 

Can anyone please tell me what the problem might be?

Dec 8, 2012 at 7:02 AM

check the demo code

Feb 27, 2013 at 12:12 PM
hello, radioman!
I don't found demo code?
where is it?
Feb 27, 2013 at 12:43 PM
in the source files ;}
Apr 27, 2013 at 8:31 AM
MainMap is the name you define in the property of the GmapControl