Welcome Guest, Not a member yet? Register   Sign In
Google map doesn't work online
#1

[eluser]Omaplie[/eluser]
Hi,

I really need your help.
I have a work for this friday where I included a Google map.
The google map displayed all locations that I include in my database.
Every thing works well in local but online, the map doesn't appear…

Code:
<?php
    function map()
    {
        $this->session->unset_userdata('search_unite');
        
        // Load the library
        $this->load->library('googlemaps');
        // Load our model
        $this->load->model('unite_model', '', TRUE);
        // Initialize the map, passing through any parameters
        $config['center'] = 'Liège,Belgique';
        $config['zoom'] = 'auto';
        $this->googlemaps->initialize($config);
        // Get the co-ordinates from the database using our model
        $coords = $this->unite_model->get_coordinates();
        // Loop through the coordinates we obtained above and add them to the map
        foreach ($coords as $coordinate)
        {
            $marker = array();
            $marker['position'] = $coordinate->adresse_coords.', Belgique';
            $marker['infowindow_content'] = '<b>'.$coordinate->nom_coords.' '. $coordinate->adresse_coords .'</b>'.'</br>'. $coordinate->description_coords;
            /*$marker['position'] = $coordinate->lat.','.$coordinate->lng;*/
            $this->googlemaps->add_marker($marker);
        }
        // Create the map
        $data = array();
        $data['map'] = $this->googlemaps->create_map();
        // Load our view, passing through the map data
        
        $data['users_online'] = $this->get_users_online();
        $data['uniteName'] = $this->uniteName();
        $data['numberInvit'] = $this->numberInvit();
        
        $layout_network['contenu'] = $this->load->view('my_view', $data, TRUE);
        $this->load->view('layout_network',$layout_network);
    }?&gt;

I do not think it's a trouble with my code because every thing is fine on my computer.

I really need your help.
Hope someone can help me.

Thank you very much.
#2

[eluser]alsemany[/eluser]
I'm using the same library for my project dnscall.org

and here an example
http://www.dnscall.org/domain/codeigniter.com

if this work well on your computer and doesn't well on the hosting server

I think the problem caused by php configuration

please be sure that the (fopen) function is active

#3

[eluser]Omaplie[/eluser]
Hi,

Thank you very much for your quick answer, it's really kind !
I am trying to enable the fopen function but i am not allowed to
modify the php.ini. I got in touch my hosting and I am waiting for an answer
(I hope they'll hurry up).

Are you on a dedicated server or on a shared server ?
#4

[eluser]alsemany[/eluser]
it's a VPS (Virtual Private Server)

you could try this on the .htaccess file on your web root
if mod_php is installed this will be easy

Code:
<Ifmodule mod_php4.c>
php_flag allow_url_fopen  on

</Ifmodule>

<Ifmodule mod_php5.c>
php_flag allow_url_fopen  on
</Ifmodule>
#5

[eluser]Omaplie[/eluser]
Hi,

Thank you very much for your help.
Unfortunately, it doesn't work.

I read somewhere that I need to use
a proxy server.
http://developer.yahoo.com/javascript/howto-proxy.html

Do you think it can be the trouble ?
I don't really understand everything…

Thank you so much for your help.
#6

[eluser]LuckyFella73[/eluser]
I had the same problem a few days before - it was a server configuration issue.
In my experience fopen is often restricted to your own server while curl is not.

Here a function I use to get geo coordinates - just change the
parameters (address, output format) send to google according to your application:
Code:
/**
     * Returns an array containing longitude and latitude
     * according to the given zip
     *
     * @access  private
     * @param   String, String
     * @return  array
     */
private function get_coords($plz, $land = 'Deutschland')
{
  $result = array();
  
  $address = "http://maps.google.com/maps/geo?q=$plz,$land&output=xml";
  $address = utf8_encode($address);

  $ch = curl_init();        //Initialize the Curl session
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
  curl_setopt($ch, CURLOPT_URL, $address);  //Set the URL
  $xml_data = curl_exec($ch);      //Execute the fetch
  curl_close($ch);        //Close the connection

  // Parse XML
  $xml_data = stripslashes($xml_data);
  $xml = new SimpleXMLElement($xml_data);

  $coords_string  = $xml->Response->Placemark->Point->coordinates;
  $coords = explode(",", $coords_string);
  $result['user_longitude'] = $coords[0];
  $result['user_latitude'] = $coords[1];

  return $result;
}

If you use a library that make use of fopen you could just replace the fopen part
with the curl part for my function handles the return data differently
#7

[eluser]alsemany[/eluser]
[quote author="Omaplie" date="1339579517"]Hi,

Thank you very much for your help.
Unfortunately, it doesn't work.

I read somewhere that I need to use
a proxy server.
http://developer.yahoo.com/javascript/howto-proxy.html

Do you think it can be the trouble ?
I don't really understand everything…

Thank you so much for your help.[/quote]


I don't think so
you don't need to use a proxy server to run google maps API

you just need to allow URL Fopen and Curl function
#8

[eluser]Omaplie[/eluser]
Hi,

I contacted my hosting and they answered me that normaly fopen is enable on most server except if the safe_mod is enable, it could have conflicts.

I don't understand everything what you say me to do with the code you gave me.
I use this library : https://github.com/BIOSTALL/CodeIgniter-...ves/master

I tried to change fopen to curl but I don't think it's what you mean…
I am sorry…

Thank you very much !
#9

[eluser]Omaplie[/eluser]
I've just checked my php configuration and it's not a trouble with the fopen because it's enable : « allow_url_fopen On »

Apparantly, it's an another trouble, what do you think ?
#10

[eluser]Omaplie[/eluser]
Someone get an idea ?




Theme © iAndrew 2016 - Forum software by © MyBB