import { Component, Input } from '@angular/core';
import { mapIcon } from '~/constants/icons';
import * as utils from '@nativescript/core/utils/utils';

@Component({
    selector: 'GpsLine',
    moduleId: module.id,
    templateUrl: './gps-line.component.html',
    styleUrls: ['../info-line/_info-line.component.scss'],

})
export class GpsLineComponent {
    isSeparated: boolean = false;
    @Input()
    set separated(value: string) {
        this.isSeparated = value != 'false';
    };
    @Input() lon: number;
    @Input() lat: number;
    @Input() class: string;

    mapIcon = mapIcon;
    openLocation(latitude: number, longitude: number) {
        const encodedAddress = encodeURI(`${latitude}, ${longitude}&`);
        utils.openUrl(`https://www.google.com/maps/search/?api=1&query=${encodedAddress}`);
    }
}
