diff --git a/src/open_apps/apps/map_app/main.py b/src/open_apps/apps/map_app/main.py index b02203e..c4028dd 100644 --- a/src/open_apps/apps/map_app/main.py +++ b/src/open_apps/apps/map_app/main.py @@ -74,7 +74,7 @@ def set_environment(config): if hasattr(app, 'config') and hasattr(app.config, 'maps') and app.config.maps.allow_planning: try: - print(f"- map planning is not supported yet, turning off...") + print(f"- map planning is not supported yet; the calculate route button is a dummy...") except Exception as e: print(f"Failed to start OTP server: {e}") if otp_process: @@ -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 %}