1

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

Community
  • 1
  • 1
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • Are there any errors in your Javascript console? – Justin Wood Jan 01 '14 at 16:35
  • @JustinWood No errors, no warnings (related to this, that is). I'm getting the info I need too. It's just that I noticed the extra goodies as *altitude* and got excited. Then, disappointed. :) – Konrad Viltersten Jan 01 '14 at 16:37
  • Sounds like there is just no data there. Or they are just not sharing it. – Justin Wood Jan 01 '14 at 16:40
  • So, you say that it's (b), (c), (d) or (e), right? :) – Konrad Viltersten Jan 01 '14 at 16:42
  • That is my guess, yes. – Justin Wood Jan 01 '14 at 16:48
  • I'm not overly excited by that, still hoping that someone else can provide a more discriminating explanation (i.e. suggesting a single of the reasons). Nevertheless, me not being overly excited is by no means a stain on your comment (I'm almost never excited, let alone overly so). Please phrase your comment as a reply so I can upvote it. At the moment it's the best reply and it'll be accepted as the answer shortly if nobody else outshines it. Thanks. :) – Konrad Viltersten Jan 01 '14 at 16:57
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/44279/discussion-between-justin-wood-and-konrad-viltersten) – Justin Wood Jan 01 '14 at 16:59
  • @JustinWood I've set up a test for non-Sweden residents to check the location worldwide. Would you be so kind and check what you get, please? Appreciate the effort. :) – Konrad Viltersten Jan 01 '14 at 17:24

3 Answers3

2

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.

Justin Wood
  • 9,941
  • 2
  • 33
  • 46
2

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

rbrundritt
  • 16,570
  • 2
  • 21
  • 46
  • I've checked with several people and none of them get any data in *data.position.coords.altitude*. Why is the field *altitude* provided if there's no data in it?! – Konrad Viltersten Jan 16 '14 at 10:06
  • It likely will have data is a GPS device is connected to your computer which is compatible with the Windows Location Services in Windows 7/8. – rbrundritt Jan 16 '14 at 10:52
  • Aha, so for the majority of users (if not all) that will see my application from a browser's window, there won't be any information there. I'll need to make a call to the web service to request the data. That's inconvenient... Thanks, anyway. :) – Konrad Viltersten Jan 16 '14 at 11:35
1

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)

user1806949
  • 81
  • 1
  • 3