我的问题是我在运行应用程序时无法在表单上看到任何内容。这是我的代码:
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;
using GMap.NET;
using GMap.NET.WindowsForms;
namespace Gmap_tesx
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e1)
{
try
{
System.Net.IPHostEntry e =
System.Net.Dns.GetHostEntry("www.google.com");
}
catch
{
gMapControl1.Manager.Mode = AccessMode.CacheOnly;
MessageBox.Show("No internet connection avaible, going to CacheOnly mode.",
"GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
// config map
GMaps.Instance.Mode = AccessMode.ServerAndCache;
// gMapControl1.CacheLocation = Application.StartupPath + "data.gmdp";
GMaps g = new GMaps();
gMapControl1.MapType = MapType.GoogleSatellite;
gMapControl1.MaxZoom = 6;
gMapControl1.MinZoom = 1;
gMapControl1.Zoom = gMapControl1.MinZoom + 1;
gMapControl1.Position = new PointLatLng(54.6961334816182,
25.2985095977783);
// map events
gMapControl1.OnCurrentPositionChanged += new
CurrentPositionChanged(gMapControl1_OnCurrentPositionChanged);
gMapControl1.OnTileLoadStart += new TileLoadStart(gMapControl1_OnTileLoadStart);
gMapControl1.OnTileLoadComplete += new
TileLoadComplete(gMapControl1_OnTileLoadComplete);
gMapControl1.OnMarkerClick += new MarkerClick(gMapControl1_OnMarkerClick);
gMapControl1.OnMapZoomChanged += new MapZoomChanged(gMapControl1_OnMapZoomChanged);
gMapControl1.OnMapTypeChanged += new MapTypeChanged(gMapControl1_OnMapTypeChanged);
gMapControl1.MouseMove += new MouseEventHandler(gMapControl1_MouseMove);
gMapControl1.MouseDown += new MouseEventHandler(gMapControl1_MouseDown);
gMapControl1.MouseUp += new MouseEventHandler(gMapControl1_MouseUp);
gMapControl1.OnMarkerEnter += new MarkerEnter(gMapControl1_OnMarkerEnter);
gMapControl1.OnMarkerLeave += new MarkerLeave(gMapControl1_OnMarkerLeave);
}
private void gMapControl1_OnCurrentPositionChanged(PointLatLng point)
{
}
private void gMapControl1_OnMarkerLeave(GMapMarker item)
{
}
private void gMapControl1_OnMarkerEnter(GMapMarker item)
{
}
private void gMapControl1_MouseUp(object sender, MouseEventArgs e)
{
}
private void gMapControl1_MouseDown(object sender, MouseEventArgs e)
{
}
private void gMapControl1_MouseMove(object sender, MouseEventArgs e)
{
}
private void gMapControl1_OnMapTypeChanged(MapType type)
{
}
private void gMapControl1_OnMapZoomChanged()
{
}
private void gMapControl1_OnMarkerClick(GMapMarker item, MouseEventArgs e)
{
}
private void gMapControl1_OnTileLoadComplete(long ElapsedMilliseconds)
{
}
private void gMapControl1_OnTileLoadStart()
{
}
}
}
答案 0 :(得分:0)
尝试添加:
using Gmap.NET.MapProviders;
软件它可以解决你的问题,因为我确实有类似的东西。 另外,检查是否已将Gmap.WindowsForms dll添加到IDE工具箱中!