Skip to content

Image getting stretched in Image layer #1533

@Shubham-Tops

Description

@Shubham-Tops

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)
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions