2017-01-23 05:31:29 +08:00
|
|
|
import {Component, OnChanges, Input} from "@angular/core";
|
|
|
|
import {PhotoDTO} from "../../../../common/entities/PhotoDTO";
|
|
|
|
import {Utils} from "../../../../common/Utils";
|
|
|
|
@Component({
|
|
|
|
selector: 'gallery-map',
|
|
|
|
templateUrl: 'app/gallery/map/map.gallery.component.html',
|
|
|
|
styleUrls: ['app/gallery/map/map.gallery.component.css']
|
|
|
|
})
|
|
|
|
export class GalleryMapComponent implements OnChanges {
|
|
|
|
|
|
|
|
@Input() photos: Array<PhotoDTO>;
|
|
|
|
|
2017-01-24 04:29:07 +08:00
|
|
|
mapPhotos: Array<{latitude: string, longitude: string, iconUrl}> = [];
|
|
|
|
mapCenter = {latitude: "0", longitude: "0"};
|
2017-01-23 05:31:29 +08:00
|
|
|
|
|
|
|
//TODO: fix zooming
|
|
|
|
ngOnChanges() {
|
2017-01-24 04:29:07 +08:00
|
|
|
this.mapPhotos = this.photos.filter(p => {
|
|
|
|
return p.metadata && p.metadata.positionData && p.metadata.positionData.GPSData;
|
|
|
|
}).map(p => {
|
2017-01-23 05:31:29 +08:00
|
|
|
return {
|
|
|
|
latitude: p.metadata.positionData.GPSData.latitude,
|
|
|
|
longitude: p.metadata.positionData.GPSData.longitude,
|
|
|
|
iconUrl: Utils.concatUrls("/api/gallery/content/", p.directory.path, p.directory.name, p.name, "icon")
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2017-01-24 04:29:07 +08:00
|
|
|
if (this.mapPhotos.length > 0) {
|
|
|
|
this.mapCenter = this.mapPhotos[0];
|
|
|
|
}
|
|
|
|
|
2017-01-23 05:31:29 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|