Telogis.GeoBase.MapLayers.RouteLayer |
MapLayers.RouteLayer inherits from MapLayers.CanvasLayer.
A class used for displaying a path or route described by a sequence of latitude-longitude coordinates. This may be constructed with the directions generated by a routing call. Note also that this layer can be used for any arbitrary path: not necessarily ones generated by routing calls.
// Method 1: // First create a route (myRoute) and a map object (map) // Then use getDirections or getQuickDirections to retrieve directions myRoute.getQuickDirections(function (result) { // Wrap the RouteLayer constructor within the callback function directionsRouteLayer = new Telogis.GeoBase.MapLayers.RouteLayer({ id: 'route_directions', map: map, // Pass the directions object to the RouteLayer directions: result, lineColor: new Telogis.GeoBase.Color(0,18,255,0.5), lineWidth: 4, show: true }); }, function (error) {alert(error)} ); // Method 2: // Or, alternatively, create a RouteLayer object without directions myRouteLayer = new Telogis.GeoBase.MapLayers.RouteLayer({ id: 'route_directions', map: map, lineColor: new Telogis.GeoBase.Color(0,18,255,0.5), lineWidth: 4, show: true }); // Then use getDirections or getQuickDirections to set the points of the RouteLayer // setPoints may also be used with an arbitrary array of LatLons myRoute.getQuickDirections(function (result) { myRouteLayer.setPoints(result.getPoints()); myRouteLayer.show(); }, function (error) {alert(error)} );
Name | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MapLayers.RouteLayer(config) | Arguments
|
Name | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
addStopAt (LatLon stop, Number index) | Adds a Routing.RouteStop to the route at a specified location in the list of stops. JavaScript // Create a RouteLayer object without directions myRouteLayer = new Telogis.GeoBase.MapLayers.RouteLayer({ id: 'route_directions', map: map, lineColor: new Telogis.GeoBase.Color(0,18,255,0.5), lineWidth: 4, show: true }); // Add stops at indexes 1 and 2 myRouteLayer.addStopAt(new Telogis.GeoBase.LatLon(33.554736,-117.706501), 1); myRouteLayer.addStopAt(new Telogis.GeoBase.LatLon(33.612914,-117.745395), 2);
| |||||||||
addWaypointAt (LatLon stop, Number index) | Adds a Routing.Waypoint to the route at a specified location in the list of stops. JavaScript // Create a RouteLayer object without directions myRouteLayer = new Telogis.GeoBase.MapLayers.RouteLayer({ id: 'route_directions', map: map, lineColor: new Telogis.GeoBase.Color(0,18,255,0.5), lineWidth: 4, show: true }); // Add stop at index 0 -- Waypoints cannot be the start or end of a route. myRouteLayer.addStopAt(new Telogis.GeoBase.LatLon(33.567888,-117.752183), 0); // Add waypoints at indexes 1 and 2 myRouteLayer.addWaypointAt(new Telogis.GeoBase.LatLon(33.554736,-117.706501), 1); myRouteLayer.addWaypointAt(new Telogis.GeoBase.LatLon(33.612914,-117.745395), 2); // Add stop at index 3 myRouteLayer.addStopAt(new Telogis.GeoBase.LatLon(33.590845,-117.702854), 3);
| |||||||||
appendStop (LatLon stop) | Adds a Routing.RouteStop to the route, at the end of the ordered list of stops. Arguments
| |||||||||
appendStops (Array stops) | Adds all supplied Routing.RouteStops to the route at the end of the ordered list of stops. JavaScript // Create a RouteLayer object without directions myRouteLayer = new Telogis.GeoBase.MapLayers.RouteLayer({ id: 'route_directions', map: map, lineColor: new Telogis.GeoBase.Color(0,18,255,0.5), lineWidth: 4, show: true }); // Add a stop at end of the route list. Not the stop the route must end at. myRouteLayer.appendStop(new Telogis.GeoBase.LatLon(33.567888,-117.752183));
| |||||||||
appendWaypoint (LatLon stop) | Adds a Routing.Waypoint to the route, at the end of the ordered list of stops. Arguments | |||||||||
canGetDirections () | Tests whether a representative Routing.Directions object can be calculated for the route. That is, that the route contains a minimum of two stops, and that neither the first nor last stop on the route is a Routing.Waypoint. JavaScript // Create a RouteLayer object without directions myRouteLayer = new Telogis.GeoBase.MapLayers.RouteLayer({ id: 'route_directions', map: map, lineColor: new Telogis.GeoBase.Color(0,18,255,0.5), lineWidth: 4, show: true }); // Add stops. myRouteLayer.appendStop(new Telogis.GeoBase.LatLon(33.567888,-117.752183)); myRouteLayer.appendStop(new Telogis.GeoBase.LatLon(33.590845,-117.702854)); // Check that a directions object can be retrieved for the route if (myRouteLayer.canGetDirections()) { // Yes (true)... myRouteLayer.getDirections(function (callback) { myRouteLayer.setPoints(callback.getPoints()); myRouteLayer.show(); }, function (error) {alert(error)} ); } else { // No (false).. alert('Unable to generate a directions object for this route.\n\n- Are there at least two stops ' + 'on the route?\n- Is the start and/or the end a waypoint (not permitted)?'); } Boolean - True if a Routing.Directions object can be calculated for the route; false otherwise. | |||||||||
DragMarkerTemplate () | Creates a custom drag marker icon. Used when route is draggable. ReturnsCanvas.Shapes.AbstractShape - The custom shape. | |||||||||
getDirections (Function callback, Function errorCallback, String units, String culture, Object server) | Calculates the route and passes a representative Routing.Directions object to the specified callback. Arguments
| |||||||||
getEnd () | Gets the location that the Routing.Routemust end at. If no end has been specified for the route, null is returned. ReturnsLatLon - The location that the route ends at. | |||||||||
getPath () | Gets the Canvas.Shapes.Path that is displayed on this layer. ReturnsCanvas.Shapes.Path - The path shown on this layer. | |||||||||
getStart () | Gets the location that the Routing.Routemust begin at. If no start has been specified for the route, null is returned. ReturnsLatLon - The location that the route starts at. | |||||||||
getStop (Number i) | Finds the stop at a given placing in the route. Arguments
LatLon - The stop at position Routing.Route.getStop.i in the route. | |||||||||
getStopCount () | Finds how many stops there are in the route. ReturnsNumber - The number of stops that the route is comprised of. | |||||||||
OnDirectionsError (Telogis.Errors.GeoBaseError error) | A callback to execute if an error or timeout occurs when fetching directions. Arguments
| |||||||||
OnDirectionsGenerated (Routing.Directions directions) | The function to call when the directions have been fetched. Arguments
| |||||||||
OnStopAdded (Object RouteStopBinder) | Called after a stop has been added to the route. Arguments
| |||||||||
optimize (Function callback, Function errorCallback, Object server) | Rearranges the route's stops for maximum efficiency by the current routing strategy. While a callback function is triggered, the results of the optimization call (a differently-ordered array of stops) are automatically used to modify the route, so no parameters are passed to it. Arguments
| |||||||||
removeStopAt (Number index) | Removes the stop at the specified index from the route. Arguments
| |||||||||
reset () | Clears all stops and directions. | |||||||||
RouteStopTemplate (String type, MapLayers.RouteLayer routelayer) | Creates a custom Routing.RouteStop icon. Arguments
Object - An object containing methods used to draw a custom RouteStop Icon. | |||||||||
setEnd (LatLon stop) | Specifies a location that the Routing.Routemust end at. This stop is not displaced during optimization. If an end was already specified for the route, it is overridden. Arguments
| |||||||||
setPoints (Array points) | Changes the list of coordinates that describe the route being drawn on the layer. Arguments
| |||||||||
setStart (LatLon stop) | Specifies a location that the Routing.Routemust begin at. This stop is not displaced during optimization. If a start was already specified for the route, it is overridden. Arguments
| |||||||||
setStrategy (Routing.RoutingStrategy strategy) | Sets the technique used to optimize the route. Arguments
| |||||||||
show () | Shows the layer on the map. See AbstractDOMEntity.show for arguments and more information. | |||||||||
useTraffic (Object trafficConfig) | Specifies traffic parameters to be used when calculating and optimizing the Routing.Route. The supplied configuration will replace the existing traffic configuration. Examples: JavaScript route.useTraffic({}); route.useTraffic({source: "LosAngeles"}); route.useTraffic({source: "LosAngeles", time: new Date()}); route.useTraffic({source: "LosAngeles", time: "01-Jan-2008 12:00:00"});
|