|
|
|
@ -16,6 +16,7 @@ import {
|
|
|
|
|
import { AutocompleteService } from '../../services/auto-complete.service';
|
|
|
|
|
import { PinService } from '../../services/pin.service';
|
|
|
|
|
import { DragDropComponent } from '../drag-drop/drag-drop.component';
|
|
|
|
|
import { ExifService } from '../../exif.service';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-add-pin-popup',
|
|
|
|
@ -34,7 +35,8 @@ export class AddPinPopupComponent implements OnInit {
|
|
|
|
|
constructor(
|
|
|
|
|
private fb: FormBuilder,
|
|
|
|
|
private autocompleteService: AutocompleteService,
|
|
|
|
|
private pinService: PinService
|
|
|
|
|
private pinService: PinService,
|
|
|
|
|
private exifService: ExifService
|
|
|
|
|
) {
|
|
|
|
|
this.form = this.fb.group({
|
|
|
|
|
title: new FormControl(''),
|
|
|
|
@ -85,8 +87,24 @@ export class AddPinPopupComponent implements OnInit {
|
|
|
|
|
this.suggestions = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onFilesReceived(files: FileList): void {
|
|
|
|
|
async onFilesReceived(files: FileList): Promise<void> {
|
|
|
|
|
this.files = Array.from(files);
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < this.files.length; i++) {
|
|
|
|
|
try {
|
|
|
|
|
const data = await this.exifService.getLocation(this.files[i]);
|
|
|
|
|
if (data.latitude !== undefined && data.longitude !== undefined) {
|
|
|
|
|
const address = await this.autocompleteService.getAddressFromCoordinates(data.latitude, data.longitude).toPromise();
|
|
|
|
|
if (address) {
|
|
|
|
|
console.error("Data : " + JSON.stringify(address));
|
|
|
|
|
this.form.get('location')?.setValue(address.display_name);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error : " + error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submitForm(): void {
|
|
|
|
|