0

I am using the Google Maps API. I get the Google Map by:

$map = $this->ci->gis->draw_map_position_by_lat_long($this->ci->profile_data['LocLat'],$this->ci->profile_data['LocLong']);
$this->ci->widgets['map']= $map;

Function:

public function draw_map_position_by_lat_long($lat = NULL , $long = NULL) {

    $load['center'] = $lat . ',' . $long;
    $load['map_height'] = "191px";
    $this->ci->googlemaps->initialize($load);
    $i = 0;
    $marker = array();

    $marker['position'] = $lat . ',' . $long;
    $marker['draggable'] = 'TRUE';
    $marker['ondragend'] = "dragmarker(this.getPosition().lat(),this.getPosition().lng())";
    $this->ci->googlemaps->add_marker($marker);

    $map = $this->ci->googlemaps->create_map();
    $this->position_data = array('map' => $map);
    return $this->position_data;
}

The map is every place in my app without any problem except one place.
The strange thing is when I print the map on server side in it is not shown.

        $map = $this->ci->gis->draw_map_position_by_lat_long($this->ci->profile_data['LocLat'],$this->ci->profile_data['LocLong']);
        $this->ci->widgets['map']= $map; 

pre($map);

like this:

enter image description here

I checked in Firebug and no java-script errors.

Another strange thing I found is that when I remove one of my javascript files, the map loads perfectly, but it has no direct link with the Google Map. Also no javascript errors shown in Firebug.

That script is:

jQuery(document).ready(function(){
        jQuery('#photo-slider').bxSlider();


        window.onload = createUploader;     
});

I have no idea what is wrong, I am stuck here. Any suggestion will be appreciated. Thanks

mdml
  • 19,981
  • 8
  • 48
  • 61
Kanishka Panamaldeniya
  • 16,046
  • 27
  • 109
  • 185
  • Why is all your code above written in PHP? Are you using this http://code.google.com/p/php-google-map-api/? One thing that's amiss with your javascript is that within jQuery(document).ready() you shouldn't be using window.onload = createUploader. Replace it with createUploader(); – wheresrhys Feb 01 '12 at 12:13

1 Answers1

4

The script is hogging the load event, which can have the effect that the google map can't use it. If you use the jQuery events instead of DOM events, several scripts can use the event.

Try changing this:

jQuery(document).ready(function(){
        jQuery('#photo-slider').bxSlider();


        window.onload = createUploader;     
});

to:

jQuery(document)
.ready(function(){ jQuery('#photo-slider').bxSlider(); })
.load(createUploader);
Guffa
  • 640,220
  • 96
  • 678
  • 956