Javascript 谷歌地图未显示

Javascript 谷歌地图未显示,javascript,html,google-maps,Javascript,Html,Google Maps,我写了一个网页,并将谷歌地图插入其中。但地图总是不显示。我尝试使用Firebug查看发生了什么,发现没有错误 地图画布的div已被谷歌地图API正确替换,但该div未显示。。。 我调试了几天,仍然没有解决方案 <html><head> <meta charset="UTF-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> &l

我写了一个网页,并将谷歌地图插入其中。但地图总是不显示。我尝试使用Firebug查看发生了什么,发现没有错误

地图画布的div已被谷歌地图API正确替换,但该div未显示。。。 我调试了几天,仍然没有解决方案

    <html><head>
        <meta charset="UTF-8">
        <meta content="IE=Edge" http-equiv="X-UA-Compatible">

        <meta content="initial-scale=1.0, user-scalable=no" name="viewport">
        <meta charset="utf-8">

        <title>TaskPaneApp1</title>
        <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js" style=""></script>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    </head>

    <body>
        <!-- Page content -->
        <div id="content-header">
            <div class="padding">
                <h1>Welcome</h1>
            </div>
        </div>
        <div id="content-main">
            <div class="padding">
                <p><strong>Add home screen content here.</strong></p>
                <p>For example:</p>
                <button id="get-data-from-selection">Get data from selection</button>

                <p style="margin-top: 50px;">
                    <a href="http://go.microsoft.com/fwlink/?LinkId=276812" target="_blank">
                        Find more samples online...
                    </a>
                </p>
                <div style="position: relative">
                    <p>Hey there!</p>
                    <div style="position: relative; width: 100%; height: 500px">
                        <div id="map-canvas">
                            Loading...
                        </div>
                    </div>  
                    <p>This is the end of the map</p>
                </div>
            </div>
        </div>

    <script type="text/javascript">
        var map;
            function initialize() {
              var mapOptions = {
                zoom: 8,
                center: new google.maps.LatLng(-34.397, 150.644),
                mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              map = new google.maps.Map(document.getElementById('map-canvas'),
                  mapOptions);
            }

            google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </body></html>

任务窗格EAPP1
欢迎
在此处添加主屏幕内容。

例如:

从选择中获取数据

加载。。。 这是地图的尽头

var映射; 函数初始化(){ 变量映射选项={ 缩放:8, 中心:新google.maps.LatLng(-34.397150.644), mapTypeId:google.maps.mapTypeId.ROADMAP }; map=new google.maps.map(document.getElementById('map-canvas'), 地图选项); } google.maps.event.addDomListener(窗口“加载”,初始化);
您没有设置映射div的维度,而是设置映射嵌套在其中的div的维度。将高度和宽度属性添加到div id“map canvas”中,地图就会出现

    <div id="map-canvas" style="width: 400px; height: 400px;">Loading...</div>
正在加载。。。

您的地图分区没有大小。这:

<div id="map-canvas" style="height:300px; width:300px;"> 


让它为我展示

你的地图分区没有大小。这
让它为我显示。可能是@geocodezip的重复,它可以工作。谢谢请您重新提交您的解决方案作为答案,以便我可以修改它?而且,它是重复的。我试图搜索,但我不知道正确的关键字,所以我没有找到那个问题。。。我的错:-(