Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何在MVC5应用程序中集成Google地图?_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 如何在MVC5应用程序中集成Google地图?

Asp.net mvc 如何在MVC5应用程序中集成Google地图?,asp.net-mvc,Asp.net Mvc,我正在遵循,并希望将其集成到ASP.NET的MVC中。我可以启动page start.html,并查看_Layout.cshtml的元素,但谷歌地图不会显示。你能帮我修一下吗?非常感谢。 在views/Start.html中 @{ Layout = "~/Views/Shared/_Layout.cshtml"; } @{ ViewBag.Title = "Road Trip Agent"; } <h3>@ViewBag.Message</h3> @

我正在遵循,并希望将其集成到ASP.NET的MVC中。我可以启动page start.html,并查看_Layout.cshtml的元素,但谷歌地图不会显示。你能帮我修一下吗?非常感谢。 在views/Start.html中

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
} 

@{
    ViewBag.Title = "Road Trip Agent";
} 
<h3>@ViewBag.Message</h3>
@Styles.Render("~/bundles/map")
<p></p> 

<div id="map"></div>
@section Scripts {
    @Scripts.Render("~/bundles/jquery")

<script>

var map;
function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: -34.397, lng: 150.644},
    zoom: 8
  });
}

</script>
<script async defer
        src="https://maps.googleapis.com/maps/api/js?key=I have put my key here&callback=initMap">
</script>

}

在Content/map.css中:

html, body { height: 100%; margin: 0; padding: 0; }
  #map { height: 100%; }
如果您使用:

    <div id="map" style="width:800px; height:500px;"></div>

i、 e.
px
而不是
%
显示

    <div id="map" style="width:800px; height:500px;"></div>