Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ L.RotateHandle = L.EditHandle.extend({
overlay.editing._rotateBy(angle);
overlay.editing._scaleBy(scale);

/* checks whether the "edgeMinWidth" property is set and tracks the minimum edge length */
/*
checks whether the "edgeMinWidth" property is set and tracks the minimum edge length;
this enables preventing scaling to zero, but we might also add an overall scale limit
*/
if (this._handled.options.hasOwnProperty('edgeMinWidth')){
var edgeMinWidth = this._handled.options.edgeMinWidth,
w = L.latLng(overlay._corners[0]).distanceTo(overlay._corners[1]),
Expand Down Expand Up @@ -695,7 +698,9 @@ L.DistortableImage.Edit = L.Handler.extend({
76: '_toggleLock', // l
79: '_toggleOutline', // o
82: '_toggleRotateDistort', // r
84: '_toggleTransparency', // t
84: '_toggleTransparency', // t
46: "_removeOverlay", // delete windows / delete + fn mac
8: "_removeOverlay" // backspace windows / delete mac
}
},

Expand Down Expand Up @@ -776,7 +781,12 @@ L.DistortableImage.Edit = L.Handler.extend({
L.DomEvent.off(window, 'keydown', this._onKeyDown, this);

overlay.fire('deselect');
},
},

confirmDelete: function () {
return window.confirm("Are you sure you want to delete?");
},


_rotateBy: function(angle) {
var overlay = this._overlay,
Expand Down Expand Up @@ -934,42 +944,53 @@ L.DistortableImage.Edit = L.Handler.extend({
}

L.DomEvent.stopPropagation(event);
},

},

_removeOverlay: function () {
var overlay = this._overlay;
if (this._mode !== "lock") {
var choice = this.confirmDelete();
if (choice) {
overlay._map.removeLayer(overlay);
overlay.fire('delete');
this.disable();
}
}
},

// Based on https://github.com/publiclab/mapknitter/blob/8d94132c81b3040ae0d0b4627e685ff75275b416/app/assets/javascripts/mapknitter/Map.js#L47-L82
_toggleExport: function (){
var map = this._overlay._map;
var map = this._overlay._map;
var overlay = this._overlay;

// make a new image
var downloadable = new Image();

downloadable.id = downloadable.id || "tempId12345";
$('body').append(downloadable);

downloadable.onload = function onLoadDownloadableImage() {

var height = downloadable.height,
width = downloadable.width,
nw = map.latLngToLayerPoint(overlay._corners[0]),
ne = map.latLngToLayerPoint(overlay._corners[1]),
sw = map.latLngToLayerPoint(overlay._corners[2]),
se = map.latLngToLayerPoint(overlay._corners[3]);
// I think this is to move the image to the upper left corner,

// I think this is to move the image to the upper left corner,
// jywarren: i think we may need these or the image goes off the edge of the canvas
// jywarren: but these seem to break the distortion math...
// jywarren: but these seem to break the distortion math...

// jywarren: i think it should be rejiggered so it
// jywarren: i think it should be rejiggered so it
// finds the most negative values of x and y and then
// adds those to all coordinates

//nw.x -= nw.x;
//ne.x -= nw.x;
//se.x -= nw.x;
//sw.x -= nw.x;

//nw.y -= nw.y;
//ne.y -= nw.y;
//se.y -= nw.y;
Expand All @@ -979,7 +1000,7 @@ L.DistortableImage.Edit = L.Handler.extend({
downloadable.onload = function() {
$(downloadable).remove();
};

if (window && window.hasOwnProperty('warpWebGl')) {
warpWebGl(
downloadable.id,
Expand Down
Loading