Desktop redesign after the Design canvas' Desktop artboard: search is one field in the topbar (places, the library, coordinates; / focuses it, sources and results drop down under it), the side rail is labelled (Map, Overlays, Library, Import | Route, Offline | GNSS, Live, Status at the bottom), the map's buttons in one column on the right (zoom and compass, north lock, 3D, my position, measure, note, home; measure/note panels open to the left), a status bar under the map (center coordinates to copy, the point under the mouse, zoom, scale, revision) instead of the zoom-level control, the scale on the map and the coordinates in the topbar; the base map button on the map dropped (the rail has it). Route panel reordered: points with their legs, adding one, the totals as a card, vehicle and avoid, directions and reach folded, reverse/clear/save last. Drive unchanged: the search, the status bar and the right column hide there
This commit is contained in:
1 parent
60d7c825fc
commit
0a5548cd8f
4 files changed
+252
-214
No files matched your search
+25
-26
@@ -37,7 +37,7 @@ function formatKm(km) {
|
||||
return km < 10 ? `${km.toFixed(1)} km` : `${Math.round(km)} km`;
|
||||
}
|
||||
|
||||
// A place-name/coordinate search box, matching NPS's own Park Tiles viewer.
|
||||
// A place-name/coordinate search box in the topbar.
|
||||
// Every result says where it was found; picking one from a layer that's
|
||||
// currently switched off switches it on (see setLayerOpeners).
|
||||
export class SearchControl {
|
||||
@@ -53,16 +53,20 @@ export class SearchControl {
|
||||
this._openers = openers;
|
||||
}
|
||||
|
||||
onAdd(map) {
|
||||
// In the topbar (the Design canvas' Desktop): the field always there,
|
||||
// the sources and results drop down under it while it's in use; "/"
|
||||
// anywhere focuses it.
|
||||
mount(map, slot) {
|
||||
this._map = map;
|
||||
this._container = document.createElement("div");
|
||||
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group search-ctrl";
|
||||
this._container.className = "search-ctrl";
|
||||
this._container.innerHTML = `
|
||||
<button type="button" class="search-ctrl__button" title="Search" aria-label="Search">${SEARCH_ICON}</button>
|
||||
<form class="search-panel__form" role="search">
|
||||
<span class="search-ctrl__icon" aria-hidden="true">${SEARCH_ICON}</span>
|
||||
<input type="search" class="search-panel__input" placeholder="Search places, the library, or lat, lng" aria-label="Search">
|
||||
<kbd class="search-ctrl__key" title="Press / to search">/</kbd>
|
||||
</form>
|
||||
<div class="search-panel" hidden>
|
||||
<form class="search-panel__form">
|
||||
<input type="text" class="search-panel__input" placeholder="Search, or lat, lng">
|
||||
</form>
|
||||
<div class="search-panel__sources">
|
||||
${SOURCES.map(
|
||||
(source) => `
|
||||
@@ -73,12 +77,11 @@ export class SearchControl {
|
||||
<ul class="search-panel__results"></ul>
|
||||
</div>
|
||||
`;
|
||||
this._button = this._container.querySelector(".search-ctrl__button");
|
||||
this._panel = this._container.querySelector(".search-panel");
|
||||
this._input = this._container.querySelector(".search-panel__input");
|
||||
this._resultsEl = this._container.querySelector(".search-panel__results");
|
||||
|
||||
this._button.addEventListener("click", () => this._toggle());
|
||||
this._input.addEventListener("focus", () => (this._panel.hidden = false));
|
||||
this._container.querySelector(".search-panel__form").addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
this._search();
|
||||
@@ -90,23 +93,20 @@ export class SearchControl {
|
||||
if (this._input.value.trim()) this._search();
|
||||
});
|
||||
});
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!this._container.contains(event.target)) this._panel.hidden = true;
|
||||
});
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape" && this._container.contains(document.activeElement)) {
|
||||
this._panel.hidden = true;
|
||||
this._input.blur();
|
||||
} else if (event.key === "/" && !event.target.closest("input, textarea, select, [contenteditable]")) {
|
||||
event.preventDefault();
|
||||
this._input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
return this._container;
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this._container.remove();
|
||||
}
|
||||
|
||||
getDefaultPosition() {
|
||||
return "top-left";
|
||||
}
|
||||
|
||||
_toggle() {
|
||||
const opening = this._panel.hidden;
|
||||
this._panel.hidden = !opening;
|
||||
this._button.classList.toggle("active", opening);
|
||||
if (opening) this._input.focus();
|
||||
slot.appendChild(this._container);
|
||||
}
|
||||
|
||||
async _search() {
|
||||
@@ -260,6 +260,5 @@ export class SearchControl {
|
||||
this._marker = new Marker({ element: el }).setLngLat(center).addTo(this._map);
|
||||
}
|
||||
this._panel.hidden = true;
|
||||
this._button.classList.remove("active");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user