mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-29 13:02:42 +00:00
22 lines
585 B
TypeScript
22 lines
585 B
TypeScript
import {Directive, Input, Host} from '@angular/core';
|
|
import {MapComponent} from '@maplibre/ngx-maplibre-gl';
|
|
import {environment} from '../../../environments/environment';
|
|
|
|
@Directive({
|
|
selector: 'mgl-map[styleName]',
|
|
standalone: true,
|
|
})
|
|
export class MapStyleDirective {
|
|
constructor(@Host() readonly map: MapComponent) {}
|
|
|
|
@Input()
|
|
set styleName(name: string) {
|
|
const style = `${environment.backend_url}/_static/map/styles/${name}/style.json`;
|
|
if (this.map.style) {
|
|
this.map.mapInstance.setStyle(style);
|
|
} else {
|
|
this.map.style = style;
|
|
}
|
|
}
|
|
}
|