我读了this example from LeanPub,在那里我学会了获取巴士站的坐标。我按照步骤&能够从BusStops.php成功获得坐标
var BusStopsCordinates = [[-40.994970,174.508080],[-41.302690,173.636960],[-41.494130,173.542100],[-40.985850,174.506590],[-40.931630,173.817260],[-41.518300,174.780810],[-41.420790,173.578300],[-42.084140,173.966320],[-41.512850,173.532740]];
按照步骤操作。我在我的Index.html页面上将此BusStops.php文件调用为javascript,如下所示。
<script>
<?php include 'busstops.php'; ?>
var map = L.map('map').setView([-40.994970, 174.508080], 18);
mapLink =
'<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
for (var i = 0; i < planes.length; i++) {
marker = new L.marker([planes[i][0],planes[i][1]])
.addTo(map);
}
</script>
但我完全没有结果。我是PHP&amp;的新手传单。请告诉我主要问题在哪里。
答案 0 :(得分:0)
在我看来,您只是忘了用planes
变量替换示例中的BusStopsCordinates
变量?