我正在尝试创建一个带有多边形叠加层的Google地图,以便加载到我的网站上。当我加载页面时,文本显示但是地图没有加载。
我是javascript的新手,并不完全确定我在做什么,并且非常感谢新鲜(经验丰富)的一双眼睛。
以下代码位于html页面中。 div规范都在css文件中定义,覆盖的坐标在链接的javascript文件中。
这是我的代码:
<head>
<link rel="stylesheet" href="../style.css"/>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?&sensor=false"></script>
<script type="text/javascript" src="greatredoubtData.js"></script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(43.003207, -73.610312),
zoom: 16,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById('maps1k'),mapOptions);
var greatredoubt = createOverlay();
greatredoubt.setMap(map);
}
function createOverlay() {
var overlayCoords = new Array ();
var processedData = greatredoubtData.split(";");
for (var i=0; i<processedData.length; i++) {
var myCoords = processedDate[i].split(",");
overlayCoords.push(new google.maps.LatLng(xyCoords[0], xycoords[1]));
}
var myOverlay = new google.maps.Polygon({
paths: overlayCoords,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35
});
return myOverlay
}
</script>
</head>
<body onLoad="initialize">
<p class="subtitle">Great Redoubt Prescribed Burn</p>
<p>Saratoga National Historical Park</p>
<div id="maps1" name="maps1">
</div>
<p class="caption">Date: April 22, 2011
</br>
Location: LAT: 43.0023593/LON: -73.6106062/ LAT:43.0061421/LON:-73.6139449 (Tour Road Stop 9 & 10, Saratoga NHP, Stillwater, NY)
</br>
Burn Boss: Jeff Wells, National Park Service
</br>
Acres: 20/15 (planned)
</br>
Primary Goals: reduce hazard fuels around historic structures, and maintain the cultural landscape of open fields and vistas for the visiting public, thereby eliminating mechanical mowing.
</p>
</body>
答案 0 :(得分:0)
试试这个fiddle现在正在使用
<div id="maps1" name="maps1" style="width:400px;height:600px;">
</div>