Manipulating Polygon using GMap for WPF

Topics: WPF
Mar 22, 2013 at 8:12 AM
Edited Mar 22, 2013 at 9:07 AM
Hi all,

I need to manipulate the polygons on the map but I have encountered some problems.
These are what I need:
  • Left clicking on the map: If a polygon is there, it will be selected for manipulation.
  • After selecting the polygon, when the left mouse button is pressed (and hold) and the clicked area is within the polygon, any moving will shift the polygon to the new location until the left mouse button is released.
  • After selecting the polygon, if the right mouse button is pressed and dragging the mouse left will increase the angle while dragging the mouse right will decrease the angle.
Anyone have any idea how to performs these manipulation? I am able to do the first point which is to select the polygon of interest from the map.

Currently I already have the following events:
  • Map_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) : which will update the latitiude and longtitude whent he mouse is moving within the map.
  • private void MainMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) : which will select and deselect the polygons.
Mar 23, 2013 at 9:57 AM
Point 2, moving the polygon:

Save the Position of the Mouse_down event

In the mouse_move event, get position, subtract it from the saved position, and add the resulting value to every point of the selected polygon.

Point 3: Do you mean to resize the Polygon ("increase the angle")?
Mar 25, 2013 at 1:35 AM
Thanks for the reply.

I will try out your method for moving of the polygon.

For point 3, its regarding to rotating the polygon (ie. rectangle). The angle is according to the map true north. I am trying to emulate something like powerpoint. when the mouse is at the corner and user clicks and drags on it, it will rotate in the direction of mouse move.