【发布时间】:2014-08-06 00:34:56
【问题描述】:
我正在 Windows 7 上使用 google earth 插件开发一个 Web 应用程序。 我注意到当我将地球对象打印到 chrome 控制台时(用于 deuggin 和代码检查) 对象是空的(看起来像“Object {}”)。经过大量谷歌搜索后我找不到原因..有人可以帮助我吗? 谢谢!
更新:这是我正在运行的代码。我需要帮助,没有调试就无法工作..
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div id="map3d" style="height: 100%; width: 100%;"></div>
<!--nothing inside this -->
@RenderBody()
@Scripts.Render("~/bundles/jquery")
<script src="https://www.google.com/jsapi"></script>
<script>
var ge;
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
};
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
console.log(JSON.stringify(ge, null, 4));
console.log('0%', ge);
console.log(ge.parseKml);
};
function failureCB(errorCode) {
throw ("Failed to load earth plugin. Error code = " + errorCode);
};
google.load("earth", "1", { "other_params": "sensor={false}" });
google.setOnLoadCallback(init);
</script>
</body>
</html>
一切正常,我可以看到地图,但控制台中的结果:
{}
0% Object {}
function parseKml() { [native code] }
【问题讨论】:
-
如果控制台返回您
"Object {}",则可能它是一个对象。只是它可能以 "String" 的形式返回(所以你无法探索它)或它可能真的是一个 Empty 对象......除非您展示/解释更多内容,否则我认为没有人能在这件事上为您提供帮助。 -
即使我创建了一个硬编码的地标并将其写入控制台,它看起来还是空的,我想有人可能遇到过这个问题。
-
附注对象代码是
%O而不是0%(它是对象的O,而不是零0) - 也是百分比优先。
标签: javascript google-chrome google-earth google-earth-plugin