Google Maps Javascript API v3热图不显示

时间:2013-01-19 08:41:28

标签: javascript google-maps google-maps-api-3

出于某种原因,地图不会显示....无法确定原因。

下面是代码,由于某种原因地图没有显示...这是我第一次使用Google Maps API v3 API进行热图,所以我有点迷失。

<!DOCTYPE html>
<html style="height: 100%">
  <head>
<meta charset="utf-8">
<title>Heatmap</title>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=visualization"></script>
<style type="text/css">
 html { height: 100% }
 body { height: 100%; margin: 0px; padding: 0px }
 #map { height: 200px; width: 100% }
   </style>  
</head>
<body onload="initialize()" style="height: 100%;>
<div id="map" style="height: 600px; width: 800px;"></div>
<script>
    var map, pointarray, heatmap;
    var callsForService = [
        new google.maps.LatLng(42.2861624, -85.5813606), 
new google.maps.LatLng(42.3033738, -85.583591), 
new google.maps.LatLng(42.2453713, -85.584707), 
new google.maps.LatLng(42.3034079, -85.5973274), 
new google.maps.LatLng(42.249651, -85.595145), 
new google.maps.LatLng(42.2897601, -85.5858846), 
new google.maps.LatLng(42.321433, -85.551406), 
new google.maps.LatLng(42.2848497, -85.5906321), 
new google.maps.LatLng(42.2916942, -85.5818942), 
new google.maps.LatLng(42.3033738, -85.583591), 
new google.maps.LatLng(42.3061913, -85.5962831), 
new google.maps.LatLng(42.321433, -85.551406), 
new google.maps.LatLng(42.2917069, -85.5872286), 
    ];
    function initialize() {
        var mapOptions = {
            zoom: 15,
            center: new google.maps.LatLng(42.2800153,-85.5828371),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        map = new google.maps.Map(document.getElementById('map'),
            mapOptions);

        pointArray = new google.maps.MVCArray(callsForService);

        heatmap = new google.maps.visualization.HeatmapLayer({
            data: pointArray
        });

        heatmap.setMap(map);
  }
</script>
</body>
</html>`

1 个答案:

答案 0 :(得分:1)

缺少双引号:

<body onload="initialize()" style="height: 100%;">
------------------------------------------------^

同时删除callsForService

中的尾随逗号