如何从 mysql 数据库中检索值并根据标记在 infowindow 中显示?
示例第一个标记,信息窗口应显示“A”..现在,它显示了所有内容。我该怎么做呢?请指导我完成。谢谢!
<script>
var map;
var marker;
var infowindow;
var info = <?php echo json_encode($infoWindow); ?>;
var placeX= <?php echo json_encode($getX); ?>;
var placeY= <?php echo json_encode($getY); ?>;
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(1.35208,103.81984),
zoom:11,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
for(var x=0; x<placeX.length; x++)
{
retrieve(placeX[x],placeY[x],info[x])
}
}
function retrieve(x,y,i)
{
var marker=new google.maps.Marker({
position:new google.maps.LatLng(y,x),
});
marker.setMap(map);
marker.setIcon('http://maps.google.com/mapfiles/ms/icons/green-dot.png')
marker.info = new google.maps.InfoWindow ({content: '<b>No. of people who choose this location:</b> '+ info});
google.maps.event.addListener(marker, 'click',function(){
marker.info.open(map,marker);
});
}
function addInfoWindow(x,y,h)
{
var infowindow = new google.maps.InfoWindow({
content:"Hello World!"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>