Ниже приведен пример кода из статьи, написанной Скоттом Митчеллом об использовании Google Maps с ASP.NET MVC:
@{
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.