2012-09-18 194 views
0

我試圖在Google Maps API上製作一些繪圖原型。我在這裏遵循了代碼,並認爲我的代碼應該可以工作,但是我得到一個空白屏幕。所有的對象都具有正確的數據,但沒有骰子。任何幫助,將不勝感激。Google Maps API問題

<!DOCTYPE html> 
<html> 
<head> 
<title>Google Maps Test</title> 
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=<key removed>&sensor=false"></script> 
<style type="text/css"> 
</style> 
<script type="text/javascript"> 
function initialize() { 
    var myLatLng = new google.maps.LatLng(33.001466, -97.354317); 

    var mapOptions = { 
     zoom:6, 
     center:myLatLng, 
     mapTypeId: google.maps.MapTypeId.TERRAIN 
    }; 
    console.log(mapOptions); 

    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 
    console.log(map); 

    var routeCoordinates = [ 
     new google.maps.LatLng(33.001466, -97.354317), 
     new google.maps.LatLng(33.025001, -97.352171), 
     new google.maps.LatLng(33.033219, -97.341700), 
     new google.maps.LatLng(33.049321, -97.320414), 
     new google.maps.LatLng(33.051335, -97.304020), 
     new google.maps.LatLng(33.059464, -97.298355), 
     new google.maps.LatLng(33.083919, -97.295609), 
     new google.maps.LatLng(33.111314, -97.291918), 
     new google.maps.LatLng(33.136042, -97.289257), 
     new google.maps.LatLng(33.182818, -97.287111) 
    ]; 
    console.log(routeCoordinates); 

    var routePath = new google.maps.Polyline({ 
     path:routeCoordinates, 
     strokeColor:"#000000", 
     strokeOpacity:.90, 
     strokeWeight: 2, 
     editable:false 
    }); 
    console.log(routePath); 

    routePath.setMap(map); 
} 
</script> 
</head> 
<body onload="initialize()"> 
<div id="map_canvas"> 

</div> 
</body> 
</html> 
+0

嘗試運行你的應用程序在Chrome中,打F12,然後去安慰,讓我知道它說 –

+0

菲利普,我與開發工具開放運行它在Chrome中。沒有錯誤,只是我正在做的控制檯日誌。 –

回答

1

如果我刪除密鑰並給出地圖div大小,則您的地圖適用於我。

http://www.geocodezip.com/JohnSwaringenSO.html

+0

所以我想我的鑰匙是壞的...... –

+0

如果你的鑰匙壞了,你會得到一個錯誤(或者至少是一個明顯的信息)。如果你的地圖div沒有大小,你會得到一個「空白屏幕」。 – geocodezip

+0

謝謝...每天學點新東西。 –