Skip to content

Commit

Permalink
fix(SebmGoogleMapPolygon): pull review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gorango committed Sep 22, 2016
1 parent 55bf6c6 commit 3449e9e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions src/core/directives/google-map-polygon.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import {AfterContentInit, Directive, EventEmitter, OnChanges, OnDestroy, SimpleChanges} from '@angular/core';
import {Subscription} from 'rxjs/Subscription';

import {LatLng, LatLngLiteral, PolyMouseEvent} from '../services/google-maps-types';
import {LatLng, LatLngLiteral, PolyMouseEvent, PolygonOptions} from '../services/google-maps-types';
import {PolygonManager} from '../services/managers/polygon-manager';

/**
* SebmGoogleMapPolygon renders a polygon on a {@link SebmGoogleMap}
*
* ### Example
* ```typescript
* import {Component} from 'angular2/core';
* import {Component} from '@angular/core';
* import {SebmGoogleMap, SebmGooglePolygon, LatLngLiteral} from 'angular2-maps/core';
*
* @Component({
* selector: 'my-map-cmp',
* directives: [SebmGoogleMap, SebmGooglePolygon],
* styles: [`
* .semb-map-container {
* height: 300px;
Expand Down Expand Up @@ -72,8 +71,8 @@ import {PolygonManager} from '../services/managers/polygon-manager';
'zIndex',
],
outputs: [
'lineClick', 'lineDblClick', 'lineDrag', 'lineDragEnd', 'lineMouseDown', 'lineMouseMove',
'lineMouseOut', 'lineMouseOver', 'lineMouseUp', 'lineRightClick'
'polyClick', 'polyDblClick', 'polyDrag', 'polyDragEnd', 'polyMouseDown', 'polyMouseMove',
'polyMouseOut', 'polyMouseOver', 'polyMouseUp', 'polyRightClick'
]
})
export class SebmGoogleMapPolygon implements OnDestroy, OnChanges, AfterContentInit {
Expand All @@ -95,11 +94,11 @@ export class SebmGoogleMapPolygon implements OnDestroy, OnChanges, AfterContentI
* The fill color. All CSS3 colors are supported except for extended
* named colors.
*/
fillColor: string = '#fff';
fillColor: string;
/**
* The fill opacity between 0.0 and 1.0
*/
fillOpacity: number = 0.7;
fillOpacity: number;
/**
* When true, edges of the polygon are interpreted as geodesic and will
* follow the curvature of the Earth. When false, edges of the polygon are
Expand Down Expand Up @@ -222,10 +221,7 @@ export class SebmGoogleMapPolygon implements OnDestroy, OnChanges, AfterContentI
return;
}

let options: {[propName: string]: any} = {};
const optionKeys = Object.keys(changes).filter(
k => SebmGoogleMapPolygon._polygonOptionsAttributes.indexOf(k) !== -1);
optionKeys.forEach(k => options[k] = changes[k].currentValue);
let options = this._updatePolygonOptions(changes);
this._polygonManager.setPolygonOptions(this, options);
}

Expand Down Expand Up @@ -255,6 +251,15 @@ export class SebmGoogleMapPolygon implements OnDestroy, OnChanges, AfterContentI
});
}

private _updatePolygonOptions(changes: SimpleChanges): PolygonOptions {
return Object.keys(changes)
.filter(k => SebmGoogleMapPolygon._polygonOptionsAttributes.indexOf(k) !== -1)
.reduce((obj, k) => {
obj[k] = changes[k].currentValue;
return obj;
}, {});
}

/** @internal */
id(): string { return this._id; }

Expand Down
4 changes: 2 additions & 2 deletions test/services/managers/polygon-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function main() {
clickable: true,
draggable: false,
editable: false,
fillColor: '#fff',
fillOpacity: 0.7,
fillColor: undefined,
fillOpacity: undefined,
geodesic: false,
paths: [],
strokeColor: undefined,
Expand Down

0 comments on commit 3449e9e

Please sign in to comment.