This is a migrated thread and some comments may be shown as answers.

Distance between two points

5 Answers 108 Views
Map
This is a migrated thread and some comments may be shown as answers.
Carlos Rodriguez
Top achievements
Rank 1
Carlos Rodriguez asked on 08 Apr 2010, 08:52 PM
You can get the ditancia between two points on the map? No matter if it is not accurate, albeit approximate.

5 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 09 Apr 2010, 04:00 PM
Hi Carlos,

You can use LocationRect object for this purpose:
Location location1 = new Location(37.7040701207995, -121.882780875908);
Location location2 = new Location(37.7140701207995, -121.872780875908);
  
Location northEast = new Location(
    Math.Max(location1.Latitude, location2.Latitude),
    Math.Max(location2.Longitude, location2.Longitude));
  
Location southWest = new Location(
    Math.Min(location1.Latitude, location2.Latitude),
    Math.Min(location1.Longitude, location2.Longitude));
  
LocationRect rect = new LocationRect(northEast, southWest);
rect.MapControl = this.radMap;
  
double distance = Math.Sqrt(rect.Width * rect.Width + rect.Height * rect.Height);

Sincerely yours,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Carlos Rodriguez
Top achievements
Rank 1
answered on 09 Apr 2010, 04:47 PM
It's pretty simple!

thank you very much Andrey!
0
Carlos Rodriguez
Top achievements
Rank 1
answered on 15 Apr 2010, 06:12 PM
I Have problems in this line:

LocationRect rect =
new LocationRect(northEast, southWest);

I get the following manner:

LocationRect rect = newLocationRect(northEast, southWert, With, Height),I can do in this case?
0
Carlos Rodriguez
Top achievements
Rank 1
answered on 15 Apr 2010, 08:02 PM
The above procedure gives me a result in decimal, how I can make the conversion to meters?
0
Andrey
Telerik team
answered on 16 Apr 2010, 02:16 PM
Hi Carlos Rodriguez,

It seems you are using quite old CTP version of the RadMap control. Since first official release of the RadMap in 2010.Q1 the LocationRect class has 2 constructors:

1. LocationRect(double north, double west, double width, double height)
2. LocationRect(Location northEast, Location southWest)

In order to get distance between 2 geographical locations you must use second type of the constructor. It creates rectangle using geographical locations. You can't use the first type of the constructor for this purpose.

Sincerely yours,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Map
Asked by
Carlos Rodriguez
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Carlos Rodriguez
Top achievements
Rank 1
Share this question
or