Skip to content
Merged
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: 5 additions & 8 deletions src/open_apps/apps/map_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
},
)

Expand Down Expand Up @@ -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():
Expand Down
13 changes: 6 additions & 7 deletions src/open_apps/apps/map_app/templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ <h2>{{ title }}</h2>
<div id="searchResults"></div>
<h3>Current Location Info</h3>
<div id="currentLocationInfo" class="info-box"></div>
{% if allow_planning %}
<h3>Route Planning</h3>
<div class="route-container">
<div class="location-input-container">
Expand All @@ -326,6 +327,7 @@ <h3>Route Planning</h3>
</div>
</div>
</div>
{% endif %}
<h3>Saved Locations</h3>
<div id="popupList"></div>
</div>
Expand Down Expand Up @@ -893,11 +895,13 @@ <h3>Saved Locations</h3>
}

// 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) {
Expand Down Expand Up @@ -997,12 +1001,6 @@ <h3>Saved Locations</h3>
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);
Expand Down Expand Up @@ -1080,7 +1078,7 @@ <h3>Saved Locations</h3>
<strong>Total Distance:</strong> ${totalDistanceKm} km
`;
}

{% if allow_planning %}
document.getElementById('calculateRouteBtn').addEventListener('click', async function() {
if (!routeLocations.from || !routeLocations.to) {
document.getElementById('routeResult').innerHTML = `
Expand Down Expand Up @@ -1274,6 +1272,7 @@ <h3>Saved Locations</h3>
console.error('Route calculation error:', error);
}
});
{% endif %}

</script>
<div id="markerCustomizationModal" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.3); z-index: 1000;">
Expand Down