Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.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
Javascript 地图画布下方的任何内容都不会显示_Javascript_Html_Google Maps - Fatal编程技术网

Javascript 地图画布下方的任何内容都不会显示

Javascript 地图画布下方的任何内容都不会显示,javascript,html,google-maps,Javascript,Html,Google Maps,我正在尝试制作一个嵌入谷歌地图的网站。但是,地图下方的任何内容都不会显示 <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height:

我正在尝试制作一个嵌入谷歌地图的网站。但是,地图下方的任何内容都不会显示

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 80%; width: 80%; margin: 50px; }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key={my_api_key}&sensor=TRUE">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div>Google map test</div>
    <div id="map-canvas"/>
    <div>End of google map test</div>
  </body>
</html>

html{高度:100%}
正文{高度:100%;边距:0;填充:0}
#地图画布{高度:80%;宽度:80%;边距:50px;}
函数初始化(){
变量映射选项={
中心:新google.maps.LatLng(-34.397150.644),
缩放:8
};
var map=new google.maps.map(document.getElementById(“地图画布”),
地图选项);
}
google.maps.event.addDomListener(窗口“加载”,初始化);
谷歌地图测试
谷歌地图测试结束
如果您在body部分看到有三个div标记:第一行文本,第二行是地图,第三行是更多文本。第一个div标签和地图正在显示,但是最后一个div标签显示GoogleMap测试结束,根本没有显示。你们知道问题出在哪里吗?谢谢。

您不能像这样关闭

根据W3C:

A div element must have both a start tag and an end tag.
资料来源:

更改此项:

   <div id="map-canvas"/>


   <div id="map-canvas"></div>