我想做类似this demo的事情 但我想从数据库中加载纬度和经度值。我能够在地图上加载标记,但它不会移动。我正在使用Codeigniter框架和Google Map JS API v3。我使用Mysql作为数据库。这是代码:
//inside the setInterval function of the above demo
interval = window.setInterval(function() {
<?php
$this->load->model('Maps/Maps_Model');
$data['result11'] = $this->Maps_Model->getLastPagination();
?>
var pos = new google.maps.LatLng(<?php echo $result11->lat; ?>,<?php echo $result11->lon; ?>);
marker.setPosition(pos);
}, 10);
//inside my model
function getLastPagination(){
$query = $this->db->query("select lat,lon from map order by id DESC limit 1");
if ($query->num_rows() > 0){
$row = $query->row();
return $row;
}
}