0

I'm using Openlayers on an image previously passed by Zoomify because it's huge (2gb +). In addition to the map, I use a set of polygons to which I have attached javascript functions. I use them via the "sourceFeatures.addFeature (featurePolyXY)" function; The image is slightly smaller than that used for creating polygons. Seeing that the polygons are generated from a large xml file with numerous values, the idea is to enlarge the map to make it adhere to the polygons and not modify the coordinates of the polygons.

I thought i could change the size of the map through the "size" parameter of ol.source.Zoomify. while the dimension multiplied by 2 works perfectly, every other intermediate quantity is not calculated always proposing the standard size. Seeing that it is the first time I use openlayers, I am convinced that the solution is under my nose and that I do not notice it ... here is the code I use:

//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]
  })
});

About the parameter: size: [imgWidth, imgHeight]

I tried to enter the following values size: [33165, 33165] => the image is displayed according to the original size size: [66330, 66330] => correctly the image doubles the size size: [imgWidth*2, imgHeight*2] => correctly the image doubles the size size: [imgWidth*5, imgHeight*5] => correctly the image size is *5 size: [49000, 49000] => the image is worngly displayed according the original size

No errors are given in the console.

Is there the possibility to enlarge the image size not of the double or of multiples but of a middle way, for example * 1.3?

1 Answer 1

0

I solved the problem with an alternative solution, a real warkaround. Instead of changing the size of the map which seems to be possible only double it / quadruple it and so on, I modified sequentially the coordinates of the polygons: for each coordinate value I added a multiplier (to manage the size of the polygon) and two parameters to add to the vertical and horizontal coordinates to manage the displacement. So for example from:

var featurePoly0162 = new ol.Feature({
geometry: new ol.geom.Polygon([
[
[5636,-12903],
[5741,-12918],
[5753,-12988],
[5683,-12996],
[5633,-12949]
]

to:

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]
]

in this way not only i can modify the polygons size but also position them correctly on the map by modifying only 3 values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.