-1

I would like to show a pop-up while executing code in a control, but the pop-up only appears at the end of the execution (so when control is handed over to the map again?) In Firefox, this works as expected, but not in Chrome or Edge.

Code:

rg.regioPrint = function(opt_options) {
    this.options = options;
    var element = document.createElement('div');
    element.className = 'ol-unselectable ol-control rg-control-button';
    var button = document.createElement('button');
    element.appendChild(button);
    var this_ = this;
    button.onclick = function(e) {
        this_.doPrint();

    };
    ol.control.Control.call(this, { element: element });

};
ol_inherits(rg.regioPrint, ol.control.Control);

rg.regioPrint.prototype.doPrint = function() {
// options.busyControl is a control that is added to the map earlier
// with map.addControl(ctl = new ....) and is working perfectly fine when 
// called in other circumstances
    this.options.busyControl.show();     
    // do some lengthy stuff
};

The pop-up only appears at the end of the 'lengthy stuff'. However, in FF, it works! Can I achieve this in another, maybe better way for Chrome/Edge? Thanks for your help. Linde

Rob
  • 14,746
  • 28
  • 47
  • 65
lindea
  • 1
  • 3
  • If `busyControl`. is a custom control I presume `busyControl.show()` completes asynchronously. Try wrapping your `do some lengthy stuff` block inside a timeout, or waiting for a completion event from the `.show()` method if there is one. – Mike Oct 01 '21 at 18:48

1 Answers1

0

Mike's comment was the solution. I wrapped the 'lengthy stuff' in a timeout, and that solved it.

lindea
  • 1
  • 3