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

Issue 11: Add map loading message #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</head>

<body>
<div id="loading">Loading...</div>
<div id="map">
<div id="right" class="sidebar flex-center right collapsed">
<div class="sidebar-content rounded-rect flex-center">
Expand Down Expand Up @@ -152,7 +153,7 @@
{ imageUrl: 'https://raw.githubusercontent.com/phillycommunitywireless/pcwnetworkmap/main/icons/RooftopHub.png', id: 'RH_icon' },
{ imageUrl: 'https://raw.githubusercontent.com/phillycommunitywireless/pcwnetworkmap/main/icons/icon1.png', id: 'MN_icon' },
{ imageUrl: 'https://raw.githubusercontent.com/phillycommunitywireless/pcwnetworkmap/main/icons/Rooftophubs2.png', id: 'LB_icon' },
]
];

Promise.all(
images.map(img => new Promise((resolve, reject) => {
Expand Down Expand Up @@ -215,7 +216,15 @@
]

// wait for all promises to resolve before adding data to Sources
const [networkpoints_data, level1_data, level2_data, level3_data] = await Promise.all(fetch_promises)
const [networkpoints_data, level1_data, level2_data, level3_data] = await Promise.all(fetch_promises);

// hide loading message now that all data has been fetched
const loadingMessage = document.querySelector('#loading');
if (loadingMessage) {
// This if statement should always be true, but this avoids crashing the site if somehow the element
// has been removed.
loadingMessage.style.display = 'none';
}

map.addSource('network-points', {
type: 'geojson',
Expand Down
22 changes: 21 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
body { margin: 0; padding: 0; }
html { height: 100%; }

body {
margin: 0;
padding: 0;

/* Needed to easily vertically center the loading message */
display: flex;
height: 100%;
}

#map { position: absolute; top: 0; bottom: 0; width: 100%; }

.layer-icon {
Expand Down Expand Up @@ -103,3 +113,13 @@ body { margin: 0; padding: 0; }
margin-top: 10px; /* Adjust this value to increase/decrease the space */
}

#loading {
/* Chosen to contrast with the sidebar colors, since it's rendered above the sidebar on small enough viewports. */
background: white;

border-radius: 4px;
padding: 1rem;
margin: auto;
z-index: 999; /** Needs to be larger than the map, sidebar, and other future elements. */
}