PHP和InfowWindows while($DNB->fetch()){ ?> var infowindow=new google.maps.infowindow({content:}); var point=newgoogle.maps.LatLng(,); var marker=new google.maps.marker({position:point,map:map}); 谷歌地图

PHP和InfowWindows while($DNB->fetch()){ ?> var infowindow=new google.maps.infowindow({content:}); var point=newgoogle.maps.LatLng(,); var marker=new google.maps.marker({position:point,map:map}); 谷歌地图,php,google-maps-markers,Php,Google Maps Markers,t、 addListener(标记,'click',function(){infowindow.open(映射,标记);}); 当我运行上述代码时,映射不会显示。但是,当我用“blah”替换php标记时,它会工作。我不知道为什么。尝试在php代码段周围加引号 while($DNB->fetch()){ ?> var infowindow = new google.maps.InfoWindow({content: <?php echo $businessnam

t、 addListener(标记,'click',function(){infowindow.open(映射,标记);});
当我运行上述代码时,映射不会显示。但是,当我用“blah”替换php标记时,它会工作。我不知道为什么。

尝试在php代码段周围加引号

    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
var infowindow=new google.maps.infowindow({content:});
var point=new google.maps.LatLng(“,”);
var marker=new google.maps.marker({position:point,map:map});
google.maps.event.addListener(标记,'click',function(){infowindow.open(映射,标记);});

事实上,如果$lat和$lon是有效的浮动,您不需要在它们周围加引号,但您可以尝试两种方法,看看效果如何。您是否尝试过在$lat和$lon片段周围不加引号的情况下使用它?标记会显示,但信息窗口只显示一个标记。有什么原因我会得到多个标记,但只有一个信息窗口?您可以添加吗原始帖子中的循环代码的其余部分?
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);});