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

improve rendering of turn-restriction boxes in narrow sidebars #8792

Merged
merged 1 commit into from
Nov 5, 2021
Merged
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: 7 additions & 5 deletions modules/ui/fields/restrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,24 @@ export function uiFieldRestrictions(field, context) {
extent._extend(_intersection.vertices[i].extent());
}

var padTop = 35; // reserve top space for hint text

// If this is a large intersection, adjust zoom to fit extent
if (_intersection.vertices.length > 1) {
var padding = 180; // in z22 pixels
var hPadding = Math.min(160, Math.max(110, d[0] * 0.4));
var vPadding = 160;
var tl = projection([extent[0][0], extent[1][1]]);
var br = projection([extent[1][0], extent[0][1]]);
var hFactor = (br[0] - tl[0]) / (d[0] - padding);
var vFactor = (br[1] - tl[1]) / (d[1] - padding);
var hFactor = (br[0] - tl[0]) / (d[0] - hPadding);
var vFactor = (br[1] - tl[1]) / (d[1] - vPadding - padTop);
var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
z = z - Math.max(hZoomDiff, vZoomDiff);
projection.scale(geoZoomToScale(z));
}

var padTop = 35; // reserve top space for hint text
var extentCenter = projection(extent.center());
extentCenter[1] = extentCenter[1] - padTop;
extentCenter[1] = extentCenter[1] - padTop / 2;

projection
.translate(geoVecSubtract(c, extentCenter))
Expand Down