2012-03-02 63 views
0

我從官方示例中複製了此代碼...我只是更換了api鍵和座標。多邊形根本不顯示

我在做什麼錯?

地圖顯示OK ,,,但多邊形不...

任何幫助將apreciated ...

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
<title>Google Maps JavaScript API v3 Example: Polygon Simple</title> 
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=AIzaSyAdL-4IAZxpfEjgVUHOTOHnPMAeD8KECNI&sensor=true"></script> 
<script type="text/javascript"> 
function initialize() { 
var myLatLng = new google.maps.LatLng(-34.921127, -57.952709); 
var myOptions = { 
zoom: 13, 
center: myLatLng, 
mapTypeId: google.maps.MapTypeId.TERRAIN 
}; 
var bermudaTriangle; 
var map = new google.maps.Map(document.getElementById("map_canvas"), 
myOptions); 
var triangleCoords = [ 
new google.maps.LatLng(-57.980518,-34.922787), 
new google.maps.LatLng(-57.953396,-34.942068), 
new google.maps.LatLng(-57.953224,-34.942771), 
new google.maps.LatLng(-57.928677,-34.920395), 
new google.maps.LatLng(-57.955799,-34.900124) 
]; 
// Construct the polygon 
bermudaTriangle = new google.maps.Polygon({ 
paths: triangleCoords, 
strokeColor: "#dddddd", 
strokeOpacity: 0.8, 
strokeWeight: 2, 
fillColor: "#dddddd", 
fillOpacity: 0.50 
}); 
bermudaTriangle.setMap(map); 
} 
</script> 
</head> 
<body onload="initialize()"> 
<div id="map_canvas"></div> 

回答

0

你的代碼工作正常,但你有你的緯度和經度混合。在設置您的視口時,您有我認爲是正確的順序(以阿根廷拉普拉塔爲中心),但是在定義您的路徑時,您將切換順序。所以多邊形正在南大西洋的深處繪製。