-1

I had a question and I would appreciate if someone answers. I want to drag the map to one side (for example, right or left, or up or down) by clicking on a button without using a mouse drag. I tried a lot and searched for a lot to answer, but I did not get it and I do not know how to do it. I also use the C # programming language , Windows Form Application and the GMap.Net library. Thank you so much.

Updated : In other words, I want to make something like that-Navigation bar in GMap

A.Sajedi
  • 13
  • 4
  • You told us what you want but you didn't ask a question. Stack Overflow is not a free code-writing service, and anyway no one could write code based on such vague statements. Show us your code. If you don't show us what you “tried” we have no idea what you could be stuck on. – Dour High Arch Oct 21 '18 at 16:44
  • I do not want anyone coding for me. I just wanted to help those who do this work. My question seems to me unambiguous. I want to add a "Navigation bar" to my map so I can Drag the map (without using left mouse click). – A.Sajedi Oct 22 '18 at 05:20
  • I mean, "I tried so much," that I looked at the entire class of GMap.Net and searched for hours on the Internet to answer this question, but it seemed that nobody did it. – A.Sajedi Oct 22 '18 at 05:24
  • How do you see people "clicking on a button", without a mouse click? – AsheraH Oct 22 '18 at 07:09
  • I did not say without mouse clicks. I said, without mouse draging and by clicking on a button!!!! – A.Sajedi Oct 22 '18 at 08:12
  • Did you see the above image uploaded? – A.Sajedi Oct 22 '18 at 08:14

1 Answers1

0

Welcome A.Sajedi to stackoverflow

The answer to your question is very easy, you just have to shift the map position (+, -) by a factor in all directions (north, south, east, west).

Try this code, after adding four buttons like the attached image and handle there click events and you can change the panFactor as you want the shift displacement

    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);
}

enter image description here

Ahmed GIS
  • 513
  • 4
  • 9