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

Commit 29fda3f

Browse files
committed
Merge pull request #351 from mattwright/route-polyline-icons
- Update route drawing methods to allow 'icons' option for drawPolyline
2 parents 27c839a + 7e15a44 commit 29fda3f

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

lib/gmaps.routes.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,18 @@ GMaps.prototype.drawRoute = function(options) {
123123
error: options.error,
124124
callback: function(e) {
125125
if (e.length > 0) {
126-
self.drawPolyline({
126+
var polyline_options = {
127127
path: e[e.length - 1].overview_path,
128128
strokeColor: options.strokeColor,
129129
strokeOpacity: options.strokeOpacity,
130130
strokeWeight: options.strokeWeight
131-
});
131+
};
132+
133+
if (options.hasOwnProperty("icons")) {
134+
polyline_options.icons = options.icons;
135+
}
136+
137+
self.drawPolyline(polyline_options);
132138

133139
if (options.callback) {
134140
options.callback(e[e.length - 1]);
@@ -206,12 +212,18 @@ GMaps.prototype.drawSteppedRoute = function(options) {
206212
var steps = route.legs[0].steps;
207213
for (var i=0, step; step=steps[i]; i++) {
208214
step.step_number = i;
209-
self.drawPolyline({
215+
var polyline_options = {
210216
path: step.path,
211217
strokeColor: options.strokeColor,
212218
strokeOpacity: options.strokeOpacity,
213219
strokeWeight: options.strokeWeight
214-
});
220+
};
221+
222+
if (options.hasOwnProperty("icons")) {
223+
polyline_options.icons = options.icons;
224+
}
225+
226+
self.drawPolyline(polyline_options);
215227
options.step(step, (route.legs[0].steps.length - 1));
216228
}
217229
}
@@ -229,12 +241,18 @@ GMaps.prototype.drawSteppedRoute = function(options) {
229241
var steps = options.route.legs[0].steps;
230242
for (var i=0, step; step=steps[i]; i++) {
231243
step.step_number = i;
232-
self.drawPolyline({
244+
var polyline_options = {
233245
path: step.path,
234246
strokeColor: options.strokeColor,
235247
strokeOpacity: options.strokeOpacity,
236248
strokeWeight: options.strokeWeight
237-
});
249+
};
250+
251+
if (options.hasOwnProperty("icons")) {
252+
polyline_options.icons = options.icons;
253+
}
254+
255+
self.drawPolyline(polyline_options);
238256
options.step(step);
239257
}
240258
}
@@ -252,12 +270,18 @@ GMaps.Route = function(options) {
252270
this.steps = this.route.legs[0].steps;
253271
this.steps_length = this.steps.length;
254272

255-
this.polyline = this.map.drawPolyline({
273+
var polyline_options = {
256274
path: new google.maps.MVCArray(),
257275
strokeColor: options.strokeColor,
258276
strokeOpacity: options.strokeOpacity,
259277
strokeWeight: options.strokeWeight
260-
}).getPath();
278+
};
279+
280+
if (options.hasOwnProperty("icons")) {
281+
polyline_options.icons = options.icons;
282+
}
283+
284+
this.polyline = this.map.drawPolyline(polyline_options).getPath();
261285
};
262286

263287
GMaps.Route.prototype.getRoute = function(options) {

0 commit comments

Comments
 (0)