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

Ensures that zoom is always set to an integer value on Explore page #3677

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
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
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