Created
October 23, 2017 14:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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