Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up Google map pans in Code igniter with BIOSTALL google map library

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;

  • If the user is logged in . Get his coordinates from his address
  • If the user is logged out. Get his coordinates from his IP address.

My Site Link

Will appreciate any kind of help. Thanks

like image 884
Malik Mudassar Avatar asked Nov 20 '25 13:11

Malik Mudassar


1 Answers

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.

like image 92
Navigator Avatar answered Nov 23 '25 02:11

Navigator