Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Google map shown in localhost, in website not shown
#1

(This post was last modified: 04-04-2020, 02:37 AM by jreklund.)

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/...nsor=false): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
Filename: libraries/Googlemaps.php

Any ideas why this happens ? Thanks
Reply
#2

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

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.
Reply
#4

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?
Reply
#5

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

Code:
var $https                      = TRUE;

Well,it works now
Reply




Theme © iAndrew 2016 - Forum software by © MyBB