Why I get this error?
Compiler Error Message: CS1061: ‘System.Collections.Generic.IEnumerable’ does not contain a definition for ‘lat’ and no extension method ‘lat’ accepting a first argument of type ‘System.Collections.Generic.IEnumerable’ could be found (are you missing a using directive or an assembly reference?)
.Ado Model
int, lat, lng, contents
Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MapApp.Models;
namespace MapApp.Controllers
{
[HandleError]
public class HomeController : Controller
{
mapEntities _db = new mapEntities();
public ActionResult Index()
{
return View(_db.river);
}
public ActionResult About()
{
return View();
}
}
}
View
@model IEnumerable<MapApp.Models.river>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2> Index</h2>
<script type="text/javascript">
@foreach (var item in Model)
{
<text>
var markerlatLng = new google.maps.LatLng(@(Model.lat), @(Model.lng));
var contents = '@(Model.contents)';
var infowindow = new google.maps.InfoWindow({
content: contents
});
var marker = new google.maps.Marker({
position: markerlatLng,
title: contents,
map: map,
draggable: false
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
});
</text>
}
</script>
Got it fixed!
Controller
View