Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented the Bus Route, Draw polyline feat, and hidden unrelated stops #31

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

tarunsinghofficial
Copy link
Collaborator

Fixes #30 #29 #24 issues.

@tarunsinghofficial
Copy link
Collaborator Author

The feature is working correctly but there's one issue left. When we try to choose a new stop, the old bus route is not removed. So, working on the leftover issue now.

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noted a few places where code can be simplified or deleted but this is looking good!

@@ -51,20 +56,54 @@
async function loadStopsAndAddMarkers(lat, lng) {
const json = await loadStopsForLocation(lat, lng);
const stops = json.data.list;
allStops = [...allStops, ...stops];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be sure to de-dupe these lists as you merge them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done.

function clearAllMarkers() {
markers.forEach(({ marker, overlay, element }) => {
if (marker) {
marker.setMap(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be simplified to marker?.setMap(null)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done the optional chaining.

if (marker) {
marker.setMap(null);
}
if (overlay) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

overlay.onRemove();
}
}
if (element && element.parentNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

allStops.forEach((s) => addMarker(s));
}

/* function markerExists(s) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted the component

@@ -107,6 +146,11 @@
container.style.position = 'absolute';
this.getPanes().overlayMouseTarget.appendChild(container);
};
overlay.onRemove = function () {
if (container.parentNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use optional chaining here too to get rid of the if statement

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the if statement in place of optional chaining.

Fixes #24 - Trip Details List and Map Overlay
Fixes #29 - The bus's route should also be projected onto the map
Fixes #30 - Hide unrelated stops on the map while a route line is being displayed

Also, checks to see if `window.google` exists, and only loads the Google Maps library if it does not. This resolves a warning in the console.

Co-authored-by: tarunsinghofficial <[email protected]>
@aaronbrethorst aaronbrethorst merged commit 95f2b12 into main Aug 14, 2024
3 checks passed
@aaronbrethorst aaronbrethorst deleted the bus-route branch August 14, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide unrelated stops on the map while a route line is being displayed
2 participants