Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ericjames/e06e4d9d30b25839c1321df848c4b8c0 to your computer and use it in GitHub Desktop.
Save ericjames/e06e4d9d30b25839c1321df848c4b8c0 to your computer and use it in GitHub Desktop.
Google Maps Create Polyline from Coordinates - Given a set of coordinates, this function will generate a polyline object
function createLine(linepoints, style, stroke, opacity, zIndex) {
var coordArray = [];
for (var i in linepoints) {
var coord = linepoints[i].split(",");
var lat = coord[1];
var lng = coord[0];
var lineCoord = new google.maps.LatLng(lat, lng);
coordArray.push(lineCoord);
}
var routeLine = new google.maps.Polyline({
path: coordArray,
strokeColor: style,
strokeOpacity: opacity,
strokeWeight: stroke,
zIndex: zIndex
});
return routeLine;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment