0
我创建了一个使用谷歌地图的地图,它显示出很好的效果,并显示了我想要的所有标记,但是点击事件并未触发,我看不出为什么我已经将脚本从在Jquery中准备好文档的初始化函数,然后再次返回,因为它没有什么区别。我将整个脚本从标题部分移到了没有任何区别的底部。单击谷歌地图上的事件标记没有触发
我很茫然,因为出了什么问题,我想填充一个div,它会在点击标记时出现在地图的边上。
感谢您的任何帮助,我会把它放在一个分支,但它的工作,使ajax调用一个XML文件。
<script type="text/javascript">
function initialize()
{
var iconBase = 'https://dl.dropboxusercontent.com/u/102059869/'; //public drop box for icons
var latlng = new google.maps.LatLng(53.74,-2);//centres map around hull
var myOptions = {zoom: 8,center: latlng,mapTypeId: google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById("map"), myOptions);// Creates Map
var mylatlng = new google.maps.LatLng(53.745670900000000000,-0.336741299999971500);
var marker = new google.maps.Marker({position: mylatlng,map: map,title: 'Kingstown', icon: iconBase + 'Kingstown_Logo.png'});// Creates Marker
//Creates markers from data
$.get('PHP/SQL_MainData.php', function(d){
$(d).find("marker").each(function()
{
var latlng = new google.maps.LatLng($(this).attr('latitude'),$(this).attr('longitude')); //gets Google LatLng
var myMarker = new google.maps.Marker(
{position: latlng,
map: map,
title:$(this).attr('traffic'),
icon: iconBase + 'caution.png'
});
marker.info = new google.maps.InfoWindow({content: '<b>Info:</b> ' + $(this).attr('traffic')});
});
});
google.maps.event.addListener(marker, 'click', function() {
marker.info.open(map, marker);
$('#info-area span').text(marker.info);
});
}
</script>