Skip to content

Commit

Permalink
Merge pull request #1125 from obueto/main
Browse files Browse the repository at this point in the history
change var to let or const
  • Loading branch information
TildaDares authored Oct 13, 2022
2 parents 42e7ca0 + 864f792 commit ecd8a21
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/edit/handles/EditHandle.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
L.EditHandle = L.Marker.extend({
initialize: function(overlay, corner, options) {
var latlng = overlay.getCorner(corner);
const latlng = overlay.getCorner(corner);

L.setOptions(this, options);

this._handled = overlay;
this._corner = corner;

var markerOptions = {
const markerOptions = {
draggable: true,
zIndexOffset: 10,
};
Expand Down Expand Up @@ -69,39 +69,40 @@ L.EditHandle = L.Marker.extend({

/* Takes two latlngs and calculates the scaling difference. */
_calculateScalingFactor: function(latlngA, latlngB) {
var overlay = this._handled;
var map = overlay._map;
const overlay = this._handled;
const map = overlay._map;

var centerPoint = map.latLngToLayerPoint(overlay.getCenter());
var formerPoint = map.latLngToLayerPoint(latlngA);
var newPoint = map.latLngToLayerPoint(latlngB);
var formerRadiusSquared = this._d2(centerPoint, formerPoint);
var newRadiusSquared = this._d2(centerPoint, newPoint);
const centerPoint = map.latLngToLayerPoint(overlay.getCenter());
const formerPoint = map.latLngToLayerPoint(latlngA);
const newPoint = map.latLngToLayerPoint(latlngB);
const formerRadiusSquared = this._d2(centerPoint, formerPoint);
const newRadiusSquared = this._d2(centerPoint, newPoint);

return Math.sqrt(newRadiusSquared / formerRadiusSquared);
},

/* Distance between two points in cartesian space, squared (distance formula). */
_d2: function(a, b) {
var dx = a.x - b.x;
var dy = a.y - b.y;
const dx = a.x - b.x;
const dy = a.y - b.y;

return Math.pow(dx, 2) + Math.pow(dy, 2);
},

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

var centerPoint = map.latLngToLayerPoint(overlay.getCenter());
var formerPoint = map.latLngToLayerPoint(latlngA);
var newPoint = map.latLngToLayerPoint(latlngB);

var initialAngle = (
const centerPoint = map.latLngToLayerPoint(overlay.getCenter());
const formerPoint = map.latLngToLayerPoint(latlngA);
const newPoint = map.latLngToLayerPoint(latlngB);

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

Expand Down

0 comments on commit ecd8a21

Please sign in to comment.