Qai*_*tti 6 javascript php google-maps
我收到以下错误.
错误
属性列表后面的SyntaxError:missing}
内容:Al futaim,贸易公司
<br />
Building M,36,Saih Shuaib 3 -
PHP代码
$content=$servicecenter->getCompanyName()."<br />".$servicecenter->getAddress()."<br /><button type='button' value='Get Direction' class='button' onclick='closeInfoWindow(),calcRoute()' name='Get Direction'>Get Direction</button>";
Run Code Online (Sandbox Code Playgroud)
脚本
var infowindow = new google.maps.InfoWindow({
content:<?php echo $content; ?>;
});
Run Code Online (Sandbox Code Playgroud)
std*_*b-- 16
json_encode
在行尾使用和删除分号:
content: <?php echo json_encode($content); ?> /* no ; here! */
Run Code Online (Sandbox Code Playgroud)
缺少quote
s的内容,不需要;
-
content: '<?php echo $content; ?>'
Run Code Online (Sandbox Code Playgroud)
要么
content: <?php echo json_encode($content); ?>
Run Code Online (Sandbox Code Playgroud)