我做了这个代码文件 Real.cs
public ActionResult Index() {
IList<Eventdata> liste = DATA2.Eventdata.GetEventdata();
int a = liste.Count;
float lat = liste[a-2].Latitude;
float longi = liste[a-2].Longitude;
IList<float> model = new List<float>();
model.Add(lat);
model.Add(longi);
return View(model);
}
我映射了表 EventData :它包含两个属性浮点数(纬度,经度),我想知道它的最后一个值。
文件索引.CShtml
@model IList<float> @{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Lay3.cshtml";
}
<body onload="initialize(@Model[0],@Model[1])">
<div id="map_canvas" style="width: 800px; height: 500px;">
</div>
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript">
</script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize(a, b) {
alert(a);
alert(b);
var myLatLng = new google.maps.LatLng(a,b);
var myOptions = {
zoom: 30,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var flightPlanCoordinates = [
new google.maps.LatLng(a,b)
];
var flightmarker = new google.maps.Marker({
position: new google.maps.LatLng(a,b),
map: map, title: " denden"
});
}
</script>
</body>
我有这样的最后一点:
Latitude=34.75064
和longitude=10.761744
。但消息是:34
和75064
。为什么?我该如何纠正它。