javascript - HTML 和谷歌地图玩得不好

标签 javascript html google-maps

我有一个自定义的谷歌地图。看起来很简单。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>

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

  <!--google magic-->
  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

  <!--custom map-->
  <script type="text/javascript">
    function initialize() {
      var latlngcenter = new google.maps.LatLng(41.523387, -87.691545);
      //move center west of marker to show I-57
      var myOptions = { zoom: 11, center: latlngcenter, mapTypeId: google.maps.MapTypeId.ROADMAP };
      var map = new google.maps.Map(document.getElementById("GardenWalk_Canvas"), myOptions);
      var latlng;
      var marker;
      latlng = new google.maps.LatLng(41.503387, -87.636545);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.520935, -87.582318);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.520075, -87.634509);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.538092, -87.677964);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.536256, -87.678006);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.533099, -87.682250);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.550018, -87.691408);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.550017, -87.691305);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.508768, -87.693976);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.509065, -87.694586);
      marker = new google.maps.Marker({ position: latlng, map: map });
      latlng = new google.maps.LatLng(41.498524, -87.810122);
      marker = new google.maps.Marker({ position: latlng, map: map });
    }
  </script>

</head>
<body onload="initialize()">
  <div id="GardenWalk_Canvas" style="width: 500; height: 350" />
  text after
</body>
</html>

唯一的问题是 map 仅在删除以下内容时显示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

有什么想法或韵律或理由来解释为什么吗?

最佳答案

您在 html 中有一些评论

//google magic
//custom map

这不是有效的 xhtml。

修改为

<!--google magic-->

关于javascript - HTML 和谷歌地图玩得不好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3118370/

相关文章:

javascript - 如何使用node js下载并保存多个文件?

javascript - CSS 溢出 : scroll; --scrollbar is only visible on hover/scrolling

html - 无法正确定位与 <a> 内联的水平列表?

javascript - 获取文本框的背景颜色

javascript - Google Maps API v3 Firefox 问题

javascript - Event.preventDefault() 和表单中的复选框?

javascript - 外部文件中的函数不起作用

google-maps - 移除 Google map 信息气泡

javascript - Google map 将信息框标记在完全相同的位置

php - jQuery 下拉依赖