sh1fralf4tih

C MAP

Dec 8th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Roadmap extends CI_Controller {
  4.  
  5.     function __construct() {
  6.         parent::__construct();
  7.         $this->load->library('googlemaps');
  8.         $this->load->model('M_map');
  9.     }
  10.  
  11.     function index() {
  12.         // Initialize the map, passing through any parameters        
  13.         $config['center'] = '106.7018137,-6.1358678';    
  14.         $config['zoom'] = "auto";
  15.         $this->googlemaps->initialize($config);
  16.         // Get the co-ordinates from the database using our model        
  17.         $coords = $this->M_map->get_coordinates();
  18.         // Loop through the coordinates we obtained above and add them to the map        
  19.         foreach ($coords as $coordinate) {            
  20.             $marker = array();            
  21.             $marker['position'] = $coordinate->LAT.','.$coordinate->LNG;            
  22.             $this->googlemaps->add_marker($marker);        
  23.         }
  24.         // Create the map        
  25.         $data = array();
  26.         $data['map'] = $this->googlemaps->create_map();
  27.         print_r($data['map']['markers']);
  28.         //$this->template->display('map/roadmap', $data);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment