[英]Can OpenLayers change the image size only of multiples rather than intermediates (using the paramenter “size” of ol.source.Zoomify)?
我在以前通過Zoomify傳遞的圖像上使用Openlayers,因為它很大(2gb +)。 除了地圖,我還使用了一組多邊形,我附加了javascript函數。 我通過“sourceFeatures.addFeature(featurePolyXY)”函數使用它們; 圖像略小於用於創建多邊形的圖像。 看到多邊形是從具有多個值的大型xml文件生成的,其想法是放大地圖以使其遵循多邊形而不修改多邊形的坐標。
我以為我可以通過ol.source.Zoomify的“size”參數來改變地圖的大小。 雖然尺寸乘以2可以完美地工作,但是不計算每個其他中間數量總是提出標准尺寸。 看到這是我第一次使用openlayers,我確信解決方案在我的鼻子底下並且我沒有注意到它......這是我使用的代碼:
//these values are taken from the ImageProperties.xml file created by
//zoomify
var imgWidth = 33165;
var imgHeight = 33165;
var url = 'imageFolder/';
var crossOrigin = 'anonymous';
var imgCenter = [imgWidth / 2, - imgHeight / 2];
var proj = new ol.proj.Projection({
code: 'ZOOMIFY',
units: 'pixels',
extent: [0, 0, imgWidth, imgHeight]
});
var source = new ol.source.Zoomify({
url: url,
//i think here is the parameter i would like to change
size: [imgWidth, imgHeight],
crossOrigin: crossOrigin
});
//MAP
var map = new ol.Map({
layers: [
new ol.layer. Tile({
source: source
}),
layerFeatures
],
target: 'map',
view: new ol.View({
projection: proj,
center: imgCenter,
zoom: 2,
extent: [0, -imgHeight, imgWidth, 0]
})
});
關於參數:size:[imgWidth,imgHeight]
我嘗試輸入以下值大小:[33165,33165] =>根據原始大小顯示圖像:[66330,66330] =>正確圖像大小加倍:[imgWidth * 2,imgHeight * 2 ] =>正確地將圖像加倍尺寸:[imgWidth * 5,imgHeight * 5] =>正確圖像尺寸為* 5尺寸:[49000,49000] =>圖像根據原始尺寸顯示
控制台中沒有給出錯誤。
是否有可能放大圖像尺寸而不是倍數或倍數而是中間數,例如* 1.3?
我用另一種解決方案解決了這個問題,一個真正的解決方案。 我沒有改變地圖的大小,似乎只有它的兩倍/四倍等等,我按順序修改了多邊形的坐標:對於每個坐標值,我添加了一個乘數(以管理多邊形的大小)和兩個參數添加到垂直和水平坐標以管理位移。 例如來自:
var featurePoly0162 = new ol.Feature({
geometry: new ol.geom.Polygon([
[
[5636,-12903],
[5741,-12918],
[5753,-12988],
[5683,-12996],
[5633,-12949]
]
至:
var multi = 1.3;
var minX = 1000;
var minY = 500;
var featurePoly0162 = new ol.Feature({
geometry: new ol.geom.Polygon([
[
[5636*multi - minX,-12903*multi - minY],
[5741*multi - minX,-12918*multi - minY],
[5753*multi - minX,-12988*multi - minY],
[5683*multi - minX,-12996*multi - minY],
[5633*multi - minX,-12949*multi - minY]
]
通過這種方式,我不僅可以修改多邊形大小,還可以通過僅修改3個值在地圖上正確定位它們
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.