i did this code
File 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);
}
i mapped the table EventData : it contains two attributs floats ( Latitude,Longitude) and i want to know its last values.
File Index.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>
and i have the last point like that :
Latitude=34.75064 and the longitude=10.761744 . but the messages are : 34 and 75064.
Why? And how can i correct it.
Try using( or set culture with ‘.’ decimal digit separator)
Instead of
If you call initialize method with 34,75064 and 10,761744 you are actually passing four parameters. Because of that a = 34 and b = 75064.
You need to check culture when passing parameters from server to client because when culture have ‘,’ insead of ‘.’ for decimal digit separator your code wont work as expected.
In your case with map you need decimal value, so you can’t use
You need to covert your decimal to appropriate culture like this