Hello
I try to show location on map using Leaflet from Lat and Long from my database, its OK the map is already shown up, but only show one location, not all from database. Is there any error on my array or loop?
Code:
function show_map($people_id) {
$this->load->library('leaflet');
$config = array(
'center' => '4.637120, 96.842534', // Center of the map
'zoom' => 6, // Map zoom
);
$this->leaflet->initialize($config);
$result = $this->db->query("SELECT * FROM table_location ");
foreach ($result->result_array() as $data)
{
$lat=$data['lat_people'];
$lon=$data['long_people'];
$marker = array();
$marker['position'] = ''.$lat.','.$lon.'';
$this->leaflet->add_marker($marker);
}
$data['map'] = $this->leaflet->create_map();
$this->load->view('view_maps', $data);
}