Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery mobile 如何将google earth API与主干.js+;jquerymobile?_Jquery Mobile_Backbone.js_Google Earth - Fatal编程技术网

Jquery mobile 如何将google earth API与主干.js+;jquerymobile?

Jquery mobile 如何将google earth API与主干.js+;jquerymobile?,jquery-mobile,backbone.js,google-earth,Jquery Mobile,Backbone.js,Google Earth,如何将google earth API与主干.js+jquery mobile结合使用 我已经使用backbone.js、下划线.js和jQuery Mobile创建了应用程序。 对于google earth API,我使用的示例代码列在 我的模板呈现和所有其他页面都工作正常,但当我在一个标记中加载google earth API时,它没有加载,在js控制台中,我收到消息:“ERR_INVALID_DIV” Google.earth模块从不回调initCallback,在调用Google.ear

如何将google earth API与主干.js+jquery mobile结合使用

我已经使用backbone.js、下划线.js和jQuery Mobile创建了应用程序。 对于google earth API,我使用的示例代码列在

我的模板呈现和所有其他页面都工作正常,但当我在一个标记中加载google earth API时,它没有加载,在js控制台中,我收到消息:“ERR_INVALID_DIV”

Google.earth模块从不回调initCallback,在调用Google.earth.createInstance时,它总是调用failureCallback

我在下面解释了我的应用程序的一些示例代码,因此基于此,您可能会得到我的代码结构,它可以帮助您解决我的问题

我的js代码如下所示

<script type="text/template" id="myPage">
    <div data-role="page">
        <div data-role="content">
            <div id="map3d" style="height: 400px; width: 600px;"></div>
        </div>
    </div>
</script>
myjs1.js

var ge;
function init() {
  google.earth.createInstance('map3d', initCB, failureCB);
}

function initCB(instance) {
  console.log(' init call back call ');
  ge = instance;
  ge.getWindow().setVisibility(true);
}

function failureCB(errorCode) {
    console.log(errorCode);
}
现在我的主干代码如下所示

<script type="text/template" id="myPage">
    <div data-role="page">
        <div data-role="content">
            <div id="map3d" style="height: 400px; width: 600px;"></div>
        </div>
    </div>
</script>
myjs2.js

WebApp.MyPage= Backbone.View.extend({

initialize:function (result) {
    this.template =_.template($('#myPage').html());
},

render:function (eventName) {
    var self = this;
    mydata = object dict of my data;
    $(self.el).html(self.template({mydata:mydata}));

    google.load("earth", "1");

    init();
    google.setOnLoadCallback(init);

}
现在我的HTML代码如下所示

<script type="text/template" id="myPage">
    <div data-role="page">
        <div data-role="content">
            <div id="map3d" style="height: 400px; width: 600px;"></div>
        </div>
    </div>
</script>

myhtml.html

有办法解决这个问题吗


感谢您的帮助。

Earth API可与一起使用,它仅在Windows和Mac OSX上可用。抱歉,它在移动设备上不可用

如果您在Mac或Windows系统上进行测试,您应该能够使其正常工作。错误代码
ERR\u INVALID\u DIV
听起来好像找不到
map3d
DIV。我会放一个
调试器google.earth.createInstance()
之前的代码中的code>语句,然后在DOM检查器中查看
map3d
是否在DOM中。它应该是来自您的模板,如果该部分正在工作


但是,当您尝试在移动设备上加载站点时,这对您没有帮助,因为您的站点上没有可用的Earth插件。

您至少应该提供一些代码,为您的问题提供上下文,否则我们的线索甚至比您的少……我正在安装Earth插件的Windows系统上进行测试,但它不起作用:(好的,它当然可以在你的Windows系统上运行。但最终目标是在移动站点上使用它吗?那不行。当我在没有主干、下划线和jQM的单个静态html页面中尝试此操作时,它可以正常工作,但在由主干、下划线和jQM创建的动态应用程序中则不行。因此,对于我的动态ap应用程序我只能选择Google地图,但我喜欢Google Earth。你肯定可以让Earth API在你的Windows系统和主干系统上运行。但无论如何,它不会在你的移动设备上运行!我假设你使用的是jQuery mobile,你的目标是移动设备,不是吗?试着加载考试在你的手机浏览器上。