ок!
, поэтому проблема была в моем определении объекта.Широта и долгота, где двойное значение, а не строковое значение.Итак, координаты где с запятой, а не с точкой
Я добавил два строковых поля в мой объект, и я преобразовал в него координаты:
В контроллере:
foreach(var item in VehiculesList)
{
item.VehicleLocation.Lat_String = item.VehicleLocation.Latitude.ToString().Replace(",", ".");
item.VehicleLocation.Long_String = item.VehicleLocation.Longitude.ToString().Replace(",", ".");
}
В представлении:
<script>
function initMap() {
var myLatLng = { lat: 48.584715, lng: 7.748556 };
// Create a map object and specify the DOM element
// for display.
var map = new google.maps.Map(document.getElementById('carte'), {
center: myLatLng,
zoom: 14
});
// Create a marker and set its position.
@foreach(var item in Model){
<text>
var marker = new google.maps.Marker({
map: map,
position: { lat: @item.VehicleLocation.Lat_String, lng: @item.VehicleLocation.Long_String },
title: 'Hello World!'
});
</text>
}
}</script>