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

feat(*): Support for Bicycling Layer #1678

Merged
5 commits merged into from
Jul 15, 2019
Merged

Conversation

bmamey
Copy link
Contributor

@bmamey bmamey commented Jul 8, 2019

  • Added a single service to manage all map layers like transit and bicycling layers

https://developers.google.com/maps/documentation/javascript/trafficlayer#bicycling_layer

- Added a single service to manage all map layers like transit and bicycling layers
@codecov
Copy link

codecov bot commented Jul 8, 2019

Codecov Report

Merging #1678 into master will increase coverage by 0.24%.
The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1678      +/-   ##
==========================================
+ Coverage    39.7%   39.95%   +0.24%     
==========================================
  Files          40       41       +1     
  Lines        1778     1802      +24     
  Branches      144      148       +4     
==========================================
+ Hits          706      720      +14     
- Misses       1071     1081      +10     
  Partials        1        1
Impacted Files Coverage Δ
packages/core/services/google-maps-types.ts 0% <ø> (ø) ⬆️
packages/core/core.module.ts 0% <0%> (ø) ⬆️
packages/core/directives.ts 0% <0%> (ø) ⬆️
packages/core/services.ts 0% <0%> (ø) ⬆️
packages/core/directives/map.ts 0% <0%> (ø) ⬆️
packages/core/services/google-maps-api-wrapper.ts 33.7% <12.5%> (-0.82%) ⬇️
packages/core/directives/transit-layer.ts 60.86% <40%> (+7.53%) ⬆️
packages/core/directives/bicycling-layer.ts 60.86% <60.86%> (ø)
packages/core/services/managers/layer-manager.ts 78.26% <78.26%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be2c5af...8d5a804. Read the comment docs.

@@ -14,51 +15,42 @@ let layerId = 0;
export class AgmTransitLayer implements OnInit, OnChanges, OnDestroy{
private _addedToManager: boolean = false;
private _id: string = (layerId++).toString();
private static _transitLayerOptions: string[] = [ 'visible'];
private _name: MapLayerType = 'TransitLayer';
Copy link

Choose a reason for hiding this comment

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

Shouldn't this be static and final?

visible: boolean;
}

export type MapLayerType = 'TransitLayer' | 'BicyclingLayer' | 'TrafficLayer';
Copy link

Choose a reason for hiding this comment

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

this is not a google map type, it doesn't belong here

@@ -435,16 +435,18 @@ export interface KmlMouseEvent extends MouseEvent {
pixelOffset: Size;
}

export interface TransitLayer extends MVCObject {
Copy link

Choose a reason for hiding this comment

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

Google maps has TransitLayer and BicycleLayer classes, but not MapLayer class.

Copy link

Choose a reason for hiding this comment

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

Why don't you just split out the classes

Copy link

Choose a reason for hiding this comment

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

keeping one LayerManager, though, is a good idea, I just think that at the level of google apis, it should be separate since google keeps it separate

*/
createTransitLayer(options: mapTypes.TransitLayerOptions): Promise<mapTypes.TransitLayer>{
Copy link

Choose a reason for hiding this comment

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

I really think that the google-maps-api-wrapper class should have separate methods for createTransitLayer, createBicycleLayer, createTrafficLayer since there is nothing in common between these, and it's bad practice to separate code execution by a passed in string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I decided to go with one layerManager because Bicycling Layer and and Transit Layer has the exact methods. There is nothing different apart from the class names. I thought it would be an overkill to have 3 services with the same methods and properties, but I will separate them since that's how google does it.

Copy link

Choose a reason for hiding this comment

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

I agree to have one uniting manager. but I think there should be different methods in ApiWrapper and in google map types

* @returns Promise<void>
*/
setOptions(layer: AgmTransitLayer|AgmBicyclingLayer, changes: SimpleChanges): Promise<void> {
const options = Object.keys(changes)
Copy link

Choose a reason for hiding this comment

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

SimpleChanges is part of angular component infrastructure, and should not be leaked to our Manager classes. I recommend going back to how it was originally.

Additionally, keeping in mind that there is only ONE parameter for both bicycle layer, and transitlayer, it doesn't make sense do the entire Object.keys, filter, etc.

You can just do

if (changes['visible'] != null) {
  return this.layerManager.setVisible(this, changes['visible'].currentValue);
}

Of course keep the above lines of code in the directive's ngOnChanges method, and not in manager.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Hey, thanks for the changes. Three more small issues. In the meantime, I'll manually test the new code.

transitLayer.setMap(options.visible ? map : null);
return transitLayer;
let newLayer: mapTypes.TransitLayer = new google.maps.TransitLayer();
newLayer.setMap(options.visible ? map : null);
Copy link

Choose a reason for hiding this comment

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

extra tab before newLayer

packages/core/services/google-maps-api-wrapper.ts Outdated Show resolved Hide resolved
packages/core/services/managers/layer-manager.ts Outdated Show resolved Hide resolved
@ghost ghost merged commit a9b2a9c into sebholstein:master Jul 15, 2019
This pull request was closed.
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.

2 participants