Drive mode: the Trip menu beside the map instead of over it (like Android Auto's side panel): the map narrower and keeping its buttons, its center (follow, the crosshair, the overview) in what's seen — the car was hidden under the panel before
This commit is contained in:
1 parent
3325ff5d17
commit
7901d75ff1
3 files changed
+18
-23
No files matched your search
@@ -3595,15 +3595,12 @@ html.follow-3d .maplibregl-ctrl-overview-map { display: none; }
|
||||
:root[data-palette] .drive-bar button,
|
||||
:root[data-palette] .drive-bar__recenter { box-shadow: 0 0 0 1px var(--ui-line), 0 2px 8px rgb(0 0 0 / 0.35); }
|
||||
|
||||
/* The driving mode's Trip menu (driving.js): big rows, big actions, on the
|
||||
right; the crosshair in the middle of what's left of the map. */
|
||||
/* The driving mode's Trip menu (driving.js): big rows, big actions, beside
|
||||
the map on the right (the map narrower, its buttons kept, like Android
|
||||
Auto); the crosshair in the middle of the map. */
|
||||
.drive-trip {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
bottom: 12px;
|
||||
z-index: 5;
|
||||
width: min(540px, 48%);
|
||||
flex: 0 0 min(540px, 45%);
|
||||
margin: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: 14px;
|
||||
@@ -3656,6 +3653,8 @@ html.follow-3d .maplibregl-ctrl-overview-map { display: none; }
|
||||
.drive-bar button.active { background: var(--accent); }
|
||||
.drive-crosshair {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
z-index: 4;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
|
||||
+8
-15
@@ -79,15 +79,6 @@ export function setupDriving(map, nightButton, routePanel) {
|
||||
const crosshair = document.createElement("div");
|
||||
crosshair.className = "drive-crosshair";
|
||||
crosshair.hidden = true;
|
||||
const visibleCenter = () => {
|
||||
const { clientWidth: w, clientHeight: h } = map.getContainer();
|
||||
return [(w - tripPanel.offsetWidth) / 2, h / 2];
|
||||
};
|
||||
const placeCrosshair = () => {
|
||||
const [x, y] = visibleCenter();
|
||||
crosshair.style.left = `${x}px`;
|
||||
crosshair.style.top = `${y}px`;
|
||||
};
|
||||
// Search: saved points (the library) and places (the offline POI
|
||||
// database), nearest the crosshair first; a result's name shows it, + adds
|
||||
// it as a stop. While there's a query the list shows results, not stops.
|
||||
@@ -103,7 +94,7 @@ export function setupDriving(map, nightButton, routePanel) {
|
||||
}
|
||||
searchTimer = setTimeout(async () => {
|
||||
const mine = ++searchSeq;
|
||||
const { lng, lat } = map.unproject(visibleCenter());
|
||||
const { lng, lat } = map.getCenter();
|
||||
const url = new URL("/api/search", window.location.origin);
|
||||
url.search = new URLSearchParams({ q: input.value, sources: "layers,places", lat, lng });
|
||||
let found = [];
|
||||
@@ -115,7 +106,7 @@ export function setupDriving(map, nightButton, routePanel) {
|
||||
});
|
||||
const lookAt = (lngLat) => {
|
||||
pauseFollow(map);
|
||||
map.easeTo({ center: lngLat, zoom: Math.max(map.getZoom(), 14), padding: { right: tripPanel.offsetWidth } });
|
||||
map.easeTo({ center: lngLat, zoom: Math.max(map.getZoom(), 14) });
|
||||
};
|
||||
const renderResults = (list) => {
|
||||
list.replaceChildren(...results.map((r) => {
|
||||
@@ -163,12 +154,11 @@ export function setupDriving(map, nightButton, routePanel) {
|
||||
bar.querySelector(".drive-bar__trip").classList.toggle("active", open);
|
||||
if (open) {
|
||||
renderTrip();
|
||||
placeCrosshair();
|
||||
}
|
||||
}
|
||||
tripPanel.querySelector(".drive-trip__close").addEventListener("click", () => openTrip(false));
|
||||
tripPanel.querySelector('[data-action="add"]').addEventListener("click", () => {
|
||||
const { lng, lat } = map.unproject(visibleCenter());
|
||||
const { lng, lat } = map.getCenter();
|
||||
routePanel?.addStop([lng, lat]);
|
||||
});
|
||||
tripPanel.querySelector('[data-action="start"]').addEventListener("click", () => routePanel?.startHere());
|
||||
@@ -228,8 +218,11 @@ export function setupDriving(map, nightButton, routePanel) {
|
||||
});
|
||||
if (isLoggedIn()) pollLog();
|
||||
else tripPanel.querySelector(".drive-trip__log").hidden = true;
|
||||
window.addEventListener("resize", placeCrosshair);
|
||||
map.getContainer().append(bar, recenter, tripPanel, crosshair);
|
||||
map.getContainer().append(bar, recenter, crosshair);
|
||||
// the Trip menu beside the map, not over it (like Android Auto's side
|
||||
// panel): the map gets narrower and keeps its buttons, its center (the
|
||||
// follow, the crosshair, the overview) stays in what's seen
|
||||
map.getContainer().after(tripPanel);
|
||||
|
||||
const render = () => {
|
||||
bar.querySelector(".drive-bar__pitch").textContent = map.getPitch() > 0 ? "2D" : "3D";
|
||||
|
||||
Reference in new issue
Block a user