Skip to content

Commit

Permalink
added waypoints parameter to influence the route Gogle will return
Browse files Browse the repository at this point in the history
  • Loading branch information
jclarke0000 committed May 29, 2017
1 parent 17e329b commit bd8d1b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ Each object in the `destinations` array has the following parameters:
<td><code>transitMode</code></td>
<td>If <code>mode</code> = <code>transit</code> you can additionally specify one or more of the following: <code>bus</code>, <code>subway</code>, <code>train</code>, <code>tram</code>, or <code>rail</code>.<br><br><strong>Type:</strong> <code>string</code>.<br>Separate multiple entries with the <code>|</code> character (e.g.: <code>"transitMode" : "bus|subway|tram"</code>). Specifying <code>rail</code>indicates that the calculated route should prefer travel by train, tram, light rail, and subway. Equivalenet to <code>train|tram|subway</code></td>
</tr>
<tr>
<td><code>waypoints</code></td>
<td>If specified, it instructs Google to find the route that passes through the waypoints to provide.<br><br><strong>Type:</strong> <code>string</code>.<br>Separate multiple entries with the <code>|</code> character. See https://developers.google.com/maps/documentation/directions/intro#Waypoints for details on how waypoints can be specified.</td>
</tr>
<tr>
<td><code>avoid</code></td>
<td>If specified, will instruct the Google API to find a route that avoids one or more of the following: <code>tolls</code>,<code>highways</code>,<code>ferries</code>,<code>indoor</code>.<br><br><strong>Type:</strong> <code>string</code>.<br>Separate multiple entries with the <code>|</code> character (e.g.: <code>"avoid" : "highways|tolls"</code>).</td>
Expand Down
12 changes: 10 additions & 2 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = NodeHelper.create({
var url = 'https://maps.googleapis.com/maps/api/directions/json' + this.getParams(this.config.destinations[i]);
this.urls.push( url );

//console.log(url);
// console.log(url);
}

//first data opull after new config
Expand Down Expand Up @@ -105,7 +105,13 @@ module.exports = NodeHelper.create({
params += '&alternatives=true';
}

params += '&departure_time=now'; //needed for time based on traffic conditions
if (dest.waypoints) {
var waypoints = dest.waypoints.split("|");
for (var i = 0; i < waypoints.length; i++) {
waypoints[i] = encodeURIComponent(waypoints[i]);
}
params += '&waypoints=' + waypoints.join("|");
}

//avoid
if (dest.avoid) {
Expand All @@ -122,6 +128,8 @@ module.exports = NodeHelper.create({

}

params += '&departure_time=now'; //needed for time based on traffic conditions

return params;

},
Expand Down

0 comments on commit bd8d1b0

Please sign in to comment.