Jul 1, 2009

Windows Mobile 6 with C# (GPS)

It's been some time since my last fun project. So after getting my brand new HTC Touch Diamond 2 I thought about ending this period and digging somewhat into C#.NET mobile device development.

As I am new to this platform I first browsed through the Mobile SDK samples to get an idea about the slighty restricted framework capabilities. An initial MyApp application was easily created using the older Visual Studio 2005. Changing the main form to my special 800x480 screen resolution did not work properly, so the designer does not represent my device screen.

The fact that my HTC has a built-in GPS device fascinated me very much. So I had a closer look at the GPS application GPS sample and copied some classes into MyApp. Instantiating goes like this:

   55 this.gps = new Gps();

   56 gps.DeviceStateChanged += new DeviceStateChangedEventHandler(gps_DeviceStateChanged);

   57 gps.LocationChanged += new LocationChangedEventHandler(gps_LocationChanged);

getting a GpsPosition class instance with the following major fields:

//** Position + heading related

internal double dblLatitude = 0.0;            // Degrees latitude.  North is positive

internal double dblLongitude = 0.0;           // Degrees longitude.  East is positive

internal float flSpeed = 0.0f;                // Speed in knots

internal float flHeading = 0.0f;              // Degrees heading (course made good).  True North=0

internal double dblMagneticVariation = 0.0;   // Magnetic variation.  East is positive

internal float flAltitudeWRTSeaLevel = 0.0f;  // Altitute with regards to sea level, in meters

internal float flAltitudeWRTEllipsoid = 0.0f; // Altitude with regards to ellipsoid, in meters

After a couple of seconds running the application I got my first position. Output formatted as string was fine ... for the first day ;-)


  1. Hi Markus,

    Thanks for the post. I have a requirement to develop a windows mobile application, where I need to capture GPS co-ordinates when I take a picture with the mobile camera. How can we do this? Could you please share your ideas/any samples/references etc.


  2. Hi! Markus
    Thanks for the post. I need to get coordinate with c#but we didnt get any coordinate
    can you help to me ?
    Can you give to me codes ?