Google earth Google earth api:打开信息窗口时如何执行处理程序
我有一个Google earth插件,其中包含从kml文件加载的数据。 kml包含多边形,单击多边形时,将打开带有标记内容的阳台 如何将处理程序附加到阳台开口,该处理程序将创建自定义阳台并停止默认事件 我想应该是这样的,我只是不知道该听什么样的节目Google earth Google earth api:打开信息窗口时如何执行处理程序,google-earth,google-earth-plugin,Google Earth,Google Earth Plugin,我有一个Google earth插件,其中包含从kml文件加载的数据。 kml包含多边形,单击多边形时,将打开带有标记内容的阳台 如何将处理程序附加到阳台开口,该处理程序将创建自定义阳台并停止默认事件 我想应该是这样的,我只是不知道该听什么样的节目 google.earth.addEventListener("SOMETHING", 'click', function(event) { //Code to create custom baloon }); 您正在收听的是“点击”,您需要知道的是
google.earth.addEventListener("SOMETHING", 'click', function(event) {
//Code to create custom baloon
});
您正在收听的是“点击”,您需要知道的是要收听的点击来源 在这种情况下,我想你想听听任何多边形上的点击 为此,为所有单击设置通用侦听器,然后测试单击是否在多边形上,如果是,则取消默认行为并显示自定义气球 e、 g
google.earth.addEventListener(ge.getWindow(), 'click', function(e) {
if (e.getTarget().getType() == 'KmlPlacemark' &&
e.getTarget().getGeometry().getType() == 'KmlPolygon') {
// Prevent the default balloon from appearing.
e.preventDefault();
// create a custom balloon attached to the target
var balloon = ge.createHtmlStringBalloon('');
balloon.setFeature(e.getTarget());
balloon.setContentString("custom baloon!");
ge.setBalloon(balloon);
}
});