RouteGetRouteHighlight Method |
Namespace: Telogis.GeoBase.Routing
Route highlighting is used to display the most likely route taken based on a series of RouteStops. This is useful when only the route stops are known, and the actual route taken is not known. In the example below, figure 1 shows three route stops (the arrows depict the vehicle's heading) without a known route. When the "Highlight" button is pressed, GetRouteHighlight() is called, the most likely directions are calculated, and the Route Highlight is displayed on the map, as shown in figure 2.
The route is calculated based on the RouteStops' properties:
If not all of these RouteStop properties are known, the bare minimum that can be used is: Lat, Lon, TimeSincePreviousStop. TimeSincePreviousStop values are automatically limited to a maximum of 300 seconds.
This example is designed with just a MapCtrl, and a button. When the program is loaded, the RouteStops are displayed with their headings. When the button is pressed, the route highlight is rendered on the map. The map's properties are as follows:
// Create a route Route myRoute = new Route(); // Create rendererlist RendererList renderList = new RendererList(); private void btnHiLite_Click(object sender, EventArgs e) { displayDirections(); } private void displayDirections() { // Create directions Directions dir; // Add route highlight dir = myRoute.GetRouteHighlight(); // Add route and highlight directions renderList.Add(dir); // Force redraw mapCtrl.Invalidate(); } private void mapCtrl_Load(object sender, EventArgs e) { // Create stops RouteStop s1 = new RouteStop(37.2981, -120.4979); RouteStop s2 = new RouteStop(37.2952, -120.4906); RouteStop s3 = new RouteStop(37.2839, -120.4948); // Add intervals between stops s1.TimeSincePreviousStop = 0; s2.TimeSincePreviousStop = 120; s3.TimeSincePreviousStop = 180; //Add headings s1.Heading = 90; s2.Heading = 180; s3.Heading = 180; // Add stops to route myRoute.AddStops(new RouteStop[] { s1, s2, s3 }); //Add to renderer mapCtrl.Renderer = renderList; renderList.Add(myRoute); }
Figure 1
Figure 2