libs/map/src/lib/control/locate/locate.component.ts
selector | n52-locate-control |
styleUrls | ./locate.component.scss |
templateUrl | ./locate.component.html |
Properties |
|
Methods |
|
Inputs |
constructor(locateService: LocateService, mapCache: MapCache)
|
|||||||||
Parameters :
|
mapId | |
Type : string
|
|
mapId | |
Type : string
|
|
Inherited from
MapControlComponent
|
|
Defined in
MapControlComponent:11
|
|
Connect map id. |
Public locateUser |
locateUser()
|
Returns :
void
|
Public isToggled |
Default value : false
|
import { Component, Input } from '@angular/core';
import { MapControlComponent } from '../map-control-component';
import { LocateService } from './locate.service';
import { MapCache } from '../../base/map-cache.service';
@Component({
selector: 'n52-locate-control',
templateUrl: './locate.component.html',
styleUrls: ['./locate.component.scss']
})
export class LocateControlComponent extends MapControlComponent {
@Input()
public mapId: string;
public isToggled = false;
constructor(
protected locateService: LocateService,
protected mapCache: MapCache
) {
super(mapCache);
}
public locateUser() {
this.isToggled = !this.isToggled;
if (this.isToggled) {
this.locateService.startLocate(this.mapId);
} else {
this.locateService.stopLocate(this.mapId);
}
}
}
<div class="btn-group-vertical btn-group-sm map-control">
<button type="button" class="btn btn-sm" (click)="locateUser()" [ngClass]="isToggled ? 'btn-primary': 'btn-light'">
locate
</button>
</div>
./locate.component.scss
:host {
i {
width: 11px;
}
}