0
    while($DNB->fetch()){
?>
     var infowindow = new google.maps.InfoWindow({content: <?php echo $businessname ?>});
     var point  = new google.maps.LatLng(<?php echo $lat ?>, <?php echo $lon ?>);
     var marker = new google.maps.Marker({position: point, map:map});
     google.maps.even

t.addListener(marker, 'click', function(){infowindow.open(map,marker);});

当我运行上面的代码时,地图没有显示。但是,当我用“blah”替换 php 标签时,它可以工作。我不确定为什么。

4

1 回答 1

0

尝试在 PHP 代码段周围加上引号。

var infowindow = new google.maps.InfoWindow({content: "<?php echo $businessname ?>"});
var point  = new google.maps.LatLng("<?php echo $lat ?>", "<?php echo $lon ?>");
var marker = new google.maps.Marker({position: point, map:map});
google.maps.event.addListener(marker, 'click', function(){infowindow.open(map,marker);});
于 2012-06-14T17:40:07.560 回答