I learned from this thread that setting up google map pan is pretty simple Job in Java script using google map API.
Unfortunately I am not good in Java Script and my project is in Codeigniter I used BIOSTALL google map library for Codeigniter which is working excellent (Thanks to BIOSTALL) but now I am stuck with one last thing and that is defining map pans and setting the zoom dynamically. I wonder if someone has experience in it and can guide me how to do that in codeigniter.
I have to display all map markers which are returned from search query. Following is my code to collect markers and create map
$zip_codes=$this->search_model->get_zip_codes();
for($i=0;$i<count($zip_codes);$i++)
{
$data['marker_items']=$this->search_model->get_items_by_zip_code($data['search'],$zip_codes[$i]['zip']);
$marker = array();
$marker['position'] = $data['marker_items'][0]['latitude'].','.$data['marker_items'][0]['longitude'];
$map_markers=$this->load->view('map_marker',$data,true);
$marker['infowindow_content']=$map_markers;
$marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='.count($data['marker_items']).'|3399FF|000000';
$this->googlemaps->add_marker($marker);
}
$data['map'] = $this->googlemaps->create_map();
I get map center coordinates by two ways;
My Site Link
Will appreciate any kind of help. Thanks
You can use the $config['zoom'] = 'auto'; It'll act like the fitbound function of the JS map library.
You can also set he minimum zoom level to get the not very deep zoom and for good user experience.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With