UNPKG

1.1 kBPlain TextView Raw
1import {Directive, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
2import {LatLngLiteral} from '../../core/services/google-maps-types';
3
4/**
5 * SebmGoogleMapPolylinePoint represents one element of a polyline within a {@link
6 * SembGoogleMapPolyline}
7 */
8@Directive({selector: 'sebm-google-map-polyline-point'})
9export class SebmGoogleMapPolylinePoint implements OnChanges {
10 /**
11 * The latitude position of the point.
12 */
13 @Input() public latitude: number;
14
15 /**
16 * The longitude position of the point;
17 */
18 @Input() public longitude: number;
19
20 /**
21 * This event emitter gets emitted when the position of the point changed.
22 */
23 @Output() positionChanged: EventEmitter<LatLngLiteral> = new EventEmitter<LatLngLiteral>();
24
25 constructor() {}
26
27 ngOnChanges(changes: SimpleChanges): any {
28 if (changes['latitude'] || changes['longitude']) {
29 const position: LatLngLiteral = <LatLngLiteral>{
30 lat: changes['latitude'].currentValue,
31 lng: changes['longitude'].currentValue
32 };
33 this.positionChanged.emit(position);
34 }
35 }
36}