Skip to content

Commit

Permalink
added _calculateAngle to L.EditHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaShD committed May 20, 2019
1 parent d91b2d7 commit e65a5a3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 42 deletions.
16 changes: 15 additions & 1 deletion src/edit/EditHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,19 @@ L.EditHandle = L.Marker.extend({

this._handled._map.off("zoomend", this.updateHandle, this);
this._handled.off("update", this.updateHandle, this);
}
},
/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,

centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),

initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);

return newAngle - initialAngle;
}

});
14 changes: 0 additions & 14 deletions src/edit/RotateHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ L.RotateHandle = L.EditHandle.extend({
this.setLatLng(this._handled._corners[this._corner]);
},

/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,

centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),

initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);

return newAngle - initialAngle;
},

/* Takes two latlngs and calculates the scaling difference. */
_calculateScalingFactor: function(latlngA, latlngB) {
var map = this._handled._map,
Expand Down
14 changes: 0 additions & 14 deletions src/edit/RotateScaleHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ L.RotateScaleHandle = L.EditHandle.extend({
this.setLatLng(this._handled._corners[this._corner]);
},

/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,

centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),

initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);

return newAngle - initialAngle;
},

/* Takes two latlngs and calculates the scaling difference. */
_calculateScalingFactor: function(latlngA, latlngB) {
var map = this._handled._map,
Expand Down
13 changes: 0 additions & 13 deletions src/edit/ScaleHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ L.ScaleHandle = L.EditHandle.extend({
this.setLatLng(this._handled._corners[this._corner]);
},

/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,

centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),

initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);

return newAngle - initialAngle;
},

/* Takes two latlngs and calculates the scaling difference. */
_calculateScalingFactor: function(latlngA, latlngB) {
Expand Down

0 comments on commit e65a5a3

Please sign in to comment.