Jason
Jason

Reputation: 51

Access RoutePath from Bing Maps AJAX Control

How can I access the RoutePath Class when using the Bing Maps AJAX Control, Version 7.0?

I've loaded the directions module, calculated directions and called the getRouteResult method of the DirectionsManager Class. Unfortunately, it doesn't return the coordinates of the actual route.

Ultimately, I need the coordinates of the shape which makes up the route line.

Upvotes: 0

Views: 460

Answers (1)

Jason
Jason

Reputation: 51

Thanks to some help from Microsoft, I've found how RoutePath is exposed. Access RoutePath by:

DirectionsManagerObj.getRouteResult().routeLegs[routeLegIndex]
    .subLegs[subLegIndex].routePath;

This works great assuming you have two waypoints. Otherwise, you'll need to loop through routeLegs and subLegs to get the entire route.

A routeLeg represents the path through two waypoints. A subLeg represents the path through a stop point and via point (or two via points). The DirectionsManager Class API has more detail on this information.

Upvotes: 1

Related Questions