Skip to content

Commit

Permalink
Merge pull request #3677 from ProjectSidewalk/2478-fix-zoom-level
Browse files Browse the repository at this point in the history
Ensures that zoom is always set to an integer value on Explore page
  • Loading branch information
misaugstad authored Oct 1, 2024
2 parents d315bc5 + f7658a4 commit e591c45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 6 additions & 6 deletions public/javascripts/SVLabel/src/SVLabel/keyboard/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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});
}
};

Expand Down Expand Up @@ -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) {
Expand Down
20 changes: 12 additions & 8 deletions public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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.
Expand All @@ -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
}
Expand Down

0 comments on commit e591c45

Please sign in to comment.