我的谷歌地图运行得很好。我一直试图让一个infowindow立即打开,并在这样做的过程中,打破了我的代码。此时我无法让它回到工作阶段。我已经完成了十几次代码并且找不到任何错误。我的更改基于stackoverflow论坛上的this article。
<script type="text/javascript">
function initialize() {
var infowindow new google.maps.InfoWindow();
var LatLng = new google.maps.LatLng(38.89, -92.343);
var myOptions = {
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: LatLng
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var bounds = new google.maps.LatLngBounds();
var Image = "images/wrenchIcon.png";
var Content = "blank";
var Head = "The Falls";
var cMarker = new google.maps.Marker({
position: LatLng,
map: map,
title: Head,
icon: Image
})
google.maps.event.addListenter(cMarker, 'click', function() {
infowindow.setContent(Content);
infowindow.open(map, cMarker);
});
Image = "images/goodIcon.png";
LatLng = new google.maps.LatLng(38.912, -92.301);
Content = "blank";
Head = "Bob TheBuilder";
var marker1 = new google.maps.Marker({
position: LatLng,
map: map,
title: Head,
icon: Image
});
google.maps.event.addListenter(marker1, 'click', function() {
infowindow.setContent(Content);
infowindow.open(map, marker1);
});
bounds.extend(LatLng);
Image = "images/alertYelIcon.png";
LatLng = new google.maps.LatLng(38.951, -92.332);
Content = "blank";
Head = "Shiloh Bar&Grill";
var marker2 = new google.maps.Marker({
position: LatLng,
map: map,
title: Head,
icon: Image
});
google.maps.event.addListenter(marker2, 'click', function() {
infowindow.setContent(Content);
infowindow.open(map, marker2);
});
bounds.extend(LatLng);
Image = "images/goodIcon.png";
LatLng = new google.maps.LatLng(38.92, -92.332);
Content = "blank";
Head = "FlatBranch Pub";
var marker3 = new google.maps.Marker({
position: LatLng,
map: map,
title: Head,
icon: Image
});
google.maps.event.addListenter(marker3, 'click', function() {
infowindow.setContent(Content);
infowindow.open(map, marker3);
});
bounds.extend(LatLng);
</script>
答案 0 :(得分:0)
看起来你的初始化函数没有结束}
如果这个问题不是什么时候调用函数,onload?
答案 1 :(得分:0)
看起来你在初始化函数的第一行中缺少=
。