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

- Update route drawing methods to allow 'icons' option for drawPolyline #351

Merged
merged 1 commit into from
Feb 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions lib/gmaps.routes.js
Original file line number Diff line number Diff line change
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