EMAPI.Router

Responsible class for routing and visualizing routes on the map.

Summary
EMAPI.RouterResponsible class for routing and visualizing routes on the map.
Functions
EMAPI.RouterThe constructor of a new instance EMAPI.Router class.
addWaypointAdds a new waypoint to the list of wayPoints.
setWaypointChange the location of the waypoint.
removeWaypointsRemoves all waypoints from the list of wayPoints.
removeWaypointDeletes the selected way point from the list of wayPoints.
swapWaypointReplaces in order two selected from the list of wayPoints.
calculateRouteCalculates a route between points placed in the list of wayPoints after the selected vehicle, driver and routing parameters.
activateRouteActivates the selected route from the calculated alternative routes.
driversReturns the list of drivers during routing
vehiclesReturns the list of vehicles used during routing
wayPointsReturns the list of waypoints.
routeRepresentationReturns result of calculated route.

Functions

EMAPI.Router

The constructor of a new instance EMAPI.Router class.

Parameters

obj{Object} An object of EMAPI.Map class or text client token.
options{Object} An object with additional parameters of class instance e.g.  preserveViewport (turning off maps repositioning), forceCalc (automatic routing after changes), reportPointsHandlerPointsName (element’s ID on website which have to contain the list of waypoints), reportResultHandlerName (element’s ID on website which have to contain route report).

addWaypoint

addWaypoint: function(lonLat,
pointType,
callback)

Adds a new waypoint to the list of wayPoints.  Data transmitted to the third parameter substituted the features included:

  • degeocoded information about the geographical position of the point (routePlanEntryDescription)
  • error code (result: 0 = ok, 1 = incorrect type of point, 2 = prohibited the location of the point)

Parameters

lonLat{EMAPI.LonLat} EMAPI.LonLat object representing the type of waypoint coordinates.
pointType{Integer} Type a waypoint: 0 = starting point, 1 = waypoint, 2 = final via point.  Via point is always added before the final one.
callback{Function} The geographic data function of designated point.

setWaypoint

setWaypoint: function(index,
lonLat,
callback)

Change the location of the waypoint.  Data transmitted to the third parameter substituted the features included:

  • degeocoded information about the geographical position of the point (routePlanEntryDescription)
  • error code (result: 0 = ok, 1 = incorrect point’s index, 2 = prohibited the location of the point)

Parameters

index{Integer} The index of waypoint in the wayPoints list: 0 = starting point, etc.
lonLat{EMAPI.LonLat} EMAPI.LonLat object representing the type of the geographical waypoint coordinates.
callback{Function} The geographic data function of designated point.

removeWaypoints

removeWaypoints: function()

Removes all waypoints from the list of wayPoints.

removeWaypoint

removeWaypoint: function(index)

Deletes the selected way point from the list of wayPoints.

Parameters

index{Integer} The index of waypoint in the wayPoints.

swapWaypoint

swapWaypoint: function(firstPointIndex,
secondPointIndex)

Replaces in order two selected from the list of wayPoints.

Parameters

firstPointIndex{Integer} Index of the first replace waypoint in the list of wayPoints.
secondPointIndex{Integer} Index of the second replace waypoint in the list of wayPoints.

calculateRoute

calculateRoute: function(vehicle,
driver,
roadType,
routeOptions,
callback,
force)

Calculates a route between points placed in the list of wayPoints after the selected vehicle, driver and routing parameters.  Data passed to the function in parameter substituted include:

  • the results and routing report (routeRepresentation being an object of EMAPI.Router.RouteRepresentation class)
  • statistics of using different types of roads (roadResults which contains an array of statistics for each type of road i.e. length, time and the cost of the route on the roads of this type, available road types correspond to the values of the EMAPI.Router.RoadParams.roadType)
  • error code (result: 0 = ok, 1 = route hasn’t been determined)

Parameters

vehicle{EMAPI.Router.VehicleParams} EMAPI.Router.VehicleParams object representing the settings for the vehicle to be used for routing.
driver{EMAPI.Router.DriverParams} EMAPI.Router.DriverParams object representing the settings for the driver to be used to designate the route.
roadType{Integer} Type of route calculation: 0 = the shortest, 1 = the fastest, 2 = the cheapest.
routeOptions{Object} An object that contains routing options in the form of logical fields: useDifficulties = true, forces the use of traffic congestion useFerry = true turns on the use of ferries, useGroundRoad = true turn on the use of unpaved roads. useTrafficTI = true turns the use of the current traffic information, useArchivalTraffic = true turns the use of archived traffic information, useLogistic = true turns the use of road restriction, avoidToll = true turns avoiding of toll road. viaToll = true turns the viaTOLL cost calculating, avoidViaToll = true turns avoiding of viaTOLL road. useVignette = true turn the use of calculating roads with vignettes, useSoftRestrictions = true allows access to the blocked waypoint. avoidLowCategoryRoads = true turn the use of avoiding low categories roads, alternativeRoutes = true turns calculating of two additional alternative roads.
force{Boolean} Information - calculate a route immediately, or wait calculating of the earlier routes.

activateRoute

activateRoute: function(index)

Activates the selected route from the calculated alternative routes.

Parameters

index{Integer} Route index (ranging from 0 for the first, which is active immediately after the route calculating).

drivers

drivers: function()

Returns the list of drivers during routing

Result

{EMAPI.ArrayObjects} List of drivers during routing This is an array of objects EMAPI.Router.DriverParams class managed by an object of EMAPI.ArrayObjects class.  By default, these parameters include the following drivers representing typical applications: Experienced i Unexperienced.

vehicles

vehicles: function()

Returns the list of vehicles used during routing

Result

{EMAPI.ArrayObjects} List of vehicles during routing.  This is an array of objects EMAPI.Router.VehicleParams class managed by an object of EMAPI.ArrayObjects class.  By default, these parameters include the following vehicles representing typical applications: Passenger car, Fast passenger car, Transport truck 10t, Transport truck 20t, Delivery truck, Motorcycle, Bicycle and Pedestrian.

wayPoints

wayPoints: function()

Returns the list of waypoints.

Result

{EMAPI.ArrayObjects} List of waypoints.  This is an array of objects EMAPI.Router.WayPoint class managed by an object of EMAPI.ArrayObjects or functions addWaypoint, setWaypoint, removeWaypoint, removeWaypoints and swapWaypoint.  By default it is empty.

routeRepresentation

routeRepresentation: function()

Returns result of calculated route.

Result

{EMAPI.Router.RouteRepresentation} Representation and parameters determined by the calculateRoute function.

addWaypoint: function(lonLat,
pointType,
callback)
Adds a new waypoint to the list of wayPoints.
wayPoints: function()
Returns the list of waypoints.
setWaypoint: function(index,
lonLat,
callback)
Change the location of the waypoint.
removeWaypoints: function()
Removes all waypoints from the list of wayPoints.
removeWaypoint: function(index)
Deletes the selected way point from the list of wayPoints.
swapWaypoint: function(firstPointIndex,
secondPointIndex)
Replaces in order two selected from the list of wayPoints.
calculateRoute: function(vehicle,
driver,
roadType,
routeOptions,
callback,
force)
Calculates a route between points placed in the list of wayPoints after the selected vehicle, driver and routing parameters.
activateRoute: function(index)
Activates the selected route from the calculated alternative routes.
drivers: function()
Returns the list of drivers during routing
vehicles: function()
Returns the list of vehicles used during routing
routeRepresentation: function()
Returns result of calculated route.
EMAPI.Map instances are interactive maps embedded in web applications.
A class representing the geographic coordinates in the form of latitude and longitude.
Parameters and representation class route.
{String} Type of road.
Class vehicle parameters taken into account during routes calculating.
Class driver parameters taken into account during routes calculating.
Assistant class for managing the JavaScript objects array.
Class of waypoints.
Close