/// <summary> /// Return a Route given a start and end location. /// </summary> /// <param name="startLocation">result from the FindLocation method</param> /// <param name="endLocation">result from the FindLocation method</param> /// <param name="segPref">specify if you want the shortest or quickest route</param> /// <returns>Route</returns> public Route GetRoute(Location startLocation, Location endLocation, SegmentPreference segPref) { Route myRoute; try { if (startLocation == null) { throw new System.ArgumentNullException("Start location cannot be null"); } if (endLocation == null) { throw new System.ArgumentNullException("End location cannot be null"); } SegmentSpecification[] routeSegmentsSpec = new SegmentSpecification[2]; routeSegmentsSpec[0] = new SegmentSpecification(); routeSegmentsSpec[0].Waypoint = new Waypoint(); routeSegmentsSpec[0].Waypoint.Name = startLocation.Entity.Name; routeSegmentsSpec[0].Waypoint.Location = startLocation; routeSegmentsSpec[0].Options = new SegmentOptions(); routeSegmentsSpec[0].Options.Preference = segPref; routeSegmentsSpec[1] = new SegmentSpecification(); routeSegmentsSpec[1].Waypoint = new Waypoint(); routeSegmentsSpec[1].Waypoint.Name = endLocation.Entity.Name; routeSegmentsSpec[1].Waypoint.Location = endLocation; routeSegmentsSpec[1].Options = new SegmentOptions(); routeSegmentsSpec[1].Options.Preference = segPref; RouteSpecification routeSpec = new RouteSpecification(); routeSpec.DataSourceName = "MapPoint.NA"; routeSpec.Segments = routeSegmentsSpec; myRoute = theMapPointRouteService.CalculateRoute(routeSpec); } catch (ArgumentNullException e) { throw e; // rethrow for app to handle } catch (Exception e) { throw e; // rethrow for app to handle } return(myRoute); }
/// <remarks/> public void CalculateSimpleRouteAsync(LatLong[] latLongs, string dataSourceName, SegmentPreference preference, object userState) { if ((this.CalculateSimpleRouteOperationCompleted == null)) { this.CalculateSimpleRouteOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCalculateSimpleRouteOperationCompleted); } this.InvokeAsync("CalculateSimpleRoute", new object[] { latLongs, dataSourceName, preference}, this.CalculateSimpleRouteOperationCompleted, userState); }
/// <remarks/> public void CalculateSimpleRouteAsync(LatLong[] latLongs, string dataSourceName, SegmentPreference preference) { this.CalculateSimpleRouteAsync(latLongs, dataSourceName, preference, null); }
public Route CalculateSimpleRoute(LatLong[] latLongs, string dataSourceName, SegmentPreference preference) { object[] results = this.Invoke("CalculateSimpleRoute", new object[] { latLongs, dataSourceName, preference}); return ((Route)(results[0])); }
/// <summary> /// This method returns the direction (itinerary) between a starting and ending location /// </summary> /// <param name="startLocation">Starting location</param> /// <param name="endLocation">Ending location</param> /// <param name="segPref">specify the shortest or quickest route</param> /// <returns>a RouteItinerary - just the directions portion of a route</returns> public RouteItinerary GetRouteDirections(Location startLocation, Location endLocation, SegmentPreference segPref) { Route myRoute; try { if (startLocation == null) { throw new System.ArgumentNullException("Start location cannot be null"); } if (endLocation == null) { throw new System.ArgumentNullException("End location cannot be null"); } SegmentSpecification[] routeSegmentsSpec = new SegmentSpecification[2]; routeSegmentsSpec[0] = new SegmentSpecification(); routeSegmentsSpec[0].Waypoint = new Waypoint(); routeSegmentsSpec[0].Waypoint.Name = startLocation.Entity.Name; routeSegmentsSpec[0].Waypoint.Location = startLocation; routeSegmentsSpec[0].Options = new SegmentOptions(); routeSegmentsSpec[0].Options.Preference = segPref; routeSegmentsSpec[1] = new SegmentSpecification(); routeSegmentsSpec[1].Waypoint = new Waypoint(); routeSegmentsSpec[1].Waypoint.Name = endLocation.Entity.Name; routeSegmentsSpec[1].Waypoint.Location = endLocation; routeSegmentsSpec[1].Options = new SegmentOptions(); routeSegmentsSpec[1].Options.Preference = segPref; RouteSpecification routeSpec = new RouteSpecification(); routeSpec.DataSourceName = "MapPoint.NA"; routeSpec.ResultMask = RouteResultMask.Itinerary; routeSpec.Segments = routeSegmentsSpec; myRoute = theMapPointRouteService.CalculateRoute(routeSpec); } catch (ArgumentNullException e) { throw e; // rethrow for app to handle } catch (Exception e) { throw e; // rethrow for app to handle } return myRoute.Itinerary; }
/// <remarks/> public System.IAsyncResult BeginCalculateSimpleRoute(LatLong[] latLongs, string dataSourceName, SegmentPreference preference, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CalculateSimpleRoute", new object[] { latLongs, dataSourceName, preference}, callback, asyncState); }