1010/// <reference types="googlemaps" />
1111
1212import {
13- ChangeDetectionStrategy ,
14- Component ,
13+ Directive ,
1514 EventEmitter ,
1615 Input ,
1716 OnDestroy ,
1817 OnInit ,
1918 Output ,
20- ViewEncapsulation
2119} from '@angular/core' ;
2220import { BehaviorSubject , combineLatest , Observable , Subject } from 'rxjs' ;
2321import { map , take , takeUntil } from 'rxjs/operators' ;
@@ -28,12 +26,8 @@ import {GoogleMap} from '../google-map/google-map';
2826 * Angular component that renders a Google Maps Polyline via the Google Maps JavaScript API.
2927 * @see developers.google.com/maps/documentation/javascript/reference/polygon#Polyline
3028 */
31- @Component ( {
32- moduleId : module . id ,
29+ @Directive ( {
3330 selector : 'map-polyline' ,
34- template : '<ng-content></ng-content>' ,
35- changeDetection : ChangeDetectionStrategy . OnPush ,
36- encapsulation : ViewEncapsulation . None ,
3731} )
3832export class MapPolyline implements OnInit , OnDestroy {
3933 @Input ( )
@@ -107,7 +101,7 @@ export class MapPolyline implements OnInit, OnDestroy {
107101 new BehaviorSubject < google . maps . MVCArray < google . maps . LatLng > | google . maps . LatLng [ ] |
108102 google . maps . LatLngLiteral [ ] | undefined > ( undefined ) ;
109103
110- private readonly _destroy = new Subject < void > ( ) ;
104+ private readonly _destroyed = new Subject < void > ( ) ;
111105
112106 private readonly _listeners : google . maps . MapsEventListener [ ] = [ ] ;
113107
@@ -129,8 +123,8 @@ export class MapPolyline implements OnInit, OnDestroy {
129123 }
130124
131125 ngOnDestroy ( ) {
132- this . _destroy . next ( ) ;
133- this . _destroy . complete ( ) ;
126+ this . _destroyed . next ( ) ;
127+ this . _destroyed . complete ( ) ;
134128 for ( let listener of this . _listeners ) {
135129 listener . remove ( ) ;
136130 }
@@ -177,13 +171,13 @@ export class MapPolyline implements OnInit, OnDestroy {
177171 }
178172
179173 private _watchForOptionsChanges ( ) {
180- this . _options . pipe ( takeUntil ( this . _destroy ) ) . subscribe ( options => {
174+ this . _options . pipe ( takeUntil ( this . _destroyed ) ) . subscribe ( options => {
181175 this . _polyline . setOptions ( options ) ;
182176 } ) ;
183177 }
184178
185179 private _watchForPathChanges ( ) {
186- this . _path . pipe ( takeUntil ( this . _destroy ) ) . subscribe ( path => {
180+ this . _path . pipe ( takeUntil ( this . _destroyed ) ) . subscribe ( path => {
187181 if ( path ) {
188182 this . _polyline . setPath ( path ) ;
189183 }
0 commit comments