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(FitBounds): add fitBounds to agm-polyline-point #1720

Merged
3 commits merged into from
Sep 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/core/directives/polyline-point.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Directive, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { Directive, EventEmitter, forwardRef, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { LatLngLiteral } from '../../core/services/google-maps-types';
import { FitBoundsAccessor, FitBoundsDetails } from '../services/fit-bounds';

/**
* AgmPolylinePoint represents one element of a polyline within a {@link
* AgmPolyline}
*/
@Directive({selector: 'agm-polyline-point'})
export class AgmPolylinePoint implements OnChanges {
@Directive({
selector: 'agm-polyline-point',
providers: [
{provide: FitBoundsAccessor, useExisting: forwardRef(() => AgmPolylinePoint)},
],
})
export class AgmPolylinePoint implements OnChanges, FitBoundsAccessor {
/**
* The latitude position of the point.
*/
Expand All @@ -33,4 +41,12 @@ export class AgmPolylinePoint implements OnChanges {
this.positionChanged.emit(position);
}
}

/** @internal */
getFitBoundsDetails$(): Observable<FitBoundsDetails> {
return this.positionChanged.pipe(
startWith({lat: this.latitude, lng: this.longitude}),
map(x => ({latLng: x}))
Copy link

Choose a reason for hiding this comment

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

rename x to position or some other meaningful name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, used position

);
}
}