Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

feat(*): Support for Bicycling Layer#1678

Merged
5 commits merged into
sebholstein:masterfrom
bmamey:bicycling-layer
Jul 15, 2019
Merged

feat(*): Support for Bicycling Layer#1678
5 commits merged into
sebholstein:masterfrom
bmamey:bicycling-layer

Conversation

@bmamey

@bmamey bmamey commented Jul 8, 2019

Copy link
Copy Markdown
Contributor
  • 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

codecov Bot commented Jul 8, 2019

Copy link
Copy Markdown

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.

private _addedToManager: boolean = false;
private _id: string = (layerId++).toString();
private static _transitLayerOptions: string[] = [ 'visible'];
private _name: MapLayerType = 'TransitLayer';

Copy link
Copy Markdown

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
Copy Markdown

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

pixelOffset: Size;
}

export interface TransitLayer extends MVCObject {

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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

* @param {string} name - the type of map layer to create
* @returns {Promise<MapLayer>} a new map layer object
*/
createTransitLayer(options: mapTypes.TransitLayerOptions): Promise<mapTypes.TransitLayer>{

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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.

@ghost ghost left a comment

Copy link
Copy Markdown

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
Copy Markdown

Choose a reason for hiding this comment

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

extra tab before newLayer

Comment thread packages/core/services/google-maps-api-wrapper.ts Outdated
Comment thread packages/core/services/managers/layer-manager.ts Outdated
@ghost ghost merged commit a9b2a9c into sebholstein:master Jul 15, 2019
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants