【发布时间】:2010-08-26 15:08:59
【问题描述】:
我正在尝试加载带有动态标记和动态 infoWindows 的谷歌地图以配合它们。基本上我已经让标记工作了。 infoWindows 是可点击和可关闭的,但是它们没有正确的内容。似乎每个 infoWindow 的内容都是在查询循环中找到的最后一条记录。你会看到发生了什么here 这是代码:
<script type="text/javascript">
//Load the Google Map with Options//
function initialize() {
var myLatlng = new google.maps.LatLng(42.48019996901214, -90.670166015625);
var myOptions = {
zoom: 6,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//Begin query loop to set the markers and infoWindow content//
<cfoutput query="GetCoord">
var LatLng = new google.maps.LatLng(#Client_Lat#, #Client_Lng#);
var marker = new google.maps.Marker({
position: LatLng,
map: map,
title: "#Client_Company#"
});
var contentString = '<p><b>#Client_Company#</b><br>'+
'#Client_Address#<br>'+
'#Client_City#, #Client_State# #Client_Zip#<br>'+
'<a href="member_detail.cfm?ID=#Client_ID#">View Details</a>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,this);
});
</cfoutput>
//End query loop
}
</script>
关于为什么会发生这种情况的任何想法?
【问题讨论】:
-
在 FF3.6.8 中,我得到三个地图标记,根据页面源显示正确。您遇到什么浏览器问题?
-
这三个是正确的地图标记,但 infoWindows 中的内容应该不同。这三个实际上都是我的 GetCoord 查询中最后一条记录的内容。
标签: javascript google-maps coldfusion