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..4fe242addd 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 }