Skip to content

Commit

Permalink
Merge pull request #33 from OneBusAway/busroute-feat
Browse files Browse the repository at this point in the history
Added the feature for hiding the bus route on back to button
  • Loading branch information
aaronbrethorst authored Aug 21, 2024
2 parents 95f2b12 + 6d00bfc commit c5fec32
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
11 changes: 9 additions & 2 deletions src/components/map/GoogleMap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import StopMarker from './StopMarker.svelte';
import RouteMap from './RouteMap.svelte';
export let selectedTrip;
export let selectedTrip = null;
export let selectedRoute = null;
export let showRoute = false;
export let showRouteMap = false;
export let showAllStops = true;
const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -83,6 +85,11 @@
markers = [];
}
$: if (showAllStops) {
clearAllMarkers();
allStops.forEach((s) => addMarker(s));
}
$: if (selectedRoute && showRoute) {
clearAllMarkers();
const stopsToShow = allStops.filter((s) => s.routeIds.includes(selectedRoute.id));
Expand Down Expand Up @@ -194,7 +201,7 @@
<div id="map"></div>
{#if selectedTrip}
{#if selectedTrip && showRouteMap}
<RouteMap {map} tripId={selectedTrip.tripId} />
{/if}
Expand Down
12 changes: 12 additions & 0 deletions src/components/oba/StopPane.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
export let stop;
export let arrivalsAndDeparturesResponse = null;
export let showAllStops = true;
let arrivalsAndDepartures;
let loading = false;
let error;
Expand All @@ -29,6 +31,11 @@
loading = false;
}
$: if (showAllStops) {
showTripDetails = false;
selectedTripDetails = null;
}
$: (async (s, arrDep) => {
// if the arrivalsAndDeparturesResponse is passed in, use that
// instead of loading fresh data.
Expand Down Expand Up @@ -66,9 +73,14 @@
};
showTripDetails = true;
dispatch('tripSelected', selectedTripDetails);
dispatch('updateRouteMap', { show: true });
}
function handleCloseTripDetailModal() {
showTripDetails = false;
dispatch('tripSelected', null);
dispatch('updateRouteMap', { show: false });
dispatch('showAllStops');
}
</script>

Expand Down
46 changes: 38 additions & 8 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
let selectedTrip = null;
let showRoute = false;
let selectedRoute = null;
let showRouteMap = false;
let showAllStops = false;
function stopSelected(event) {
stop = event.detail.stop;
Expand All @@ -20,19 +22,47 @@
}
function tripSelected(event) {
selectedTrip = event.detail;
showRoute = true;
selectedRoute = {
id: event.detail.routeId,
shortName: event.detail.routeShortName
};
if (event.detail) {
selectedTrip = event.detail;
showRoute = true;
selectedRoute = {
id: event.detail.routeId,
shortName: event.detail.routeShortName
};
} else {
selectedTrip = null;
showRoute = false;
selectedRoute = null;
}
}
function handleUpdateRouteMap(event) {
showRouteMap = event.detail.show;
showAllStops = !event.detail.show;
}
function handleShowAllStops() {
showAllStops = true;
showRouteMap = false;
}
</script>

{#if stop}
<ModalPane on:close={closePane}>
<StopPane {stop} on:tripSelected={tripSelected} />
<StopPane
{showAllStops}
{stop}
on:tripSelected={tripSelected}
on:updateRouteMap={handleUpdateRouteMap}
on:showAllStops={handleShowAllStops}
/>
</ModalPane>
{/if}

<GoogleMap {selectedTrip} {selectedRoute} on:stopSelected={stopSelected} {showRoute} />
<GoogleMap
{selectedTrip}
{selectedRoute}
on:stopSelected={stopSelected}
{showRoute}
{showRouteMap}
/>

0 comments on commit c5fec32

Please sign in to comment.