引用错误:$未定义 - 同时加载DZI xml文件-OpenSeaDragon

时间:2017-07-17 13:55:34

标签: openseadragon

以下是我用来加载和显示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 enter image description here

1 个答案:

答案 0 :(得分:0)

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

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