Latitude and Longitude

May 4, 2015 at 4:07 PM
I'm using your MAPWINGIS with great satisfaction and I thank you.
I can not, however, to obtain a given that it would appear easy to read but that has not proven this.
I wish I knew how to capture the coordinates of latitude and longitude that appear on the map in the top right, in the format as shown.
I apologize for my English (thanks to Google Translator) I salute you.

May 5, 2015 at 8:45 AM
Edited May 5, 2015 at 9:04 AM
Hi, here is a code sample. You can format the resulting coordinates in whatever way you like. Please see more on map projection and coordinates here.
private void Init()
    axMap1.SendMouseMove = true;
    axMap1.MouseMoveEvent += axMap1_MouseMoveEvent;     // "plus=" operator to attach an event handler

void axMap1_MouseMoveEvent(object sender, AxMapWinGIS._DMapEvents_MouseMoveEvent e)
    if (axMap1.Measuring.IsUsingEllipsoid)
        // if map projection is set and there is known conversion to decimal degrees
        double degX = 0.0, degY = 0.0;
        axMap1.PixelToDegrees(e.x, e.y, ref degX, ref degY);
        double projX = 0.0, projY = 0.0;
        axMap1.PixelToProj(e.x, e.y, ref projX, ref projY);
Hope it helps,
May 5, 2015 at 9:14 AM
oohh thaks you very much

May 5, 2015 at 1:50 PM
Edited May 5, 2015 at 1:51 PM
Thank you but not exactly what I was looking, I think.
Let me give you a practical example.
I created a map in my area (Lazio, Italy) in georeferenced TIFF format.
In fact, when I load the map, this fits perfectly with the underlying default map OpenStreetMap.
If you move the mouse over the map and I position for example the Colosseum in Rome, by the routine

Private Sub map0_MouseMove (ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
Xx As Double Dim: Dim Yy As Double
Map0.PixelToProj x, y, Xx, Yy
Lat = Yy
Lon = Xx
End Sub

I get the following values
Latitude: 5116036.38692499 (Lat)
Longitude: 1390643.13778291 (Lon)

while in the map at the top right shows the following values
Lat: 41.890
Lon: 12.492.

How do I get these two values?
How to intercept them to carry in two variables?

I hope I was clear.

Thank you.

May 5, 2015 at 1:55 PM
To get degrees you should use PixelToDegrees (see original answer). The values you are getting are in map units (presumably Google Mercator projection).
axMap1.PixelToDegrees(e.x, e.y, ref degX, ref degY);
May 5, 2015 at 2:12 PM
I've tried to use both
 Map0.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR
 Map0.PixelToDegrees x, y, Xx, Yy
Map0.Projection = tkMapProjection.PROJECTION_WGS84
Map0.PixelToDegrees x, y, Xx, Yy
but in any case I did not get the values

Lat: 41.890
Lon: 12.492.

However, using the functions
I can get the exact coordinates of the center of the map without resorting to any kind of conversion.

What drives me crazy is that if the default map display latitude and longitude in the upper right corner as information, they must be inevitably already available without having to convert the pixels more ....
May 5, 2015 at 4:09 PM
Strange indeed, this method is working for me. You can also try to do the conversion in 2 steps: PixelToProj and then ProjToDegrees. Another option is to convert Google Mercator coordinates you are getting to WGS84 with the instance of GeoProjection class. Also make sure to set application callback to know if something wrong is happening inside.
May 5, 2015 at 4:27 PM
The only thing I want to get the coordinates are indicated by the red arrows in the picture attached.
If they are visible on the map, must be able to read ....
May 5, 2015 at 4:53 PM
Internally MapWinGIS uses an instance of GeoProjection class with initialized transformation from map coordinate system (GoogleMercator in your case) to the WGS84 coordinate system to display the lat/lon values you see on screen. There is no way to access these values via API. However as I said you can run the same transformation in your code.

Jun 15, 2015 at 11:36 AM
I try to show cursor coordinate in a separate control, e.g. LABEL, while mouse move (by implementing the mouse move event as shown above).
My problem is that the update rate of the control is very slow compared to the built-in coordinates on the map.

How to make the update rate of the control as fast as the built-in shown coordinates?