dcd17
dcd17

Reputation: 21

Earth API- Hide placemark desciption balloon on double click?

I've got a number of placemarks displaying, each of which contains a description. On single click the desciption balloon displays which is fine, but on double click I want to flyto the coordinates and not display the balloon. Is there code to turn off the balloon/placemark display on doubleclick?

Upvotes: 1

Views: 660

Answers (1)

Fraser
Fraser

Reputation: 17094

The correct way to do this would be to cancel the default behaviour using the KmlEvent preventDefault() method. You would then usually implement your own behaviour for the event in the same handler if required.

Something like the following.

// listen for all double-click events 
google.earth.addEventListener(ge.getWindow(), 'dblclick', function(e) {

    // get the target of the event
    var target = e.getTarget();

    // we are only interested in placemarks, so...
    if(target.getType() == 'KmlPlacemark') {

      // stop the default behaviour.
      // for placemarks the default behaviour is the balloon popping up
      e.preventDefault();

      // Add any custom behaviour here
    }
});

Upvotes: 1

Related Questions