Route.Specification Property
Route.Specification Property
Contains all the information necessary to calculate a route (RouteSpecification object), including route segments and data source.
Public Specification As RouteSpecification
[C#]
public RouteSpecification Specification;
Remarks
- If the Specification property is null, you must pass the CalculatedRepresentation property as input to the RenderServiceSoap.GetMap or RenderServiceSoap.GetLineDriveMap method.
Example
[Visual Basic]
'Route between two locations
Dim startLocation As New Location()
Dim endLocation As New Location()
startLocation.LatLong = New LatLong()
endLocation.LatLong = New LatLong()
startLocation.LatLong.Latitude = 40
startLocation.LatLong.Longitude = -120
endLocation.LatLong.Latitude = 41
endLocation.LatLong.Longitude = -121
Dim routeSegmentsSpec(1) As SegmentSpecification
routeSegmentsSpec(0) = New SegmentSpecification()
routeSegmentsSpec(0).Waypoint = New Waypoint()
routeSegmentsSpec(0).Waypoint.Name = "Start"
routeSegmentsSpec(0).Waypoint.Location = startLocation
routeSegmentsSpec(1) = New SegmentSpecification()
routeSegmentsSpec(1).Waypoint = New Waypoint()
routeSegmentsSpec(1).Waypoint.Name = "End"
routeSegmentsSpec(1).Waypoint.Location = endLocation
Dim routeSpec As New RouteSpecification()
routeSpec.DataSourceName = "MapPoint.NA"
routeSpec.Segments = routeSegmentsSpec
Dim myRoute As Route
myRoute = routeService.CalculateRoute(routeSpec)
'Remove pieces of the Route object that aren't needed
'so that the information is processed faster
myRoute.CalculatedRepresentation = Nothing
'Store the specification for later use
routeSpec = myRoute.Specification
'Get a map of the route
Dim myRouteView(0) As ViewByHeightWidth
myRouteView(0) = myRoute.Itinerary.View.ByHeightWidth
Dim mapSpec As New MapSpecification()
mapSpec.DataSourceName = "MapPoint.NA"
mapSpec.Route = myRoute
mapSpec.Views = myRouteView
Dim myMaps() As MapImage
myMaps = renderService.GetMap(mapSpec)
[C#]
//Route between two locations
Location startLocation = new Location();
Location endLocation = new Location();
startLocation.LatLong = new LatLong();
endLocation.LatLong = new LatLong();
startLocation.LatLong.Latitude = 40;
startLocation.LatLong.Longitude = -120;
endLocation.LatLong.Latitude = 41;
endLocation.LatLong.Longitude = -121;
SegmentSpecification[] routeSegmentsSpec = new SegmentSpecification[2];
routeSegmentsSpec[0] = new SegmentSpecification();
routeSegmentsSpec[0].Waypoint = new Waypoint();
routeSegmentsSpec[0].Waypoint.Name = "Start";
routeSegmentsSpec[0].Waypoint.Location = startLocation;
routeSegmentsSpec[1] = new SegmentSpecification();
routeSegmentsSpec[1].Waypoint = new Waypoint();
routeSegmentsSpec[1].Waypoint.Name = "End";
routeSegmentsSpec[1].Waypoint.Location = endLocation;
RouteSpecification routeSpec = new RouteSpecification();
routeSpec.DataSourceName = "MapPoint.NA";
routeSpec.Segments = routeSegmentsSpec;
Route myRoute;
myRoute = routeService.CalculateRoute(routeSpec);
//Remove pieces of the Route object that aren't needed
//so that the information is processed faster
myRoute.CalculatedRepresentation = null;
//Store the specification for later use
routeSpec = myRoute.Specification;
//Get a map of the route
ViewByHeightWidth[] myRouteView = new ViewByHeightWidth[1];
myRouteView[0] = myRoute.Itinerary.View.ByHeightWidth;
MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Route = myRoute;
mapSpec.Views = myRouteView;
MapImage[] myMaps = renderService.GetMap(mapSpec);
See Also
Route Class | RouteSpecification Class | RenderServiceSoap.GetMap Method | Route.CalculatedRepresentation Property