我正在尝试使用谷歌地图标记的c#列表填充javascript谷歌地图。我可以从公共浮动中获取数据,但不能从列表中获取数据。该列表将由数据库填充,但在这种情况下,列表是硬编码的。我添加了一个硬编码标记。任何想法?
ASP.NET Web表单
<title></title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function InitialiseMap() {
var latlng = new google.maps.LatLng('<%= lat %>', '<%= lng %>');
var myOptions = {
zoom: 9,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
Placement(a, 1, 1);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: 'Test!'
});
}
//window.onload = InitialiseMap();
</script>
C#
公共课安置 { public string PlacementName {get;组; } 公共浮动纬度{get;组; } 公共浮动经度{get;组; }
public List<Placement> GetPlacementDetails()
{
Placement placement = new Placement();
placement.PlacementName = "Placement 1";
placement.Latitude = 53.28097170166426F;
placement.Longitude = -2.9433422088622F;
Placement placement2 = new Placement();
placement2.PlacementName = "Placement 2";
placement2.Latitude = 55.74326998205062F;
placement2.Longitude = -2.8699998855590F;
List<Placement> placements = new List<Placement>();
placements.Add(placement);
placements.Add(placement2);
return placements;
}