Question

I'm executing the code below to fetch the current position of the user. It works dandy but I'm only getting the "flat" information - altitude and longitude - while altitude is null. Can that be remedied and, if so, how?

var geolocationProvider = new Microsoft.Maps
  .GeoLocationProvider(map).getCurrentPosition({
    successCallback: function(data) {
      var latitude = data.position.coords.latitude;
      var longitude = data.position.coords.longitude;
      var altitude = data.position.coords.altitude;
    } ...
});

Please note that I'm looking for a solution based on JavaSCript calls (currently avoiding RESTing and WCFing). Might the issue be coming up because of:
a. problems with my code (bug or syntax getting data)
b. problems at the particular locations (spots with no data)
c. lack of altitude data on Bing Maps (no data at MS at all)
d. insufficient rights for my account (no data for my license)
e. wrong platform applied (no data for JS control approach)
f. other?

When I F12 the thing I see this.

data.position.coords

Coordinates {speed: null, heading: null, altitudeAccuracy: null, accuracy: 34, altitude: null…} accuracy: 34
altitude: null
altitudeAccuracy: null
heading: null
latitude: 59.333358800000006
longitude: 18.0567974
speed: null
__proto__: Coordinates

Was it helpful?

Solution

The altitude information would be returned if it's available. The location API that powers this uses several different methods to determine a users location; GPS, WIFI triangulation, IP address. Only the GPS method would be able to provide the users true altitude. Wifi triangulation could provide an approximate one but is generally not returned due to error.

If you want to get the elevation of the ground for where the user is then this could be retrieved from the Bing Maps Elevation service: http://msdn.microsoft.com/en-us/library/jj158959.aspx

OTHER TIPS

Based on our discussion in the chat, I would have to wager a guess that they currently do not have the altitude data, or they are just not willing to share at the moment.

var geo_options = { enableHighAccuracy: true, maximumAge : 30000, timeout : 27000 };

navigator.geolocation.watchPosition(showPosition, null, geo_options);

// Will have the altitude populated when using Chrome or FF (2019/01/31)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top