Skip to content

Add image rotation #44

@mrAceT

Description

@mrAceT

Hello,

I've started using (and updating) imgViewer2

And it works great for my needs.

I would really like to add a button to rotate the image in increments of 90 degrees, but I can't get it to work..

I've found this little snippet of code, and I'm sure it would help me, but my experience in this area is limited. Is there anyone here that could help me out?

PS: if so, I'll promise to share my improvements :)

L.rotateImageLayer = function(url, bounds, options) {
            return new L.RotateImageLayer(url, bounds, options);
          };
// A quick extension to allow image layer rotation.
          L.rotateImageLayer = L.ImageOverlay.extend({
            options: {rotation: 90},
            _animateZoom: function(e){
              L.ImageOverlay.prototype._animateZoom.call(this, e);
              var img = this._image;
              img.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.rotation + 'deg)';
            },
            _reset: function(){
              L.ImageOverlay.prototype._reset.call(this);
              var img = this._image;
              img.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.rotation + 'deg)';
            }
          });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions