Skip to content

feat(google-maps): Add Layer components. #19604

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

Merged
merged 5 commits into from
Aug 21, 2020

Conversation

mbehrlich
Copy link
Collaborator

Implement components to easily add a traffic, transit or bicycling layer
to an Angular Google Map.

@mbehrlich mbehrlich requested a review from a team as a code owner June 10, 2020 23:57
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 11, 2020
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

The code LGTM, but it seems like it's somewhat identical between the different layers. Would it make sense to either have one component where the user passes in what kind of layer they want (e.g. <map-layer type="traffic">) or have a base class that is shared between them?

@jelbourn
Copy link
Member

+1 to @crisbeto's comment

@mbehrlich
Copy link
Collaborator Author

The code LGTM, but it seems like it's somewhat identical between the different layers. Would it make sense to either have one component where the user passes in what kind of layer they want (e.g. <map-layer type="traffic">) or have a base class that is shared between them?

I considered this. The main issue is the "autoRefresh" on the traffic layer causes that component to have a different initialization process than the other two layers, and to implement both processes in a single abstract component would defeat the DRY principle we're going for. I also considered a single component that would implement everything like but I decided against this, because I think that the Angular components should mirror the Google Maps JavaScript API as much as possible. If they had done an initialization like:

let trafficLayer = new google.maps.Layer(google.maps.LayerType.TRAFFIC);

then I would make them the same component, but since google maps made them different classes, I think we should follow their convention and make them separate components.

It would still be possible to try make a base class between the transit and bicycling layers, since they are virtually identical. I didn't do that initially since they're so small and there's only two of them, so the amount of duplicated code is minimal, what do you think?

@jelbourn
Copy link
Member

Could it be one layer base class with the traffic layer adding a bit extra in the subclass?

@mbehrlich
Copy link
Collaborator Author

Could it be one layer base class with the traffic layer adding a bit extra in the subclass?

It could, and I've experimented with it a little bit. Ultimately I don't think it's a useful abstraction. Since traffic class is instantiated in a different way, we wouldn't be able to avoid duplication there and ultimately there's very little code that we can avoid duplication for among all of the components. The final code would actually be somewhat longer if we implemented this.

@jelbourn
Copy link
Member

Ack- does a shared class just make sense for the other two layers, then?

@mbehrlich
Copy link
Collaborator Author

Done - Added a base class for transit and bicycling layers.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM with one nit.

@crisbeto crisbeto added lgtm P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release action: merge The PR is ready for merge by the caretaker labels Jul 8, 2020
@jelbourn
Copy link
Member

@mbehrlich can you rebase? I merged a couple other maps PRs so there's a merge conflict now

Implement components to easily add a traffic, transit or bicycling layer
to an Angular Google Map.
Fix comment for autoRefresh property of Traffic Layer.
Add a base class for the transit and bicycling layers.
Fix circleci error with MapBaseLayer not being part of a module.
Update public api with base layer class.
@mbehrlich
Copy link
Collaborator Author

@mbehrlich can you rebase? I merged a couple other maps PRs so there's a merge conflict now

Done

@mmalerba mmalerba removed the lgtm label Jul 31, 2020
@wagnermaciel wagnermaciel merged commit 3345a9a into angular:master Aug 21, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants