The DistanceTo method takes another location as an argument; the following code shows how to calculate distance between two locations:
//Get the from location
MapPoint.Location fromLocation
= this.findResults.get_Item(ref fromIndex) as MapPoint.Location;
//Get the to location
MapPoint.Location toLocation
= poiResults.get_Item(ref poiIndex) as MapPoint.Location;
//Calculate the distance between the from location and
//to location using the DistanceTo method
double distance = fromLocation.DistanceTo(toLocation);
Another way of calculating the distance between two locations is to call the Distance method on active Map object as shown below:
double distance = app.ActiveMap.Distance(startLocation, endLocation);
Both startLocation and endLocation are of MapPoint.Location type objects.
To learn more about this topic and other related topics, please buy
Programming MapPoint in .NET
0 comments
Post a Comment