我正在自学asp .net mvc 3。我阅读了本教程: http: //www.codeproject.com/Articles/148949/ASP-NET-MVC-3-the-Razor-View-Engine-and-Google-Map和其他几个这样的帖子。但是,我无法在我的应用程序上运行谷歌地图。我究竟做错了什么?
看法:
@section Scripts_head {
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
}
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(40.716948, -74.003563);
var options = { zoom: 14, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById("map"), options);
}
$(function () {
initialize();
});
</script>
<div id="map" style="width:80%; height:80%"></div>
我也尝试将 div 放在 script 标签上。
布局页面:
<head>
...
@RenderSection("Scripts_head", false)
</head>
控制器:
public class MapController : Controller
{
//
// GET: /Map/
public ActionResult Index()
{
return View();
}
}