0
以下代碼有效。我可以加載一個頁面並讓地球顯示。TypeScript和Google地球
我想顯示導航控件。如果我在initCB中取消註釋行,它就可以工作。
我認爲代碼有一個範圍問題,需要微調才能正常工作。
謝謝。
declare var google;
class GoogleEarth {
static pluginInstance;
static display() {
google.load("earth", "1");
google.setOnLoadCallback(init);
}
static ShowNavigation() {
this.pluginInstance.getNavigationControl().setVisibility(this.pluginInstance.VISIBILITY_AUTO);
}
private static init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
private static initCB(instance) {
this.pluginInstance = instance;
this.pluginInstance.getWindow().setVisibility(true);
//this.pluginInstance.getNavigationControl().setVisibility(this.pluginInstance.VISIBILITY_AUTO);
}
private static failureCB(errorCode) {}
}
GoogleEarth.display();
GoogleEarth.ShowNavigation();
我看你要去哪裏showNavigation與pluginInstance有同樣的問題。它仍然是由它獲取initCB甚至當我通過真實的顯示() 下面是HTML,以獲得時間假這項工作
@DougFinke我已經更新了我的答案。 – Fenton
謝謝你的幫助Sohnee。當我做複製和粘貼時,這個例子在getWindow上得到一個錯誤。當我有空時,我會看看我是否造成問題。我是JavaScript新手,所以似乎可以使用TypeScript,OOP和狀態完全對象,但通過瀏覽器以及與Google Earth等庫的交互,我們仍在等待「事件」發生,以便完全實現對象?然後我們可以對它們執行操作。 –