annotorious / annotorious-v1

Project has moved to http://github.com/annotorious/annotorious
https://annotorious.com
MIT License
592 stars 142 forks source link

OpenLayer Image stretched using annotorious #218

Open Shubham-Tops opened 4 years ago

Shubham-Tops commented 4 years ago

Hi,

I am using annotorious plugin in my project. I am using it with openLayer and in that ImageLayer. The issue which I am facing is when I initialize plugin, image get stretched. Check my code below. init_annotorious = function() { var img_src = $('#map').attr('attr-img-src');

  $('#map').removeClass('annotorious_map');

  if(typeof img_src != "undefined" && img_src != "")
  {
    $('#map').addClass('annotorious_map');

    $('.annotate-action-btn').show();

    anno.destroy();

    $('#map').html("");

    map = new OpenLayers.Map('map', { numZoomLevels: 4 });

    var proof = new OpenLayers.Layer.Image('proofimg', img_src, new OpenLayers.Bounds(-600, -500, 250, 600), new OpenLayers.Size(375, 750));

    proof.setIsBaseLayer(true);

    proof.display(true);

    map.addLayer(proof);

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

    anno.makeAnnotatable(map);

    add_floor_coordinates();
  }
}

Note : I am not allowed to change image dimensions at any cost. Image can be of any height width.

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(-600, -500, 250, 600), new OpenLayers.Size(375, 750));