Share via


MapSpecification.Route Property

The route (Route object) to render on the map.

Public Dim Route As [Namespace].Route
    Member of [Namespace].MapSpecification
[C#]
public [Namespace].Route Route
    Member of [Namespace].MapSpecification

Remarks

  • If the Route property is passed and the Views property is null, the map view of the entire route is used. If both the Route and Views properties are null, a SOAP fault is returned.
  • To render a route, the passed Route object must contain at least a Route.CalculatedRepresentation or a Route.Specification property (the Route.Itinerary property is ignored). If it contains just a Route.Specification property, the RenderServiceSoap.GetMap method calls the route service to calculate the route. For increased performance when rendering a map of a route, pass the Itinerary and Specification properties as null.
  • If the Route.CalculatedRepresentation property is located outside the area defined by the Views property, the RenderServiceSoap.GetMap method returns a map image without error. This is to allow panning a route map such that the route is no longer in view.

Example

 
[Visual Basic] 
'This example assumes that the service instances 
''routeService' and 'renderService' have already 
'been created and that the MapPoint Web Service namespace 
'has been imported 

'Route between two locations
Dim latLongs(1) As LatLong
latLongs(0) = New LatLong()
latLongs(1) = New LatLong()
latLongs(0).Latitude = 40
latLongs(0).Longitude = -120
latLongs(1).Latitude = 41
latLongs(1).Longitude = -121

Dim myRoute As Route
myRoute = routeService.CalculateSimpleRoute(latLongs, "MapPoint.NA", SegmentPreference.Quickest)

'Get a map of the route
Dim myRouteViews(0) As ViewByHeightWidth
myRouteViews(0) = myRoute.Itinerary.View.ByHeightWidth

Dim mapSpec As New MapSpecification()
mapSpec.DataSourceName = "MapPoint.NA"
mapSpec.Route = myRoute
mapSpec.Views = myRouteViews

Dim myMaps() As MapImage
myMaps = renderService.GetMap(mapSpec)

 
[C#]
//This example assumes that the service instances 
//'routeService' and 'renderService' have already 
//been created and that the MapPoint Web Service namespace 
//has been imported 

//Route between two locations
LatLong[] latLongs = new LatLong[2];
latLongs[0] = new LatLong();
latLongs[1] = new LatLong();
latLongs[0].Latitude = 40;
latLongs[0].Longitude = -120;
latLongs[1].Latitude = 41;
latLongs[1].Longitude = -121;

Route myRoute = routeService.CalculateSimpleRoute(latLongs, "MapPoint.NA", SegmentPreference.Quickest);

//Get a map of the route
ViewByHeightWidth[] myRouteViews = new ViewByHeightWidth[1];
myRouteViews[0] = myRoute.Itinerary.View.ByHeightWidth;

MapSpecification mapSpec  = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Route = myRoute;
mapSpec.Views = myRouteViews;

MapImage[] myMaps = renderService.GetMap(mapSpec);

 

See Also

MapSpecification Class | Route Class | MapSpecification.Views Property | Route.CalculatedRepresentation Property | Route.Specification Property | Route.Itinerary Property | RenderServiceSoap.GetMap Method