Welcome Guest, Not a member yet? Register   Sign In
Google maps can not be loaded
#1

[eluser]Unknown[/eluser]
I have tried this script, but google maps cannot be loaded.

Model:
Code:
<?php
class mymap_model extends CI_Model {

public function getAllMarkers() {
    $this->load->database();
    $query = $this->db->get('mymap');

    if( $query->num_rows() > 0 ) {
        return $query->result();
    } else {
        return false;
    }
    }    
    
    
}
?>

Controller
Code:
<?php
class Mymap extends CI_Controller {
  
      
  function __construct()
  {
  
    parent::__construct();
    

  }
  
  function index(){
  
    
    $this->load->library('googlemaps');

  

    $config['center'] = '37.4419, -122.1419';
    $config['zoom'] = 'auto';

    $this->googlemaps->initialize($config);
    
    
    $this->load->model('mymap_model');
  
    
  
    $db_markers = $this->mymap_model->getAllMarkers();
    
    if( $db_markers ){
        
        
        foreach( $db_markers as $db_marker ){
            
        $marker = array();
        $marker['position'] = $db_marker->lat.', '.$db_marker->lng;
        $marker['infowindow_content'] = $db_marker->place.'\'<b>'.$db_marker->place.'</b><br>'.$db_marker->desc;
        $marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
        $this->googlemaps->add_marker($marker);
        
        }
      
       $data['map'] = $this->googlemaps->create_map();
        
    }else{
        
        $data['map'] = false;
        
    }
  
    $this->load->view('mymap_view.php', $data);
  
  }
  

}

?&gt;

View
Code:
&lt;?php
    if(!$map){
        echo "no data available!";
    }else{
        
        ?&gt;

&lt;html&gt;
&lt;head&gt;&lt;?php echo $map['js']; ?&gt;&lt;/head&gt;
&lt;body&gt;&lt;?php echo $map['html']; ?&gt;&lt;/body&gt;
&lt;/html&gt;

&lt;?
}
?&gt;

Any help would be greatly appreciated guys Smile




Theme © iAndrew 2016 - Forum software by © MyBB