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
+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