From d989aca2dedc047eb08891112d902cbf6441462e Mon Sep 17 00:00:00 2001 From: JingtongSu Date: Tue, 16 Dec 2025 11:49:35 -0500 Subject: [PATCH 1/2] better reflection of map feature --- src/open_apps/apps/map_app/main.py | 11 ++++------- src/open_apps/apps/map_app/templates/map.html | 13 ++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/open_apps/apps/map_app/main.py b/src/open_apps/apps/map_app/main.py index b02203e..28a0b95 100644 --- a/src/open_apps/apps/map_app/main.py +++ b/src/open_apps/apps/map_app/main.py @@ -121,6 +121,7 @@ async def map_page(request: Request): "search_button_hover_color": getattr(app.config.maps, "search_button_hover_color", "#2980b9"), "calculate_button_hover_color": getattr(app.config.maps, "calculate_button_hover_color", "#2980b9"), "sidebar_background_color": getattr(app.config.maps, "sidebar_background_color", "#f8f9fa"), + "allow_planning": app.config.maps.allow_planning, }, ) @@ -342,14 +343,10 @@ async def get_route( # print(response.json()) return response.json() except requests.exceptions.RequestException as e: - print(f"Error querying OTP GraphQL API: {e}") - if e.response is not None: - print(f"Response status code: {e.response.status_code}") - print(f"Response content: {e.response.text}") - return {"error": f"Route planning failed: {e}", "details": str(e.response.text if e.response is not None else "No response text")} + return {"error": f"route planning not supported, stay tuned!"} except Exception as e: - print(f"An unexpected error occurred: {e}") - return {"error": f"An unexpected error occurred: {e}"} + print(f"An error occurred during route planning: {e}") + return {"error": f"route planning not supported, stay tuned!", "details": str(e)} def get_map_routes(): diff --git a/src/open_apps/apps/map_app/templates/map.html b/src/open_apps/apps/map_app/templates/map.html index e1b84a1..0608c6a 100644 --- a/src/open_apps/apps/map_app/templates/map.html +++ b/src/open_apps/apps/map_app/templates/map.html @@ -303,6 +303,7 @@

{{ title }}

Current Location Info

+ {% if allow_planning %}

Route Planning

@@ -326,6 +327,7 @@

Route Planning

+ {% endif %}

Saved Locations

@@ -893,11 +895,13 @@

Saved Locations

} // Ensure DOMContentLoaded calls the correct handleLocationSearch for routing inputs + {% if allow_planning %} document.addEventListener('DOMContentLoaded', function () { // For Route Planning handleLocationSearch('fromLocation', 'fromLocationResults', 'from'); handleLocationSearch('toLocation', 'toLocationResults', 'to'); }); + {% endif %} // Function to handle clicking outside search results function handleClickOutside(event, resultsDiv) { @@ -997,12 +1001,6 @@

Saved Locations

return points; } - // Initialize route search functionality - document.addEventListener('DOMContentLoaded', function() { - handleLocationSearch('fromLocation', 'fromLocationResults', 'from'); - handleLocationSearch('toLocation', 'toLocationResults', 'to'); - }); - function displayItinerary(itineraryNode) { if (routeLayer) { map.removeLayer(routeLayer); @@ -1080,7 +1078,7 @@

Saved Locations

Total Distance: ${totalDistanceKm} km `; } - + {% if allow_planning %} document.getElementById('calculateRouteBtn').addEventListener('click', async function() { if (!routeLocations.from || !routeLocations.to) { document.getElementById('routeResult').innerHTML = ` @@ -1274,6 +1272,7 @@

Saved Locations

console.error('Route calculation error:', error); } }); + {% endif %}