Google地球"ERR_CREATE_PLUGIN" [英] Google Earth "ERR_CREATE_PLUGIN"

查看:130
本文介绍了Google地球"ERR_CREATE_PLUGIN"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的错误.我正在尝试加载Google Earth库,但这样做时出现错误"ERR_CREATE_PLUGIN"

I've come across a weird error. I'm trying to load the Google Earth libraries but when doing so am getting the error "ERR_CREATE_PLUGIN"

以下代码可以正常工作:

The following code DOES work:

<script src="http://www.google.com/jsapi"></script>
<script>
    google.load("earth", "1");

    var ge = null;

    function init() {
        google.earth.createInstance("map3d", initCallback, failureCallback);
    }

    function initCallback(object) {
        ge = object;
        ge.getWindow().setVisibility(true);
    }

    function failureCallback(object) {
    }
</script>
</head>
<body onload='init()' id='body'>
    <center>
        <div id='map3d'
            style='border: 1px solid silver; height: 600px; width: 800px;'></div>
    </center>
</body>

该代码不提供:

<script type="text/javascript">
  google.load("earth", "1");

    var ge = null;

    function initCallback(object) {
        ge = object;
        ge.getWindow().setVisibility(true);
    }

    function failureCallback(object) {
    }

    $(document).ready(function() {


        google.earth.createInstance("map3d", initCallback, failureCallback);    
    });
</script>

推荐答案

不起作用的原因是因为jquery可能在Google Earth API之前加载.

The reason that won't work is because jquery may load before the Google Earth API.

google.load()完成之前,$(document).ready()中的jquery会调用google.earth.createInstance().

That is google.earth.createInstance() is getting called by jquery in $(document).ready() before google.load() has finished.

为确保在调用createInstance()之前正确加载所有内容-只需从google.load()方法> Google loader .这样,您便可以使用setOnLoadCallback方法知道何时一切就绪.即

To ensure everything is loaded correctly before calling createInstance() - simply load both, jquery and the earth api, from the Google loader via the google.load() method. That way you can then use the setOnLoadCallback method to know when everything is ready. i.e.

<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
  google.load("jquery", "1"); 
  google.load("earth", "1"); 
  google.setOnLoadCallback(function() { 
    //Place init code here instead of $(document).ready()
    google.earth.createInstance("map3d", initCallback, failureCallback);   
  }); 

  // etc...

这篇关于Google地球"ERR_CREATE_PLUGIN"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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