我从使用谷歌地图的ASP.NET MVC写斯科特·米切尔的文章得到了下面的示例代码:JSON代ASP.NET MVC 3
@{
var locations = new List<string>();
var infoWindowContents = new List<string>();
foreach (var store in Model) {
locations.Add(string.Format(
@"{{
title: ""Store #{0}"",
position: new google.maps.LatLng({1}, {2})
}}",
store.StoreNumber,
store.Latitude,
store.Longitude));
infoWindowContents.Add(string.Format(
@"{{
content: ""<div class=\""infoWindow\""><b>Store #{0}</b><br />{1}<br />{2}, {3} {4}</div>""
}}",
store.StoreNumber,
store.Address,
store.City,
store.Region,
store.PostalCode)
);
}
}
然而,当页面呈现以下是说明(我加一个空格之间“&”和“QUOT;”
{
title: & quot;Store #893& quot;,
position: new google.maps.LatLng(32.7178080, -117.1611020)
}
最有可能涉及到JSON编码,但我仍然在ASP.NET MVC初学者
我在哪里使用它? – Bill
尝试locations.Add(string.Format( @:“{{ –