Skip to content

Commit

Permalink
add departAt and arriveAt as options
Browse files Browse the repository at this point in the history
  • Loading branch information
mrohnstock committed Mar 20, 2017
1 parent 4b2f794 commit 98ad376
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Some of the available options from [TomTom Online Routing](https://developer.tom
* vehicleLength: int (in m)
* vehicleWidth: int (in m)
* vehicleHeight: int (in m)
* departAt: string (YYYY-MM-DD\THH:mm:ss, i.e. 2017-03-20T20:00:15)
* arriveAt: string (YYYY-MM-DD\THH:mm:ss)
* vehicleCommercial: boolean

See [TomTom Online Routing Documentation](https://developer.tomtom.com/online-routing/online-routing-documentation) for further informations.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lrm-tomtom",
"version": "1.0.1",
"version": "1.0.2",
"description": "Support for TomTom in Leaflet Routing Machine",
"main": "src/L.Routing.TomTom.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions src/L.Routing.TomTom.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
vehicleLength: 0, // m
vehicleWidth: 0, // m
vehicleHeight: 0, // m
departAt: "", // YYYY-MM-DD\THH:mm:ss
arriveAt: "", // YYYY-MM-DD\THH:mm:ss
vehicleCommercial: false
},

Expand Down Expand Up @@ -162,12 +164,20 @@
vehicleLength: this.options.vehicleLength,
vehicleWidth: this.options.vehicleWidth,
vehicleHeight: this.options.vehicleHeight,
departAt: this.options.departAt,
arriveAt: this.options.arriveAt,
vehicleCommercial: this.options.vehicleCommercial
};

if (_options.avoid == "" || _options.avoid == [])
delete _options.avoid;

if (_options.departAt.match(/^(\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/) === null)
delete _options.departAt;

if (_options.arriveAt.match(/^(\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/) === null)
delete _options.arriveAt;

for (i = 0; i < waypoints.length; i++)
locs.push(waypoints[i].latLng.lat + ',' + waypoints[i].latLng.lng);

Expand Down

0 comments on commit 98ad376

Please sign in to comment.