From e61da9075db2e21e5c422331d017873c1eb9c249 Mon Sep 17 00:00:00 2001 From: Obueto Amakiri Date: Wed, 12 Oct 2022 00:31:37 +0100 Subject: [PATCH] change var to let or const --- src/edit/handles/EditHandle.js | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/edit/handles/EditHandle.js b/src/edit/handles/EditHandle.js index beabb9b26..1be7a18bd 100644 --- a/src/edit/handles/EditHandle.js +++ b/src/edit/handles/EditHandle.js @@ -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, }; @@ -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) );