I actually integrate google map for my site but map is not displayed, I take library googlemaps but still not displayed. here is my code:
controller:
<?php
class api extends CI_Controller
{
public function index()
{
parent::Controller();
}
function googleapi()
{
$this->load->library('googlemaps');
$config = array();
$config['zoom'] = 'auto';
$config['geocodeCaching'] = TRUE;
$config['region'] = 'US';
$config['sensor'] = FALSE;
$this->googlemaps->create($config);
$markers = array();
$marker['position'] = '37.429, -122.1519';
$marker['animation'] = 'DROP';
$this->googlemaps->add_markers($markers);
$markers = array();
$marker['position'] = '1600 Amphitheatre Parkway in Mountain View, Santa Clara County, California United States';
$marker['animation'] = 'DROP';
$this->googlemaps->add_markers($markers);
$data['map'] = $this->googlemaps->create();
echo print_r($data['map']['markers']);
}
}
?>
help me if there is something wrong in my code. Thank you
Try like this :
Controller File:
$this->load->library('googlemaps');
$config['center'] = '37.4419, -122.1419';
$config['zoom'] = 'auto';
$this->googlemaps->initialize($config);
$marker = array();
$marker['position'] = '37.429, -122.1419';
$this->googlemaps->add_marker($marker);
$data['map'] = $this->googlemaps->create_map();
$this->load->view('view_file', $data);
View File:
<html>
<head><?php echo $map['js']; ?></head>
<body><?php echo $map['html']; ?></body>
</html>