Skip to content

Commit

Permalink
feat(marker): Add popupShown Input binding to marker.component (#113)
Browse files Browse the repository at this point in the history
Enable opening and closing marker popups with Input variable
  • Loading branch information
AndrejB1 authored and Wykks committed Mar 17, 2019
1 parent 487c464 commit 1b0fed8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/ngx-mapbox-gl/src/lib/marker/marker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class MarkerComponent implements OnChanges, OnDestroy, AfterViewInit, OnI
@Input() feature?: GeoJSON.Feature<GeoJSON.Point>;
@Input() lngLat?: LngLatLike;
@Input() draggable?: boolean;
@Input() popupShown?: boolean;

@Output() dragStart = new EventEmitter<Marker>();
@Output() drag = new EventEmitter<Marker>();
Expand Down Expand Up @@ -65,6 +66,9 @@ export class MarkerComponent implements OnChanges, OnDestroy, AfterViewInit, OnI
if (changes.draggable && !changes.draggable.isFirstChange()) {
this.markerInstance!.setDraggable(!!this.draggable);
}
if (changes.popupShown && !changes.popupShown.isFirstChange()) {
changes.popupShown.currentValue ? this.markerInstance!.getPopup().addTo(this.MapService.mapInstance) : this.markerInstance!.getPopup().remove();
}
}

ngAfterViewInit() {
Expand Down

0 comments on commit 1b0fed8

Please sign in to comment.