Hi ,I have attached library google map v3 API and now i need to fetch Latitude and longitude from database which I have calculated and which should display by serial Every time dynamically.I used marker but it's not displaying .Does anyone can help me to solve this problem?
controller:
function Googlemaps($serial)
{
// Load the library
$this->load->library('googlemaps');
$config['minifyJS'] = TRUE;
//$config['center_lat_long']= '030.259565,-81.61062';//30.25953,-81.611
//$config['zoom']=16;
// Initialize our map. Here you can also pass in additional parameters for customising the map
$this->googlemaps->initialize($config);
$coords=$this->dashboard_model->googlemaps($serial);var_dump($coords);
foreach($coords as $coordinate)
{
$marker=array();
$lat1=$coordinate->cycle_19_INT.(substr($coordinate->cycle_20_INT, 0, 2)+(substr($coordinate->cycle_20_INT, 2).".".$coordinate->cycle_21_INT)/60);
$lat2=str_replace($coordinate->cycle_22_INT,'-',$coordinate->cycle_22_INT).(substr($coordinate->cycle_23_INT, 0, 2)+substr((substr($coordinate->cycle_23_INT, 2).".".$coordinate->cycle_24_INT)/60,0,7));
$lat=$lat1.','.$lat2;
$marker['position']=$lat;var_dump($lat);
$this->googlemaps->add_marker($marker);
}
// Create the map
$this->data=array();
$this->data['map'] = $this->googlemaps->create_map();
// Load our view, passing the map data that has just been created
$this->load->view('dashboard/dashboard_googlemap_view', $this->data);
}
model:
function googlemaps($serial)
{
$return=array();
$query=$this->db->select('cycle_19_INT,cycle_20_INT,cycle_21_INT,cycle_22_INT,cycle_23_INT,cycle_24_INT')->from('cycles')->where(array('cycle_serial'=>$serial))->limit(1)->order_by('cycle_timestamp','DESC')->get();
if($query->num_rows()>0)
{
foreach($query->result() as $row)
{
array_push($return,$row);
}
}
return $return;
}
view:
<?php echo $map['javascript'];?> <?php echo $map['mapdiv']; ?>
controller:
function Googlemaps($serial)
{
// Load the library
$this->load->library('googlemaps');
$config['minifyJS'] = TRUE;
//$config['center_lat_long']= '030.259565,-81.61062';//30.25953,-81.611
//$config['zoom']=16;
// Initialize our map. Here you can also pass in additional parameters for customising the map
$this->googlemaps->initialize($config);
$coords=$this->dashboard_model->googlemaps($serial);var_dump($coords);
foreach($coords as $coordinate)
{
$marker=array();
$lat1=$coordinate->cycle_19_INT.(substr($coordinate->cycle_20_INT, 0, 2)+(substr($coordinate->cycle_20_INT, 2).".".$coordinate->cycle_21_INT)/60);
$lat2=str_replace($coordinate->cycle_22_INT,'-',$coordinate->cycle_22_INT).(substr($coordinate->cycle_23_INT, 0, 2)+substr((substr($coordinate->cycle_23_INT, 2).".".$coordinate->cycle_24_INT)/60,0,7));
$lat=$lat1.','.$lat2;
$marker['position']=$lat;var_dump($lat);
$this->googlemaps->add_marker($marker);
}
// Create the map
$this->data=array();
$this->data['map'] = $this->googlemaps->create_map();
// Load our view, passing the map data that has just been created
$this->load->view('dashboard/dashboard_googlemap_view', $this->data);
}
model:
function googlemaps($serial)
{
$return=array();
$query=$this->db->select('cycle_19_INT,cycle_20_INT,cycle_21_INT,cycle_22_INT,cycle_23_INT,cycle_24_INT')->from('cycles')->where(array('cycle_serial'=>$serial))->limit(1)->order_by('cycle_timestamp','DESC')->get();
if($query->num_rows()>0)
{
foreach($query->result() as $row)
{
array_push($return,$row);
}
}
return $return;
}
view:
<?php echo $map['javascript'];?> <?php echo $map['mapdiv']; ?>