非常感谢您的帮助。我试图用新的mvc3剃须刀使用谷歌地图api,但是当我去运行我的代码时,除了标签外,没有任何东西正在显示。但是,如果我创建一个html文件,我可以让地图显示出来。我确信我会对答案的答案有多明显,但在过去的几天里,我一直在研究这段代码,但一直无法弄清楚如何让它在VS中工作。请帮助:在MVC 3中不显示Google Maps v3
我在_Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<pre lang="aspnet">@RenderSection("Scripts", false)
<style type="text/css">
@RenderSection("Styles", false)
</style>
</head>
<body>
@RenderBody()
</body>
</html>
在我Index.cshtml:
@{
ViewBag.Title = "MVC 3 and Google Maps";
}
@section Scripts {
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
}
@section Styles {
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 80% }
}
<script type="text/javascript">
function initialize() {
//var latlng = new google.maps.LatLng(40.716948, -74.003563);
var options = { center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById
("map_canvas"), options);
}
$(function() {
initialize();
});
</script>
<h2>Hello, Google Maps</h2>
<div id="map_canvas" style="width:80%; height:80%"></div>
这一切都是我的工作,现在,希望你能及告诉我我缺少的东西。我已经查看了几个类似的代码,但由于某种原因在VS它不想显示谷歌地图,但就像我说我的显示。谢谢你的帮助!
谢谢你的帮助,但我已经试过了,没有运气。 – 4everAStudent 2012-03-13 23:11:41