I'm trying to create a Google Map that will draw out a race course from a list of lat & lng in my MVC model. I have successfully done this with markers but I need to do it with polylines to create a path of the course. Below is what I have but can't get the lines to show up.
Any suggestions?
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=false"></script>
<script>
function initialize() {
var mapOptions = {
zoom: 10,
center: new google.maps.LatLng(@Model.Courses.Latitude, @Model.Courses.Longitude),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
@foreach (var item in Model.CourseRatings.ValuesList)
{
<text>addMarker(@item.Item2, @item.Item3)</text>
}
var flightPath = new google.maps.Polyline({
path: function addMarker(x, y) { new google.maps.LatLng(x, y); },
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Thank you!