2

I'm learning to create windows 8 apps and I'm stumped as regards something.

Say I am in London. And I want to find Trafalgar square relative to where I am standing. But based on a compass. So for example if I am south of trafalgar, regardless of how far away, the compass would point north.

How on earth do I get access to the tablet's location to then calculate where it is, relative to that location?

David G
  • 6,803
  • 4
  • 28
  • 51
  • Perhaps here http://msdn.microsoft.com/en-us/library/windows/desktop/dd317749(v=vs.85).aspx – mplungjan Jul 16 '13 at 04:17
  • Do you mean with or without GPS? It sounds like you want to do it without. Unless I misunderstood, it sounds easy with GPS. Can you add the sensors you have available on your tablet? – Kaushal De Silva Jul 24 '13 at 03:55

1 Answers1

3

Here is the link for the geolocation sample in Windows 8: Windows 8 Geolocation Sample

You can check the samples in C#, JavaScript, and C++. Below is the specific part where it shows the latitude and longitude in JavaScript. You can find the corresponding in C++/C# by browsing through the code samples:

JavaScript

function getPositionHandler(pos) {
    document.getElementById('latitude').innerHTML = pos.coordinate.latitude;
    document.getElementById('longitude').innerHTML = pos.coordinate.longitude;
    document.getElementById('accuracy').innerHTML = pos.coordinate.accuracy;
    document.getElementById('geolocatorStatus').innerHTML =
        getStatusString(loc.locationStatus);
}

Regarding location of Trafalgar Square, I'm sure Bing Maps API or Google Maps API, or any Maps API will help in finding the specific longitude and latitude.

I also suggest you take a look at this StackOverflow post regarding longi/latitude: Link

I also have given a link for a code snippet to find lat/long using Google Maps API: Link

To parse the direction, you might have to write your own function, which shouldn't be too difficult.

Hope this helps in your app development!

Edit: I have also attached two links for determining distance and bearing with two latitudes. They are both pretty much the same: Link 1, Link 2. They explain the concepts very well.

Second Edit: Did you catch your pun? >> How on earth do I get access to the tablet's location to then calculate where it is, relative to that location?

Community
  • 1
  • 1
asuprem
  • 554
  • 1
  • 5
  • 17