The LocatorProxy
class is similar to the class with the same name we wrote in the previous chapter; however, this time it generates a URL that points to the Routes API:
public class LocatorProxy { private const string MAP_KEY = "[YOUR BING MAPS KEY]"; private const string REST_URL = "http://dev.virtualearth.net/REST/V1/Routes/Driving?rpo=Points"; }
The Routes API URL template expects a set of parameters, including (see the full list at http://msdn.microsoft.com/en-us/library/ff701717.aspx):
waypoint.n (or wp.n)
: required, is a list of sequential locations that define the route, such as addresses, landmarks, or geographical pointsviaWaypoint.n (or vwp.n)
: optional, specifies intermediate locations between two waypointsavoid
: optional, indicates the road types (highways, tolls) to minimize or avoid when a driving route is constructed
Now, let's write the method that communicates with the API:
public static void QueryRoute(string[] places, Action<RouteInfo> callback) {...