我目前正在尝试在浏览器的调试窗口中设置断点。每当发生点击事件时,断点都会导致 Google 地球插件崩溃。
为了避免崩溃,我是否缺少一种方法?我只想轻松访问在断点上尝试不同的 kml 属性。希望我错过了一个类似于警告框超时的功能,以防止单击 GE 时框崩溃。
尝试在 Chrome 和 IE 中调试。
这是基本的 Google 地球代码。
google.earth.createInstance(this, initCB, failureCB, earthArgs);
this
是 map div,earthArgs
保存数据库位置
......................
点击事件代码:
function initCB(instance) {
gep = instance;
gep.getWindow().setVisibility(true);
google.earth.addEventListener(gep.getGlobe(), 'click', function(event) {
//set breakpoint here
});
}
代码可以正常工作并加载 GE,问题是单击 GE 时断点卡住。
最佳答案
这可能是因为您正在为事件处理程序使用匿名委托(delegate)。要设置断点,请尝试创建命名函数并将其传递给 addEventListener 方法。
// handle click events on the globe
// e is the KmlMouseEvent object
var globeClickHandler = function(e) {
// set breakpoint here
};
// in initCB
google.earth.addEventListener(gep.getGlobe(), 'click', globeClickHandler);
关于javascript - Google 地球插件点击时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10037110/