Report of the route |
EMAPI allows for the final route report and then displays it in a DIV element. It's also possible to create your own representation of the route (EMAPI.Router.RouteRepresentation class).
Example of using the final route report::
var router = new EMAPI.Router( //create a new instance of the EMAPI.Router class { map: mapa, //map on which routes are to be visualized reportPointsHandlerPointsName: 'punkty_id' //DIV element, which sets the list of waypoints reporResultHandlerName: 'raport_id' //DIV element, which sets the route report } ); <div id="points_id"></div> //DIV element that contains added waypoints <div id="report_id"></div> //DIV element that contains the final route
The list of added waypoints:
Raport trasy:
EMAPI.Router.RouteRepresentation - parameters and representation class of the route. Representation includes a report of the route divided into sections (sections) designated by the waypoints.
var rr = router.routeRepresentation;
Available parameters:
routeFrom | {String} Location of the starting point of the route. |
routeTo | {String} Location of the final point of the route. |
routeDescription | {String} Name of the route. |
routeItems | {EMAPI.ArrayObjects} List of segments of the route between pairs of another points. |
tollRoadLength | {Float} Length of toll roads are included in the route (in km). |
tollRoadTime | {String} Length of toll roads are included in the route. |
totalFuelCost | {Float} Total cost of the fuel. |
totalRouteCost | {Float} The total cost of the route traveled. |
totalRouteLenght | {Float} The total length of the route (in km). |
totalRouteTime | {String} Total travel time route. |
unreachableEntry | {Integer} The index of the waypoint which it wasn't impossible to determine the drive. ( starting from 1 for the second waypoint). |
var div = document.getElementById('raport'); //DIV element, which sets the route report var rr = router.routeRepresentation; div.innerHTML = 'Name: '+ rr.routeDescription // + '
Starting point: ' + rr.routeFrom //information contained in the route report + '
Final point: ' + rr.routeTo // + '
The length of the route: ' + rr.totalRouteLength; // <div id="raport"></div> //DIV element contained the route report
EMAPI.Router.RouteRepresentationSection - parameters and representation class section (section) route between two points of the route.
Available parameters:
sectionFrom | {String} Location of the starting point of the route section. |
sectionTo | {String} Location of the final point of the route section. |
sectionCost | {Float} The total cost of the section traveled route. |
sectionDistance | {Float} The total length of the section of route (in km). |
sectionTime | {String} Total travel time of the section route |
routeItems | {EMAPI.ArrayObjects} The list of characteristic points of the section route ( report of the route). |
var div = document.getElementById('raport_id2'); var rr = router.routeRepresentation; var raport=''; for(var i=0; i<rr.routeItems.length; i++) //search all sections { var sekcje = rr.routeItems[i]; //getting information from all sections of the route raport = raport + '<tr><th width="300" style="border:1 solid #DB700F;background-color:#FFE8B5">' + sekcje.sectionFrom + ' - ' + sekcje.sectionTo //starting point - the final point of the section + '<th width="60">km' + '<th width="60">czas' + '</tr>'; }
EMAPI.Router.RouteRepresentationItem - the class of the route characteristic point (entry in the report of the route).
Available parameters:
entryCost | {Float} The current cost of the route starting from the beginning up to this point. |
entryDistance | {Float} Distance along the route starting from the beginning up to this point (in km). |
entryPosition | {EMAPI.LonLat} The coordinates of the chracteristic point of the route.v |
entryTime | {String} Journey time to the point from the beginning of the route. |
entryDescription | {String} A description of the characteristic point that inform about the event in the course of the route. |
entryType | {String} The type of event at this point. |
Example of creating a route report:
var div = document.getElementById('raport_id2'); var rr = router.routeRepresentation; var raport=''; for(var i=0; i<rr.routeItems.length; i++) //search all sections { var sekcje = rr.routeItems[i]; //downloading information from all sections of the route raport = raport + '<tr><th width="300" style="border:1 solid #DB700F;background-color:#FFE8B5">' + sekcje.sectionFrom + ' - ' + sekcje.sectionTo //starting point - the final point of the section + '<th width="60">km' + '<th width="60">czas' + '</tr>'; for(var j=0;j<sekcje.routeItems.length;j++) //search all the points in the section { var punkty = sekcje.routeItems[j]; //downloading information from all points of the section raport = raport + '<tr><td style="color:#8e8e8e;padding-left:10px;">' + punkty.entryDescription //a description of the point + '<td>' + punkty.entryDistance //distance to the point + '<td>' + punkty.entryTime + '</tr>'; //time to reach the point } } <div id="raport_id2"></div> //DIV element that contains the report of the route