up home
This commit is contained in:
parent
c3dc3bdbb5
commit
a2834c1f25
1 changed files with 26 additions and 77 deletions
|
@ -228,26 +228,28 @@ class DemoMainResource:
|
||||||
# <div id="auth-section" class="auth-section">
|
# <div id="auth-section" class="auth-section">
|
||||||
# <h3>OpenStreetMap Authentication</h3>
|
# <h3>OpenStreetMap Authentication</h3>
|
||||||
#
|
#
|
||||||
# <a href="https://www.openstreetmap.org/oauth2/authorize?client_id={client_id}&redirect_uri={client_redirect}&response_type=code&scope=read_prefs" class="osm-login-btn">
|
<a href="https://www.openstreetmap.org/oauth2/authorize?client_id={client_id}&redirect_uri={client_redirect}&response_type=code&scope=read_prefs" class="osm-login-btn">
|
||||||
# <span class="osm-logo"></span>
|
<span class="osm-logo"></span>
|
||||||
# Login with OpenStreetMap
|
Login with OpenStreetMap
|
||||||
# </a>
|
</a>
|
||||||
# <script>
|
<script>
|
||||||
# // Replace server-side auth section with JavaScript-rendered version if available
|
# // Replace server-side auth section with JavaScript-rendered version if available
|
||||||
# document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
# if (window.osmAuth) {
|
fetchEvents();
|
||||||
# const clientId = document.getElementById('osmClientId').value;
|
|
||||||
# const redirectUri = document.getElementById('osmRedirectUri').value;
|
if (window.osmAuth) {
|
||||||
# const authSection = document.getElementById('auth-section');
|
const clientId = document.getElementById('osmClientId').value;
|
||||||
#
|
const redirectUri = document.getElementById('osmRedirectUri').value;
|
||||||
# // Only replace if osmAuth is loaded and has renderAuthSection method
|
const authSection = document.getElementById('auth-section');
|
||||||
# if (osmAuth.renderAuthSection) {
|
|
||||||
# authSection.innerHTML = osmAuth.renderAuthSection(clientId, redirectUri);
|
// Only replace if osmAuth is loaded and has renderAuthSection method
|
||||||
# }
|
if (osmAuth.renderAuthSection) {
|
||||||
# }
|
authSection.innerHTML = osmAuth.renderAuthSection(clientId, redirectUri);
|
||||||
# });
|
}
|
||||||
# </script>
|
}
|
||||||
# </div> -->
|
});
|
||||||
|
</script>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
<h3 id="endpoints_list_header">API Endpoints:</h3>
|
<h3 id="endpoints_list_header">API Endpoints:</h3>
|
||||||
<ul id="endpoints_list">
|
<ul id="endpoints_list">
|
||||||
|
@ -276,7 +278,7 @@ class DemoMainResource:
|
||||||
// Fonction pour gérer les listes dépliantes
|
// Fonction pour gérer les listes dépliantes
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
fetchEvents();
|
|
||||||
|
|
||||||
const endpointsHeader = document.getElementById('endpoints_list_header');
|
const endpointsHeader = document.getElementById('endpoints_list_header');
|
||||||
const endpointsList = document.getElementById('endpoints_list');
|
const endpointsList = document.getElementById('endpoints_list');
|
||||||
|
@ -353,62 +355,7 @@ class DemoMainResource:
|
||||||
let currentStyle = 'default';
|
let currentStyle = 'default';
|
||||||
let eventsData = null;
|
let eventsData = null;
|
||||||
|
|
||||||
document.getElementById('style-default').addEventListener('click', () => {
|
|
||||||
if (currentStyle !== 'default') {
|
|
||||||
switchMapStyle('default');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('style-osm-vector').addEventListener('click', () => {
|
|
||||||
if (currentStyle !== 'osmVector') {
|
|
||||||
switchMapStyle('osmVector');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('style-osm-raster').addEventListener('click', () => {
|
|
||||||
if (currentStyle !== 'osmRaster') {
|
|
||||||
switchMapStyle('osmRaster');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function switchMapStyle(styleName) {
|
|
||||||
// Update active button
|
|
||||||
document.querySelectorAll('.map-style-control button').forEach(button => {
|
|
||||||
button.classList.remove('active');
|
|
||||||
});
|
|
||||||
document.getElementById(`style-${styleName.replace('osm', 'osm-')}`).classList.add('active');
|
|
||||||
|
|
||||||
// Save current center and zoom
|
|
||||||
const center = map.getCenter();
|
|
||||||
const zoom = map.getZoom();
|
|
||||||
|
|
||||||
// Save events data if already loaded
|
|
||||||
if (map.getSource('events')) {
|
|
||||||
try {
|
|
||||||
eventsData = map.getSource('events')._data;
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Error saving events data:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply new style
|
|
||||||
map.setStyle(mapStyles[styleName]);
|
|
||||||
|
|
||||||
// Restore center and zoom after style is loaded
|
|
||||||
map.once('style.load', () => {
|
|
||||||
map.setCenter(center);
|
|
||||||
map.setZoom(zoom);
|
|
||||||
|
|
||||||
// Restore events data if available
|
|
||||||
if (eventsData) {
|
|
||||||
addEventsToMap(eventsData);
|
|
||||||
} else {
|
|
||||||
fetchEvents();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
currentStyle = styleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch events when the map is loaded
|
// Fetch events when the map is loaded
|
||||||
map.on('load', function() {
|
map.on('load', function() {
|
||||||
|
@ -870,6 +817,8 @@ class DemoMainResource:
|
||||||
errorToast.classList.remove('show');
|
errorToast.classList.remove('show');
|
||||||
}, 6000);
|
}, 6000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue