I'm trying to add locations into google map marker with model data,but map doesn't load and prompt me to kill page, where as if i put 40 static locations to a marker, it loads well, how do i load marker values with model data below is my code
<pre> var map = new google.maps.Map(document.getElementById('googleMap'), {
zoom: 5,
center: new google.maps.LatLng(40.4931300000, -79.8631100000),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
var locations = [];
@for(int i = 0; i < Model.pallet.Lattitudes.Count; i++)
{
if (Model.pallet.Lattitudes[i] != null) {
@:locations.push(new google.maps.LatLng('@Model.pallet.Lattitudes[i]', '@Model.pallet.Longitudes[i]'));
}
}
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: locations[i],
});
marker.setMap(map);
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
What I have tried:
i tried putting 40 hard cocded location values into array and loads well ,but with model data it doesn't work