cesium-addons icon indicating copy to clipboard operation
cesium-addons copied to clipboard

infowindow doesn't close!

Open stutteringp0et opened this issue 10 years ago • 2 comments

setVisible(false) doesn't work because _computeVisible runs constantly and resets visibility to true immediately.

I changed the close onclick function to use hide(), and now set a _closed property which _computeVisible and setVisible check before they change visibility.

stutteringp0et avatar Sep 12 '14 03:09 stutteringp0et

Hi, I got the same problem. can you add code example, if you still have it :)

azulay7 avatar Mar 06 '17 14:03 azulay7

I've got the similar problem! But In my case I wanted the initial state of the info windows to be closed and I need to show them only on click on the pin. So I changed initial state of the window to closed and not visible. Here is the part of the code that I've changed.

...
this._visible = false;
this._closed = true; // new flag for close state
this._close.onclick = function() {
  _self.setClosed(true); // Now we are calling close method
}
this.setClosed(false); // To open a window now we need to change closed value

_.prototype.setVisible = function(visible) {
  this._visible = visible;
  this._div.style.display = visible ? 'block' : 'none';
}
_.prototype.setClosed = function(visible) {
  this._closed = visible; // changing the flag of closed
  this.setVisible(!visible); // same as before
}
...
// at the end of this method we are adding new conditional
_.prototype.computeVisible = function(){
  ...
  if(isOccluded && !this._closed){
    this.setVisible(false);
  }else if (!this._closed) {
    this.setVisible(true);
  }
}

After This changes use setClosed instead of setVisible method to manipulate the infoWindows visibilty

jdakowicz avatar Apr 20 '17 13:04 jdakowicz