CodeIgniter Forums
[SOLVED] Google map shown in localhost, in website not shown - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [SOLVED] Google map shown in localhost, in website not shown (/showthread.php?tid=75936)



[SOLVED] Google map shown in localhost, in website not shown - kelapamuda - 03-30-2020

Hello, 
I have columns in a table, for example   :   name, employee_lat, employee_long .
I show them in google maps using library CodeIgniter-Google-Maps-V3-API-Library,, in localhost everything is OK .
One of function i use is this
Code:
        function map_loc()
     {
        $this->load->library('googlemaps');
        $config['center'] = '4.637120, 96.842534';
        $config['zoom'] = "8";
           $this->googlemaps->initialize($config);
        //Mulai Query
        $result = $this->db->query("SELECT * FROM employee_loc");
       
        foreach ($result->result_array() as $data){
        $lat=$data['employee_lat'];
        $lon=$data['employee_long'];
       
        $marker = array();     
        $marker['position'] = ''.$lat.','.$lon.'';
        $this->googlemaps->add_marker($marker);
       }
        $data['map'] = $this->googlemaps->create_map();     
        $this->load->view('dashboard/v_view_maps', $data);  
      
      
     }  

Everythings is OK in localhost. I am able to produce any sql i want and it shown well in google maps.
 But when i put in real website in internet, the website is OK but no google maps is shown there. Error is this 

Severity: Warning
Message: file_get_contents(http://maps.google.com/maps/api/geocode/json?address=%2C&sensor=false): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
Filename: libraries/Googlemaps.php

Any ideas why this happens ? Thanks



RE: Google map shown in localhost, in website not shown - jreklund - 03-30-2020

Dosen't look like you are sending an API key along that, have you checked the docs if you need one?


RE: Google map shown in localhost, in website not shown - kelapamuda - 03-30-2020

It looks strange, error says as if i dont have APi Key from google. Yes i have, and for sure, i just request the second api key from google and use it. But still not shown yet that google maps.


RE: Google map shown in localhost, in website not shown - kelapamuda - 04-03-2020

Well, its about https. If i st $config['base_url']= https,,its not shown.. If i set $config['base_url']=http, the map shown. 
But i need my website to be https as always. In chorme i inspect and this is the result:

Mixed Content: The page at 'https websayaxxx' was loaded over HTTPS, but requested an insecure script 'http://maps.googleapis.com/maps/api/js?key=blablsablsasayaxxx&sensor=false'. This request has been blocked; the content must be served over HTTPS. 
Any ideas?


RE: Google map shown in localhost, in website not shown - kelapamuda - 04-03-2020

Change this line on folder libary/Googlemaps.php on line 44 to TRUE

Code:
var $https                      = TRUE;

Well,it works now