Question

This is the code to drawing a line on the map in Google maps v3:

var line = new google.maps.Polyline({
path: lineCoordinates,
strokeOpacity: 0,
icons: [{
  icon: lineSymbol,
  offset: '0',
  repeat: '20px'
}],
map: map

});

The repeat property can help us to draw dashed line. But I want to change this property dynamically. Something like this: setRepeat('20px');

Was it helpful?

Solution

you must re-assign the icons-property of the line, e.g.:

  line.set('icons',[{icon:line.icons[0].icon,
                     offset:line.icons[0].offset,
                     repeat:'50px'}]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top