如果页面上有一个JavaScript错误,谷歌地图不加载? [英] If there is a javascript error on the page, does google map not load?

查看:168
本文介绍了如果页面上有一个JavaScript错误,谷歌地图不加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Maps API。我通过以下方式获得Google Map:

  $ map = $ this-> ci-> gis-> draw_map_position_by_lat_long($这 - > CI-> profile_data [ 'LocLat'],$这 - > CI-> profile_data [ 'LocLong']); 
$ this-> ci->小工具['map'] = $ map;

功能:

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

$ load ['center'] = $ lat。 ','。 $长;
$ load ['map_height'] =191px;
$ this-> ci-> googlemaps->初始化($ load);
$ i = 0;
$ marker = array();

$ marker ['position'] = $ lat。 ','。 $长;
$ 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);
返回$ this-> position_data;
}

地图是我应用程序中除了一个地方以外没有任何问题的每个地方。
奇怪的是当我在服务器端打印地图时,它没有显示。

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

pre($ map);

像这样:


我检查了Firebug和没有java脚本错误

我发现另一个奇怪的事情是,当我删除我的一个javascript文件时,地图加载完美,但它与Google Map没有直接关联。也没有在Firebug中显示的JavaScript错误。



该脚本是:

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


window.onload = createUploader;
});

我不知道什么是错,我被困在这里。任何建议将不胜感激。谢谢

解决方案

脚本占用 load 事件,谷歌地图无法使用它的效果。如果您使用jQuery事件而不是DOM事件,几个脚本可以使用该事件。



试着改变它:



< pre $ jQuery(document).ready(function(){
jQuery('#photo-slider')。bxSlider();


window.onload = createUploader;
});

到:

 < code $ j 
.ready(function(){jQuery('#photo-slider')。bxSlider();})
.load(createUploader);


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:

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

解决方案

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);

这篇关于如果页面上有一个JavaScript错误,谷歌地图不加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆