Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change var to let or const #1125

Merged
merged 3 commits into from
Oct 13, 2022
Merged
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
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