2013-01-19 106 views
1

出於某種原因,地圖不會顯示....真的不能找出原因。谷歌地圖JavaScript API V3熱圖顯示不

下面是代碼,由於某種原因,地圖是不顯示...這是我與谷歌地圖API第3版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

存在丟失的雙引號:

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

而且刪除尾隨逗號callsForService

+0

感謝...這就是它! –