Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HEREMap.prototype.drawRoute = function(fromCoordinates, toCoordinates, reroutePoint) {
var startPoint = Utils.locationToWaypointString(fromCoordinates);
var endPoint = Utils.locationToWaypointString(toCoordinates);
var viaPoint = reroutePoint && Utils.locationToWaypointString(reroutePoint);
var routeOptions = {
mode: 'fastest;car',
representation: 'display',
routeattributes: 'waypoints,summary,shape,legs',
waypoint0: startPoint,
};
if (viaPoint) {
this.updateMarker('viaPoint', reroutePoint);
routeOptions.waypoint1 = viaPoint;
routeOptions.waypoint2 = endPoint;
} else {
routeOptions.alternatives = 2;
routeOptions.waypoint1 = endPoint;
}
this.updateMarker('origin', fromCoordinates);
this.updateMarker('destination', toCoordinates);
this.router.drawRoute(routeOptions);
this.places.clearSearch();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.