通过单击按钮拖动地图而不使用鼠标拖动

Drag map by clicking on a button without using mouse Drag

我有一个问题,如果有人回答我将不胜感激。 我想通过单击按钮而不使用鼠标拖动将地图拖到一侧(例如,向右或向左、向上或向下)。我尝试了很多并搜索了很多答案,但我没有得到它,我不知道该怎么做。 我还使用 C# 编程语言、Windows 表单应用程序和 GMap.Net 库。 非常感谢。

更新:换句话说, I want to make something like that-Navigation bar in GMap

欢迎A.Sajedi使用Whosebug

您的问题的答案很简单,您只需将地图位置 (+, -) 在各个方向(北、南、东、西)移动一个系数即可。

尝试此代码,在添加四个按钮(如附图)并处理那里的点击事件后,您可以根据需要更改 panFactor 移位

    double panFactor = 0.025;

private void btnPanNorth_Click(object sender, EventArgs e)
{
    //   Pan North
    GMapControl1.Position = new PointLatLng(GMapControl1.Position.Lat + panFactor, GMapControl1.Position.Lng);
}

private void btnPanEast_Click(object sender, EventArgs e)
{
    //   Pan East
    GMapControl1.Position = new PointLatLng(GMapControl1.Position.Lat, GMapControl1.Position.Lng + panFactor);
}

private void btnPanSouth_Click(object sender, EventArgs e)
{
    //   Pan South
    GMapControl1.Position = new PointLatLng(GMapControl1.Position.Lat - panFactor, GMapControl1.Position.Lng);
}

private void btnPanWest_Click(object sender, EventArgs e)
{
    //   Pan West
    GMapControl1.Position = new PointLatLng(GMapControl1.Position.Lat, GMapControl1.Position.Lng - panFactor);
}