|
|
|
date: Sat, 8 Dec 2007 05:46:00 -0800,
group: microsoft.public.mappoint.webservice
back
RE: Find driving distance
Hi Marc
You can find the distance between two lat/longs by getting the route. I know
you stated that you don't need the actual route, and you don't have to use
it, but it is the route that will determine the driving distance between two
points.
To do this, you call the CalculateSimpleRoute method off of the
RouteServiceSoap web service, like this:
LatLong[] routePoints= new LatLong[2];
routePoints[0] = new LatLong();
routePoints[0].Latitude = 40;
routePoints[0].Longitude = -120;
routePoints[1] = new LatLong();
routePoints[1].Latitude = 41;
routePoints[1].Longitude = -121;
Route route = routeService.CalculateSimpleRoute(routePoints, "MapPoint.NA",
SegmentPreference.Shortest);
The parameter called routePoints is just a collection of lat/longs (starting
and ending location). "MapPoint.NA" defines the data source, and
SegmentPreference.Shortest can be set to Shortest, Quickest, or
PreferredRoads.
Once you have your route, the distance is found off of the Itinerary object,
which is a property of the route object, like this:
string distance = route.Itinerary.Distance.ToString();
More info can be found at:
RouteServiceSoap: http://msdn2.microsoft.com/en-us/library/aa502471.aspx
Route object: http://msdn2.microsoft.com/en-us/library/aa502468.aspx
RouteInterary object: http://msdn2.microsoft.com/en-us/library/aa502469.aspx
- FlyboyWhite
http://dotnetadvantage.blogspot.com/
"maa" wrote:
> I would like to find the driving distances between 2 addresses. I can get
> the geocode (lat/long) from the addresses using Find Service. I don't need
> the actual route between the 2 addresses but I do need the shortest distance
> between them. Is there a call for this.
> Thanks,
> Marc
date: Mon, 17 Dec 2007 14:03:54 -0800
author: FlyboyWhite
|
|