Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
- Update route drawing methods to allow 'icons' option for drawPolyline
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwright committed Sep 16, 2014
1 parent d0efbd2 commit 7e15a44
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions lib/gmaps.routes.js
Expand Up @@ -123,12 +123,18 @@ GMaps.prototype.drawRoute = function(options) {
error: options.error,
callback: function(e) {
if (e.length > 0) {
self.drawPolyline({
var polyline_options = {
path: e[e.length - 1].overview_path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

self.drawPolyline(polyline_options);

if (options.callback) {
options.callback(e[e.length - 1]);
Expand Down Expand Up @@ -206,12 +212,18 @@ GMaps.prototype.drawSteppedRoute = function(options) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
var polyline_options = {
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

self.drawPolyline(polyline_options);
options.step(step, (route.legs[0].steps.length - 1));
}
}
Expand All @@ -229,12 +241,18 @@ GMaps.prototype.drawSteppedRoute = function(options) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
var polyline_options = {
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

self.drawPolyline(polyline_options);
options.step(step);
}
}
Expand All @@ -252,12 +270,18 @@ GMaps.Route = function(options) {
this.steps = this.route.legs[0].steps;
this.steps_length = this.steps.length;

this.polyline = this.map.drawPolyline({
var polyline_options = {
path: new google.maps.MVCArray(),
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
}).getPath();
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

this.polyline = this.map.drawPolyline(polyline_options).getPath();
};

GMaps.Route.prototype.getRoute = function(options) {
Expand Down

0 comments on commit 7e15a44

Please sign in to comment.