locked
pos.coordinate.heading value returning as Null. RRS feed

  • Question

  • Hi All,

    I have Implemented the code for getting the value of Heading ,altitude ,latitude using

    LocationTrackerPage.location = new Windows.Devices.Geolocation.Geolocator();

    and the corresponding function as

    onPositionChanged: function (args) {
                 /// Handler for Windows.Devices.Geolocation.Geolocator.onPositionChanged event
                /// Updates the position information on the screen
               /// <param name="args">Information from the onPositionChanged event</param>
                var pos = args.position;
               
                document.getElementById('latitude').innerHTML = pos.coordinate.latitude;
                document.getElementById('longitude').innerHTML = pos.coordinate.longitude;
                document.getElementById('accuracy').innerHTML = pos.coordinate.accuracy;

                if (pos.coordinate.altitude) {
                    document.getElementById("altitude").innerHTML = pos.coordinate.altitude;
                }
                if (pos.coordinate.altitudeAccuracy) {
                    document.getElementById("altitudeAccuracy").innerHTML = pos.coordinate.altitudeAccuracy;
                }
                if (pos.coordinate.heading)
                {
                    document.getElementById("heading").innerHTML = pos.coordinate.heading;
                }
                if (pos.coordinate.speed)
                {
                    document.getElementById("speed").innerHTML = pos.coordinate.speed;
                }
                if (pos.coordinate.timestamp) {
                    document.getElementById("timestamp").innerHTML = pos.coordinate.timestamp;
                }

            },

    I am getting all the values of speed,timestamp,altitudeAccuracy etc....but for heading I am getting Null.

    can you help me in that....is this some problem related with the device or the API is not returning any value.

    Regards,

    Ldm_Metro


    Regards, Ldm_Metro

    Friday, August 24, 2012 4:32 AM

Answers

All replies

  • Hi L,

    The properties available depend on the device.  Take a look at this documentation:

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geocoordinate.aspx

    -Jeff


    Jeff Sanders (MSFT)

    Friday, August 24, 2012 7:16 PM
    Moderator
  • Hi Jeff,

    I went through the link. It says if the value is not available(JavaScript code) then it will display as null.

    But to confirm this I used Sensor diagnostic tool for checking, using this tool  I am getting  the value of heading in degrees.

    but when I am using the metro application for it, it is displaying as Null. So , I guess it is not device problem.


    Regards, Ldm_Metro

    Monday, August 27, 2012 5:27 AM
  • Hi Jeff,

    Any updates regarding the heading value.


    -Ldm

    Wednesday, September 5, 2012 4:39 AM
  • Hi Ldm,

    I am a bit confused... what sort of update are you looking for?  If the value is not available from your device it will be null. 

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, September 5, 2012 11:44 AM
    Moderator
  • Hi Jeff,

    As i have mentioned in the above thread that, the Sensor diagnostic tool  is able to fetch the heading value and it is displaying also.

    It means that the device is providing the value .

    -Ldm


    -Ldm

    Tuesday, September 11, 2012 6:59 AM