Follow by Email

How to obtain current mouse co ordinates in MapInfo MapXtreme

Here i will show you that how can we get the current mouse co ordinates in the MapInfo MapXtreme

private void mapControl1_MouseMove (object sender, MouseEventArgs e)
             System.Drawing.PointF DisplayPoint = new PointF (eX, eY); / / create two-dimensional midpoint of x and y coordinates of the ordered pair
             MapInfo.Geometry.DPoint MapPoint = new MapInfo.Geometry.DPoint (); // create a point layer
             MapInfo.Geometry.DisplayTransform converter =
              this.mapControl1.Map.DisplayTransform; converter.FromDisplay (DisplayPoint, out MapPoint); / / display coordinates of a point into the map coordinates of the point or layer
             this.statusBar1.Text = "Cursor Location:" + MapPoint.x.ToString () + "," + MapPoint.y.ToString ();


DisplayTransform.FromDisplay method (Rectangle, DRect)
Will display the coordinates of the rectangle into a map or a layer of rectangular coordinates.
public void FromDisplay (
Rectangle srcRect,out DRect destRect)
Rectangle srcRect :  display coordinates of the rectangle.
out DRect destRect : map or a layer of rectangular coordinates.

DisplayTransform.ToDisplay method (DPoint, Point) Point of the map or layer into a display point.
public void ToDisplay (
DPoint pntSrc,out Point pntDest )
DPoint pntSrc : maps or layers points out Point pntDest  : display points.


Post a Comment