We made some changes

Our new forums are here!

Saving money on data

Mint SIM is the perfect way to get cheap data in the U.S.

Don't count Windows Phone out just yet

Dead? Psh. Here are 5 reasons to stick with Windows 10 Mobile

VPN vs. Proxy

The difference between a proxy and a VPN

Latitude attitude

Dell Latitude 7280 is a business laptop with tons of consumer attitude

4K all the way

You probably don't NEED a 4K webcam, but we love Logitech's BRIO 4K anyway

Long live Windows phone

Contrary to popular belief, Windows phone won't die anytime soon

XP-YESSSSSSS

Dell's already awesome XPS 15 gets even better in 2017

Surface Pwn 5

Surface Pro 5, Project NEON details leaked on LinkedIn?

Redefining the PC

Why Microsoft's Surface phone could be MUCH more than a mere 'phone'

Surface table meets Windows 10

Yes, we did put Windows 10 on the original Surface table ... and it rocks

Cream o' the crop

Before buying a Microsoft laptop, check out our pick for the absolute best

Simple and secure, just the way I like it

We think Windows 10 Cloud is a great idea, here's why

uber micro

Halo Wars 2 has something for everyone. Here's our full review.

Oldie but goldie

We reviewed Microsoft's decade-old Surface table

Creators Update comin' at ya

These are the coolest new features in the next big Xbox One update (video)

Buyer's guide

The Razer Blade 14 is the best laptop Razer has to offer

Windows 10 app gems

10 terrific Windows 10 apps you should be using

Tower of power

Here's what we think of Dell's XPS Tower Special Edition

Quite a deal

Grab the complete C# coding bootcamp for $41!

< >
Welcome to the Windows Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 4 of 4
  1. BrilliSoft's Avatar
    Member

    Posts
    12 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
       #1  
    I am creating an app for WP7 that requires the user to find something on a map and somehow point to it. The app will compare the lat/long co-ords that s/he pointed to, to the "correct" lat/long co-ords, to see if s/he found what s/he was meant to find (by checking that the 2 co-ord sets are within a certain distance of each other). Obviously, the zoom level plays a role, so the user will be required to zoom in to a certain point, to make the selection more accurate. My question is twofold: 1) what is the best event to use (not sure click is the best) for the user to tell the app that s/he thinks s/he found what was requested of them; and 2) how can we, from that event, determine the lat/long co-ords that the user found? I realize that it can't be an exact set of co-ords, but a range will do, as will the center of the screen at the point the user triggers the "I found it" event. Any help will be greatly appreciated!
  2. RogueCode's Avatar
    Retired Moderator

    Posts
    76 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    #2  
    If I were you, I would have some form of crosshair floating above the map, so they can see where the exact center is of the map. Then have a button in the app bar or below the map that they press once the crosshair is over what they want.
    On the click event of that button you can get the maps center by: myMap.TargetCenter which has longitude and latitude.

    From there you are going to want to find the distance between the points. But remember that the earth is curved, so you cant just presume that each degree is 100miles etc, because that value changes based on where in the world it is.

    For that you can use the haversine formula:
    a = sin(Δlat/2) + cos(lat1).cos(lat2).sin(Δlong/2)
    c = 2.atan2(√a, √(1−a))
    d = R.c
    //click function
    {
    var lat1 = mapMain.TargetCenter.Latitude;
    var lat2 = //targetlat
    var lon1 = mapMain.TargetCenter.Longitude;
    var lon2 = //targetlong
    var R = 6371; // earth radius in km
    var dLat = DegreeToRadians(lat2 - lat1);
    var dLon = DegreeToRadians(lon2 - lon1);
    lat1 = DegreeToRadians(lat1);
    lat2 = DegreeToRadians(lat2);

    var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
    Math.Sin(dLon / 2) * Math.Sin(dLon / 2) * Math.Cos(lat1) * Math.Cos(lat2);
    var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
    var distance = R * c;
    }

    private double DegreeToRadians(double angle)
    {
    return Math.PI * angle / 180.0;
    }
    BrilliSoft likes this.
  3. BrilliSoft's Avatar
    Member

    Posts
    12 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
       #3  
    Quote Originally Posted by RogueCode View Post
    If I were you, I would have some form of crosshair floating above the map, so they can see where the exact center is of the map. Then have a button in the app bar or below the map that they press once the crosshair is over what they want.
    On the click event of that button you can get the maps center by: myMap.TargetCenter which has longitude and latitude.

    From there you are going to want to find the distance between the points. But remember that the earth is curved, so you cant just presume that each degree is 100miles etc, because that value changes based on where in the world it is.

    For that you can use the haversine formula:
    Thanks, RogueCode. Best solution I've been offered so far!
  4. RogueCode's Avatar
    Retired Moderator

    Posts
    76 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    #4  
    Quote Originally Posted by BrilliSoft View Post
    Thanks, RogueCode. Best solution I've been offered so far!
    Looks like it's the only solution you've been offered :P

Posting Permissions

";