开发者

HTMLDivBalloon - Google Earth API Question

I have a problem using balloons in google earth. I have some markers on the map, upon clicking on a marker, a balloon popup is shown containing some data, now when I click on the close button of that balloon, the click event of the map is also triggered which is really annoying as I have a handler attached with the map click event.

I tried everything including using event.stopPropagation() in the 'beforeclose' event of the htmlDivBalloon but still nothing works. Anyone ha开发者_如何学JAVAs an idea about that ?

Best Regards John Tadros


The chances are you are not handling the default event or you are not screening which objects the event acts in the handler "attached with the map click event". You haven't shown any code, so it is hard to say exactly how to fix it - but a generic way to handle this is as follows.

// listen for mousedown on the window 
google.earth.addEventListener(ge.getWindow(), 'mousedown', function(e) {
  var type = e.getTarget().getType();
  if (type == 'KmlPlacemark') {
    // prevent the default event for placemarks, stop Propagation
    e.preventDefault();
    e.stopPropagation();
  } else if(type == 'GEGlobe') {
    // do something with the globe...
  }
  // etc...
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜