openlayers/ol2

Image getting stretched in Image layer

Shubham-Tops opened this issue · 0 comments

HI,

I am not sure is this a bug or not, but I am facing an image get stretched issue. Might I am missing something. Below is my code for clear understanding.

   var img_src = "dynamic image url";
   map = new OpenLayers.Map('map', { numZoomLevels: 4 });
  
  var proof = new OpenLayers.Layer.Image(
                    'proofimg', 
                    img_src, 
                    new OpenLayers.Bounds(-375, -750, 375, 750), 
                    new OpenLayers.Size(375, 750)
                  );

    proof.setIsBaseLayer(true);

    proof.display(true);

    map.addLayer(proof);

    map.setCenter(new OpenLayers.LonLat(0,0),0,false,true);

Note : I am not allowed to change image dimensions at any cost. Image can be of any height width and this img_src will be dynamic(it will be uploaded by end user), coming straight from database. Any new way of initialization is welcomed. I mean using any property of ol2

I need a way where this height, width could be set automatically.

Below is the line where I think something could be done.
var proof = new OpenLayers.Layer.Image(
'proofimg',
img_src,
new OpenLayers.Bounds(-375, -750, 375, 750),
new OpenLayers.Size(375, 750)
);