我尝试从 zoomify 查看器切换到 OpenLayers。但是,我没有成功加载 zoomify 图像。
这是网址: https ://get.microvisioneer.com/scans/oltest2_stackoverflow.html
它成功地从 TileGroup18 加载了一个图块 (7-57-24.jpg),但页面上没有显示任何内容。
我究竟做错了什么?
我尝试从 zoomify 查看器切换到 OpenLayers。但是,我没有成功加载 zoomify 图像。
这是网址: https ://get.microvisioneer.com/scans/oltest2_stackoverflow.html
它成功地从 TileGroup18 加载了一个图块 (7-57-24.jpg),但页面上没有显示任何内容。
我究竟做错了什么?
您需要设置并打开视图
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css" type="text/css">
<style>
.map {
height: 400px;
width: 400px;
}
</style>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js"></script>
<title>OpenLayers example</title>
</head>
<body>
<h2>My Map</h2>
<div id="map" class="map"></div>
<script type="text/javascript">
var imgWidth = 29184;
var imgHeight = 12288;
var zoomifyUrl = 'https://get.microvisioneer.com/scans/US20-589.svs.zoomify/';
var source = new ol.source.Zoomify({
url: zoomifyUrl,
size: [imgWidth, imgHeight],
zDirection: -1 // Ensure we get a tile with the screen resolution or higher
});
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: source
})
],
view: new ol.View({
// adjust zoom levels to those provided by the source
resolutions: source.getTileGrid().getResolutions(),
// constrain the center: center cannot be set outside this extent
extent: source.getTileGrid().getExtent(),
constrainOnlyCenter: true
})
});
map.getView().fit(source.getTileGrid().getExtent());
</script>
</body>
</html>