Public Lab Research note

GSoC Update- New class additions in ImageDistortion (L.DistortableImage and L.ImageMarker)

by anishshah101 | July 28, 2014 07:36 28 Jul 07:36 | #10985 | #10985

The working demo of the latest version of ImageDistortion can be viewed here:

You can click and drag any control point to distort the image. The code can be viewed here:


On Zooming, the image behaves weirdly, that still remains to be corrected.

Important changes/additions in plugin:

1) Extended the L.ImageOverlay class to L.DistortableImage: . This was done to add the DOM attribute id to make every image unique.

2) Extended the L.Marker class to L.ImageMarker: .This was done to make the image control points draggable and clickable by default. Also, the riseonhover property provides it with a high z-index value so that it remains on top of everything else for selection. Any custom image can be used as an image marker.

Things which still remain to be done:

1) Correcting the zoom event by preserving the last state of the distorted image.


Clever. Not sure where you intend to take this experiment, but grab-n-drag the photo and having a semi-transparent mode (to see the map below the photo) would be a nice effect for manipulating the corners to find a match. Cheers, Dave

Reply to this comment...

Looking great! If you add basic image dragging, you have most of the base functions done! I agree with Dave too, the transparency, outline mode, and "rotate/scale" modes are next. Great work!

I did see a weird bug after 3-4 distorts:


Reply to this comment...

Excellent. And I see that it works fairly well in iOS.

Reply to this comment...

I look forward to seeing this work with scaling, but it is coming along very nicely.

I agree that there should be a way to drag the whole image. In order to move the image right now, one would have to move each of the four corners to it's final location. It would be far easier to drag the image itself to the final location, and then adjust the corners.

Since the example site is client-side only and the HTML, JS, CSS are on Github, this could be hosted directly out of Github Pages:

Here is an example of github pages. Code repo:, Github page:

The source code for index.html in the repo ( does not look like the source code for the index.html that you are hosting ( Have you commit and pushed all your changes?

Is this a question? Click here to post it to the Questions page.

Reply to this comment...

I was unaware of the bug before Jeff mentioned but it is occurring each time after a few distorts. I am not sure why that is happening because the same piece of code is running each time. Will try to sort that out.

Will work on transparency, scaling and image dragging once the zoom event and the bug gets rectified.

@btbonval - thanks for pointing out github pages. Wanted to know if it has any advantage over usual VPSs? Btw the source code for index.html on the server corresponds to the file 1.html on the github repo: . The repo is slightly unorganized, will sort that out as well.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...

Login to comment.