This project has moved. For the latest updates, please go here.

Distance between two points

Jul 13, 2014 at 8:52 PM
Edited Jul 13, 2014 at 8:52 PM

can you indicate me the way to calculate the distance between two distinct points on the map control?

Thank you very much, your control is very impressive!

Jul 13, 2014 at 8:58 PM
Edited Jul 13, 2014 at 9:59 PM
See here: Great-circle distance and Geodesics on an ellipsoid. For a highly accurate calculation you would usually apply Vincenty's formula.
Jul 14, 2014 at 4:38 AM
Edited Jul 14, 2014 at 4:38 AM
Hi ClemensF,

thank you very much for your quick reply!

That`s fine, now i know what sort of transformation i need to apply.

Next step, could you please indicate me where in th code i should apply it? I need to ask to API the points transformation and the apply alghoritm distance calculation?

Thank you very much!
Jul 14, 2014 at 7:15 AM
Edited Jul 14, 2014 at 7:16 AM
I don't undestand your question. You want me to tell you where in your code you would perform such a calculation? How would I possibly know that?

You should write a method (in one of your application's classes) that takes two Locations as argumens and returns their calculated distance. Then you call this method wherever you need it.
Jul 14, 2014 at 7:36 AM
Hi ClemensF,

is there something special i need to do in xamlmapcontrol in order to have the right calculation? I mean, if i take the two points by mouse, for example, i suppose i need to get the coordinate points returned by XamlMapControl API, right? and then i can calculate the distance beetween that two coordinates, i'm right? or i'm wrong? Maybe, is there something else i need to do? I bag your pardon if the question is trivial for you.

Thank you.
Jul 14, 2014 at 8:30 AM
Right, you simply get a Location from a mouse position by calling MapBase.ViewportPointToLocation (as shown in the MouseMove handler in the sample application). When you've got two Locations, you may perform whatever distance calculations you want.