These are chat archives for openseadragon/openseadragon

2nd
Feb 2018
Tammy DiPrima
@tdiprima
Feb 02 2018 19:30

Hi @iangilman, the example you gave works...

var viewer = OpenSeadragon({
  tileSources: [
    backgroundLayerTileSource // no transparency
  ],
  ...
});

Now let's say I have an event which triggers a layer to be added. That means I can't add the tileSources from the beginning. So I added this...

viewer.tileSources.push(overlayTileSource1); // with transparency

Adding to the array like that doesn't cause the custom tiles to render to the screen. Do I need to call a "redraw" function or something? I didn't think I had to...?

Ian Gilman
@iangilman
Feb 02 2018 19:34
@tdiprima If you want to add images after the fact, you have to use addTiledImage, for example:
viewer.addTiledImage({tileSource: overlayTileSource1});
Tammy DiPrima
@tdiprima
Feb 02 2018 19:35
@iangilman That’s what I was doing from the beginning. But then I got the error “attempting to draw tile … when it’s not cached”. OK… I’m probably just doing something wrong. Thanks for help clearing things up. :)
Ian Gilman
@iangilman
Feb 02 2018 19:42
Well, that's what you should be doing... I'm not sure where that error is coming from. If you want to share a code pen or something I can take a look.
Tammy DiPrima
@tdiprima
Feb 02 2018 20:13

I learned something about that error...
I made a small example fail on purpose, and it failed beautifully.

addOverlays1(thing1);
addOverlays1(thing2);
addOverlays1(thing2); // OOPS ON PURPOSE.

That produces the error

[Tile.drawCanvas] attempting to draw tile 6/303_119 when it's not cached

So if you try to draw it twice, it fails! That's good news. :)

Ian Gilman
@iangilman
Feb 02 2018 21:01
@tdiprima Interesting... so maybe we have a bug with how we handle duplicate tile sources? We definitely want to be able to support that...
Would you mind filing an issue for that?
Tammy DiPrima
@tdiprima
Feb 02 2018 21:03
@iangilman Sure. Because too, if you’re not careful, items will keep getting added to viewer.world, and the itemCount goes up… probably want to keep a distinct array of stuff so that performance stays pretty good.
Ian Gilman
@iangilman
Feb 02 2018 21:04
Yeah, you definitely need to remove images if you don't want them anymore.
...and thanks!
Tammy DiPrima
@tdiprima
Feb 02 2018 21:04
np! thank you!