I'm trying to iterate through Model.DataList, however, I'm not able to get Javascript value 'i' in c#. Is it possible to access I from c#?
for (var i = 0; i < (@Model.DataList.Count); i++) {
var la = (@Model.DataList[i].Latitude)/1000000;
var lo = (@Model.DataList[i].Longitude)/1000000;
var marker = new google.maps.Marker({
position: {lat: la, lng: lo},
map: map,
title: "Some title",
zIndex: i
});
}
Html.Raw(Json(....))is a common solution to this question. I will delete the dup comment as well.