Search code examples
node.jsopenseadragon

Example of using require() to use OpenSeadragon


I'm an OpenSeadragon newb, and I would prefer to use npm to install it rather than depend on a downloaded version.

I'm having a little trouble with the syntax, and (so far) no amount of Googling has come up with an example. I assume it would look something like this:

var viewer = require('openseadragon');

But then, in particular, how would the prefixURL option be set?

Are there examples out there I haven't found?


Solution

  • Actually, the current version of OpenSeadragon (2.1.0) published on npm does not support require yet. It will be available with the next release and should be used like this:

    var openseadragon = require('openseadragon');
    var viewer = openseadragon({
      prefixUrl: 'url',
      ...
    });
    

    In the mean time, you will have to include OSD manually:

    <script src="node_modules/openseadragon/build/openseadragon/openseadragon.js"></script>
    

    And create an instance like this:

    var viewer = OpenSeadragon({
      prefixUrl: 'url',
      ...
    });