0

以下是 iam 用于加载和显示 DZI xml 文件的代码片段。我收到参考错误:$ 未定义。

  var dziFilesUrl = '//DZI//dzc_output_files//';

// Change this to the contents of the .dzi file from your server. 
var dziData = '<?xml version="1.0" encoding="utf-8"?><Collection MaxLevel="8" TileSize="256" Format="jpg" NextItemId="1" xmlns="http://schemas.microsoft.com/deepzoom/2008"><Items><I Id="0" N="0" Source="dzc_output_images/worldmap.xml"><Size Width="5000" Height="3752" /><Viewport Width="1" X="-0" Y="-0" /></I></Items></Collection>';

// This converts the XML into a DZI tile source specification object that OpenSeadragon understands. 
var tileSourceFromData = function (data, filesUrl) {
    var $xml = $($.parseXML(data));
    var $image = $xml.find('Image');
    var $size = $xml.find('Size');

    var dzi = {
        Image: {
            xmlns: $image.attr('xmlns'),
            Url: filesUrl,
            Format: $image.attr('Format'),
            Overlap: $image.attr('Overlap'),
            TileSize: $image.attr('TileSize'),
            Size: {
                Height: $size.attr('Height'),
                Width: $size.attr('Width')
            }
        }
    };

    console.log(dzi);
    return dzi;
};

// This creates the actual viewer. 
var viewer = OpenSeadragon({
    id: 'openseadragon1',
    prefixUrl: '//DZI/',
    tileSources: tileSourceFromData(dziData, dziFilesUrl)
});

请让我知道我需要纠正什么。我正在使用最新的 OpenSeaDragon 版本 2.3.0在此处输入图像描述

4

1 回答 1

0

您需要包含 jQuery。更多讨论在这里:

https://github.com/openseadragon/openseadragon/issues/1255

于 2017-07-19T17:38:05.743 回答