我想從我的MVC模型項目中繪製多個動態谷歌地圖標記。我能夠通過硬編碼來做到這一點,但不是動態的。我錯過了什麼?MVC動態谷歌地圖標記
function codeAddress(index, value)
{
//var addressArray = ['Canada', 'India', 'America'];
//$.each(addresses, function()
//{
// var addresses = value.ASSET_NAME;
//});
@for (int i = 0; i < Model.Count(); i++)
{
var addressArray = Model[i].ASSET_NAME;
}
//var geocoder = new google.maps.Geocoder();
for (var x = 0; x < addressArray.Count(); x++)
{
geocoder.geocode({ 'address': addressArray[x] }, function (results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
考慮這個樣品http://www.jmelosegui.com/map/marker/DataBindingToModel –