[英]OpenLayers3 and high-resolution image (XYZ source)
I am trying to display a high-resolution image with OpenLayers3.我正在尝试使用 OpenLayers3 显示高分辨率图像。 The image (14336px x 12544px) has been tiled into 7 levels of 256px x 256px tiles.
图像 (14336px x 12544px) 已平铺为 7 级 256px x 256px 平铺。
I am trying to center the image and constrain the view to the image (no repetition).我试图将图像居中并将视图限制在图像上(不重复)。
I have looked to extent and projection but I did not manage to do what I wanted.我已经看过范围和投影,但我没有设法做我想做的事。
Here is my code:这是我的代码:
var width = 14336;
var height = 12544;
var level = 6;
var layer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'http://projects.local/.../{z}/{x}/{-y}.jpg'
}),
maxZoom: level
});
var view = new ol.View({
center: [0, 0],
zoom: 2,
maxZoom: level
});
var map = new ol.Map({
target: 'viewerContainer',
layers: [
layer,
],
view: view
});
Thanks for your help谢谢你的帮助
I found a solution thanks to this JSFiddle : http://jsfiddle.net/jonataswalker/6f233kLy/由于这个 JSFiddle,我找到了一个解决方案: http : //jsfiddle.net/jonataswalker/6f233kLy/
var width = 14336;
var height = 12544;
var level = 6;
var projection = new ol.proj.Projection({
code: 'pixels',
units: 'pixels',
extent: [0, 0, height, width]
});
var layer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'http://projects.local/prototype/data/item1/0/0/0/{z}/{x}/{-y}.jpg',
projection: projection
}),
maxZoom: level
});
var view = new ol.View({
center: [height/2, width/2],
zoom: 2,
maxZoom: level,
projection: projection
});
var map = new ol.Map({
target: 'viewerContainer',
layers: [
layer,
],
view: view
});
Hope it will help someone希望它会帮助某人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.