Php “如何修复”;SyntaxError:意外标记'<'&引用;

Php “如何修复”;SyntaxError:意外标记'<'&引用;,php,html,google-maps-api-3,Php,Html,Google Maps Api 3,我有一些代码可以使用LAT&LONG,数据保存在一个txt文件中,并以html的形式显示为谷歌地图。但是php函数导入txt,没有任何效果。你知道问题出在哪里吗 我试着在其他机器上运行,而系统中的rasp是安装在Nginx中的 <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <

我有一些代码可以使用LAT&LONG,数据保存在一个txt文件中,并以html的形式显示为谷歌地图。但是php函数导入txt,没有任何效果。你知道问题出在哪里吗

我试着在其他机器上运行,而系统中的rasp是安装在Nginx中的

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>LOCATION</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?key="></script>
    <?php $array = explode("\n", file_get_contents('locations.txt')); ?>
    <script>
    function initialize() {
    var mapOptions = {
    zoom: 20,
    center: new google.maps.LatLng(<?php echo $array[0]; ?>),
    mapTypeId: google.maps.MapTypeId.HYBRID
    };


    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

    var flightPlanCoordinates = [

<?php foreach ($array as $arrayItem) { 
echo 'new google.maps.LatLng('.$arrayItem.'),'; 
} ?>
                                ];

    var flightPath = new google.maps.Polyline({
        path: flightPlanCoordinates,
        geodesic: true,
        strokeColor: '#FF0000',
        strokeOpacity: 1.0,
        strokeWeight: 2
    });
    flightPath.setMap(map);
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>
    <body>
        <div id="map-canvas"></div>
    </body>
</html>

地方
html,正文,#地图画布{
身高:100%;
边际:0px;
填充:0px
}
函数初始化(){
变量映射选项={
缩放:20,
中心:新的google.maps.LatLng(),
mapTypeId:google.maps.mapTypeId.HYBRID
};
var map=new google.maps.map(document.getElementById('map-canvas'),mapOptions);
var FlightPlan坐标=[
];
var flightPath=new google.maps.Polyline({
路径:FlightPlan坐标,
测地线:正确,
strokeColor:“#FF0000”,
笔划不透明度:1.0,
冲程重量:2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(窗口“加载”,初始化);
Trows错误“SyntaxError:意外标记”在第20行,您有

center: new google.maps.LatLng(<?php echo $array[0]; ?>),
center:new google.maps.LatLng(),
换成

center: new google.maps.LatLng('<?php echo $array[0]; ?>'),
center:new google.maps.LatLng(“”),

将其更改为->echo'new google.maps.LatLng(“.$arrayItem.”);谢谢你的工作,这部分的另一个问题是var flightplancomatives=[”);我得到了“SyntaxError:意外的EOF”