尽我所能,我似乎无法从我的公共托管网页上的 google-earth-plugin 实例访问 kml 文件。使用我可以找到的所有谷歌开发人员帮助并尝试 Fetchkml 以及 kmlNetworkLink 均未成功,我尝试以一次一步的方式解决问题并达到以下僵局:
当我指向 code.google.com 上的 kml 源时,使用以下 javascript 代码有效:
google.load("earth", "1");
var ge;
function init() {
google.earth.createInstance('mapthreedee', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
var link = ge.createLink('');
var href = 'http://code.google.com/apis/earth/documentation/samples/kml_example.kml';
link.setHref(href);
var networkLink = ge.createNetworkLink('');
networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView
ge.getFeatures().appendChild(networkLink);
}
function failureCB(errorCode) {
alert("failure");
}
google.setOnLoadCallback(init);
</script>
google-earth 插件缩小到旧金山。但是,如果我使用 google Chrome 下载相同的 kml_example.kml 源文件,请将未修改的 kml 文件放入我的 google docs 文档空间,获取它的相关 id 地址并将此地址粘贴到我网页上的 javascript 代码中(没有对代码的其他更改),如下所示:
google.load("earth", "1");
var ge;
function init() {
google.earth.createInstance('mapthreedee', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
var link = ge.createLink('');
var href = 'https://docs.google.com/open?id=0B3kCsTNlhwBaM2I5YTk0ZjEtOGVlNS00MGU4LTk5MTgtYTUyYzQ2Mzc2Mzhl';
link.setHref(href);
var networkLink = ge.createNetworkLink('');
networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView
ge.getFeatures().appendChild(networkLink);
}
function failureCB(errorCode) {
alert("failure");
}
google.setOnLoadCallback(init);
</script></code>
尽管 google-earth-plugin 仍然可以正确加载,但页面加载时不会访问 kml。我只会走这些极端,因为我在 google docs 中有一个 kmz 位置(在挪威),我可以通过我的 PC 上的 google Earth 客户端中的 Network Link 很好地访问它,但不会出现在 google-earth-plugin 中我尝试使用与上述相同的代码来访问它。
谁能指出我正确的方向?
这些网页位于http://geoffreychaucernm.co.uk/offlineTEST_SITE_ghp/googlemaps/googleEarth_3.html和http://geoffreychaucernm.co.uk/offlineTEST_SITE_ghp/googlemaps/googleEarth_4.html
该站点托管在 1and1 Microsoft Web 服务器上。