GPS location

Jun 24, 2010 at 11:36 AM

Hello all

 

Is there any simple way to show the GPS position over the map?

 

Thank you in advance

 

Jesús de Diego

Jun 26, 2010 at 1:20 PM
Edited Jun 26, 2010 at 1:21 PM
Hi!

Yes there is.

1. Create a ICoordinateTransformation between your ICoordinateSystem and WGS84 (see Proj.Net);
2. Attach an event handler to MouseMove;
3. Use e.GetPosition(map) to get mouse position relative to map;
4. Use map.Transform.MapToWorld to get your position in the map ICoordinateSystem;
5. Use MathTransform.Transform from your ICoordinateTransformation to transform the coordinates to WGS84;
6. Convert the coordinates to the required format (h m ss);

Goran
Mar 9, 2011 at 12:12 PM
GoranSiska wrote:
Hi!

Yes there is.

1. Create a ICoordinateTransformation between your ICoordinateSystem and WGS84 (see Proj.Net);
2. Attach an event handler to MouseMove;
3. Use e.GetPosition(map) to get mouse position relative to map;
4. Use map.Transform.MapToWorld to get your position in the map ICoordinateSystem;
5. Use MathTransform.Transform from your ICoordinateTransformation to transform the coordinates to WGS84;
6. Convert the coordinates to the required format (h m ss);

Goran

Hello! I'm very interested to this sample but using the last version I have some problems.

Let's take as an example the Wpf demo project.

In the fourth point you suggest to use the Transform.MapToWorld method of the object called  map. Are you referring to the MapControl object? I can't see any  Transform.MapToWorld

object. 

As an old sharp map 0.9 user, i'm very confused about the mouse events in these new kind of clients.

Thanks for your help.

Salvatore

 

 

 

 

Mar 11, 2011 at 6:29 PM

Hi!

Regarding step 4. Sorry, I have those helpers methods on my extended Mapsui.Map control. Mapsui Map control has methods for converting mouse coordinates to world coordinates. Use Map.View.ViewToWorld.

In MouseMove handler, e.GetPosition(map) is called on map control to get mouse coordinates relative to your map control.

These mouse coordinates need to be transformed in your world coordinates via map.View.ViewToWorld.

The world coordinates now need to be transformed to wgs84 via ICoordinateTransformation (you create the transformation using your coordinate sistem and wgs84 coordinate system)

Goran

 

Mar 13, 2011 at 11:24 AM

Thanks!

Working on it.

Salvatore