1

我正在创建一个使用 Google Maps API 来显示地图的网络应用程序。当我重新加载页面时,它不会初始化我的坐标告诉它的地图并且是“模糊的”。一旦我使用左侧的工具栏缩小并放大一切都很好。这是我的代码:

<!DOCTYPE html>
<html>
<head>
<title>Google Maps JavaScript</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<style type="text/css">
  html, body, #map_canvas {
    margin: 0;
    padding: 0;
    height: 50%;
  }
</style>
<script type="text/javascript"
    src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  var map;
  function initialize() {
    var myOptions = {
      zoom: 14,
      center: new google.maps.LatLng(2.3584170693, -71.065063476),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
        myOptions);

  var bikeLayer = new google.maps.BicyclingLayer();
  bikeLayer.setMap(map);

    var marker = new google.maps.Marker({
    position: new google.maps.LatLng(42.346872819794896, -71.06643676757812),
      map: map,
      title: 'REPORT'
    });

    var marker = new google.maps.Marker({
    position: new google.maps.LatLng(42.363363955820496, -71.08978271484375),
      map: map,
      title: 'REPORT'
    });
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas" style="width: 90%; height: 300%"></div>
</body>
</html>
4

1 回答 1

0

我注意到您的标记在波士顿 (42.3, -71) 附近,但选项中所写的地图中心缺少“4”,并将初始位置发送到哥伦比亚 (2.3, -71)。

关于模糊性,是否只是自行车层需要一段时间才能加载?我无法重现这种效果。

于 2012-06-22T20:28:39.917 回答