From 2c38e4eec4ddd33a212e5e8d061ee073a34c2f9c Mon Sep 17 00:00:00 2001 From: Mikey Saugstad Date: Tue, 1 Oct 2024 14:56:10 -0700 Subject: [PATCH 1/2] ensures that zoom is always set to an integer value --- .../SVLabel/src/SVLabel/keyboard/Keyboard.js | 12 +++++------ .../src/SVLabel/navigation/MapService.js | 20 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/public/javascripts/SVLabel/src/SVLabel/keyboard/Keyboard.js b/public/javascripts/SVLabel/src/SVLabel/keyboard/Keyboard.js index 6fa50c2f0f..3434beeef3 100644 --- a/public/javascripts/SVLabel/src/SVLabel/keyboard/Keyboard.js +++ b/public/javascripts/SVLabel/src/SVLabel/keyboard/Keyboard.js @@ -94,11 +94,11 @@ function Keyboard (svl, canvas, contextMenu, googleMap, ribbon, zoomControl) { /** * Change the heading of the current panorama point of view by a particular degree value. - * TODO Change the method name so it is more descriptive. + * * @param degree */ - this._rotatePov = function (degree){ - if (!svl.map.getStatus("disablePanning")){ + this._rotatePovByDegree = function(degree) { + if (!svl.map.getStatus("disablePanning")) { svl.contextMenu.hide(); // Panning hide label tag and delete icon. var labels = svl.labelContainer.getCanvasLabels(), @@ -116,7 +116,7 @@ function Keyboard (svl, canvas, contextMenu, googleMap, ribbon, zoomControl) { pitch: pitch, zoom: zoom }); - svl.panorama.setPov({heading: pov.heading, pitch: pov.pitch, zoom: pov.zoom}); + svl.map.setPov({heading: pov.heading, pitch: pov.pitch, zoom: pov.zoom}); } }; @@ -157,10 +157,10 @@ function Keyboard (svl, canvas, contextMenu, googleMap, ribbon, zoomControl) { } else { switch (e.keyCode) { case 37: // "ArrowLeft" - self._rotatePov(-2); + self._rotatePovByDegree(-2); break; case 39: // "ArrowRight" - self._rotatePov(2); + self._rotatePovByDegree(2); break; } if (!status.disableMovement) { diff --git a/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js b/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js index 30c50e24a8..e8f4bcfe86 100644 --- a/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js +++ b/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js @@ -458,12 +458,13 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { if ("panorama" in svl) { var pov = svl.panorama.getPov(); - // Pov can be less than 0. So adjust it. + // Make sure that zoom is set to an integer. + // pov.zoom = Math.round(pov.zoom); + + // Adjust heading to be between 0 and 360 instead of -180 to 180. while (pov.heading < 0) { pov.heading += 360; } - - // Pov can be more than 360. Adjust it. while (pov.heading > 360) { pov.heading -= 360; } @@ -1212,7 +1213,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { */ function updatePov(dx, dy) { if (svl.panorama) { - var pov = svl.panorama.getPov(); + var pov = getPov(); var alpha = 0.25; pov.heading -= alpha * dx; pov.pitch += alpha * dy; @@ -1251,9 +1252,12 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { */ function setPov(pov, durationMs, callback) { if (('panorama' in svl) && svl.panorama) { - var currentPov = svl.panorama.getPov(); + var currentPov = getPov(); var interval; + // Make sure that zoom is set to an integer value. + if (pov.zoom) pov.zoom = Math.round(pov.zoom); + // Pov restriction. restrictViewPort(pov); @@ -1445,7 +1449,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { } function setZoom(zoomLevel) { - svl.panorama.setZoom(zoomLevel); + svl.panorama.setZoom(Math.round(zoomLevel)); } // Set a flag that triggers the POV being reset into the route direction upon the position changing. @@ -1455,9 +1459,9 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { // Set the POV in the same direction as the route. function setPovToRouteDirection(durationMs) { - var pov = svl.panorama.getPov(); + var pov = getPov(); var newPov = { - heading: parseInt(svl.compass.getTargetAngle() + 360, 10) % 360, + heading: Math.round(svl.compass.getTargetAngle() + 360) % 360, pitch: pov.pitch, zoom: pov.zoom } From f7658a403bad60fb3f75ed104d388404bb5e6f3e Mon Sep 17 00:00:00 2001 From: Mikey Saugstad Date: Tue, 1 Oct 2024 14:59:09 -0700 Subject: [PATCH 2/2] uncomments code that needed to be included --- public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js b/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js index e8f4bcfe86..4fe242addd 100644 --- a/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js +++ b/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js @@ -459,7 +459,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { var pov = svl.panorama.getPov(); // Make sure that zoom is set to an integer. - // pov.zoom = Math.round(pov.zoom); + pov.zoom = Math.round(pov.zoom); // Adjust heading to be between 0 and 360 instead of -180 to 180. while (pov.heading < 0) {