<?php
 
defined('BASEPATH') OR exit('No direct script access allowed');
 
class Google extends MY_Controller {
 
    public function __construct() {
        parent::__construct();
        // load model
        $this->load->admin_model('Google_model', 'google');
    //    $this->load->helper(array('url','html','form'));
    }    
 
    public function index($user_id = NULL) {//print_r($user_id);die();
          /*if ($this->input->get('id')) {
            $sale_id = $this->input->get('id');
        }
      $inv = $this->google->getInvoiceByID($sale_id);
        $biller_id = $inv->biller_id;
        $date = $inv->date;*/
       // $this->input->post('user_id');
        //$date = '2020-03-30 14:40:34';//$this->input->post('date');
    /*  $users = $this->google->get_list($user_id,$date);
//$markers = [];
foreach($users as $value) 
	{
        $markers = $value->lattitude.','. $value->longitude
          ;          
          
    }//print_r($markers);die();
	$location['markers'] = json_encode($markers);
	$this->load->library('googlemaps');
    $config['center'] = $markers;
	$config['zoom'] = 'auto';//print_r($config);die();
	$this->googlemaps->initialize($config);
	
	$marker = array();
	$marker['position'] = $markers;
	$this->googlemaps->add_marker($marker);//print_r($marker);die();
	$data['map'] = $this->googlemaps->create_map();  */
	 $id= $this->db->get_where('users',array('id'=>$user_id))->row()->biller_id;
        $user_id =$id;
	$this->load->library('googlemaps');
	$config['apikey'] = 'ABQIBAAADiypSsSGMm4zOSm7T0Nf1BT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTegq9k46u7yla9Jc-SjozzP0J8ig';
 $this->load->admin_model('Google_model', 'google');
$config['center'] = '24.6895448, 46.7002012';
$coordss = $this->google->get_coordinatess($user_id);
$coordsss = $this->google->get_coordinatesss($user_id);
$coordinatess= $coordsss->lattitude.','.$coordsss->longitude;
//$date = $coordsss->date;
//$dates = $coordss->date;
$coordinates= $coordss->lattitude.','.$coordss->longitude;
//print_r($coordinates);die();
$config['directionsStart']=$coordinates;
$config['directionsEnd']=$coordinatess;
$config['zoom'] = "auto";
$this->googlemaps->initialize($config);
$coords = $this->google->get_coordinates($user_id);
foreach ($coords as $coordinate) {//print_r($coords);
$marker = array();
$polyline = array();

$marker['position'] = $coordinate->lattitude.','.$coordinate->longitude;
$datess = $coordinate->date;
$marker['title'] = $datess;
$poly[] =$coordinate->lattitude.','.$coordinate->longitude;
//$marker['position'] = $coordinate->lattitude.','.$coordinate->longitude;
$this->googlemaps->add_marker($marker);
}//die();
$polyline['points'] =$poly;
$this->googlemaps->add_polyline($polyline);
//print_r($poly);die();
$data = array();
$data['map'] = $this->googlemaps->create_map();

  $this->load->view($this->theme . 'google/map_marker', $data);
        
    }
    
     
}
?>