我如何将 google earth API 与bone.js+jquery mobile 结合使用?
我使用backbone.js、underscore.js 和jQuery Mobile 创建了应用程序。对于谷歌地球 API,我正在使用https://developers.google.com/earth/documentation/#using_the_google_earth_api中列出的示例代码
我的模板渲染和所有其他页面工作正常但是当我在一个标签中加载谷歌地球 API 时,它没有加载并且在 js 控制台中我收到消息:“ERR_INVALID_DIV”。
Google.earth 模块从不回调 initCallback,它总是在调用 google.earth.createInstance 时调用 failureCallback。
我解释了我的应用程序的一些示例代码,因此基于此,您可能会获得我的代码结构,它可以帮助您解决我的问题。
我的js代码如下,
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);
}
现在我的主干代码如下,
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>
我的html.html
有没有什么办法解决这一问题?
任何帮助表示赞赏。