Welcome Guest, Not a member yet? Register   Sign In
Show locations using Leaflet, array ?
#1

(This post was last modified: 04-07-2020, 01:32 AM by kelapamuda.)

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);  
                 
                         }
    
     

    
Reply
#2

@kelapamuda,

Have you tested the query to make sure that it is pulling more than 1 location?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB