我正在使用代码点火器。这是我在 obj 数组中查询结果的 php 代码,那么我如何将它们传递给 js。我想在谷歌地图中使用它
<?php
foreach ($query->result() as $row)
{
$lat = $row->geo_lat;
$lng = $row->geo_lng;
$pic = $row->picture;
echo $lat;
echo $lng;
echo "<img src=\"" . base_url() . $pic . "\"/><br />";
//echo json_encode($row);
//echo "<pre>";
//echo print_r($row);
}
?>
js代码
var locations = ?????????;
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][0], locations[i][1]),
map: map,
draggable: true
});
}