Skip to content

Commit

Permalink
feat(mglNavigation): add showCompass & showZoom inputs
Browse files Browse the repository at this point in the history
close #55
  • Loading branch information
Wykks committed Sep 9, 2018
1 parent a864d3f commit b1428b0
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, OnInit, Host } from '@angular/core';
import { Directive, Host, Input, OnInit } from '@angular/core';
import { NavigationControl } from 'mapbox-gl';
import { MapService } from '../map/map.service';
import { ControlComponent } from './control.component';
Expand All @@ -7,6 +7,9 @@ import { ControlComponent } from './control.component';
selector: '[mglNavigation]'
})
export class NavigationControlDirective implements OnInit {
/* Init inputs */
@Input() showCompass?: boolean;
@Input() showZoom?: boolean;

constructor(
private MapService: MapService,
Expand All @@ -18,7 +21,14 @@ export class NavigationControlDirective implements OnInit {
if (this.ControlComponent.control) {
throw new Error('Another control is already set for this control');
}
this.ControlComponent.control = new NavigationControl();
let options: { showCompass?: boolean, showZoom?: boolean } = {};
if (this.showCompass !== undefined) {
options.showCompass = this.showCompass;
}
if (this.showZoom !== undefined) {
options.showZoom = this.showZoom;
}
this.ControlComponent.control = new NavigationControl(options);
this.MapService.addControl(this.ControlComponent.control, this.ControlComponent.position);
});
}
Expand Down

0 comments on commit b1428b0

Please sign in to comment.