2017-06-11 04:32:56 +08:00
|
|
|
import {Component, ElementRef, Input, OnChanges, ViewChild} from "@angular/core";
|
2017-01-23 05:31:29 +08:00
|
|
|
import {PhotoDTO} from "../../../../common/entities/PhotoDTO";
|
2017-06-11 04:32:56 +08:00
|
|
|
import {Dimension, IRenderable} from "../../model/IRenderable";
|
2017-02-06 00:27:58 +08:00
|
|
|
import {GalleryMapLightboxComponent} from "./lightbox/lightbox.map.gallery.component";
|
2017-01-23 05:31:29 +08:00
|
|
|
@Component({
|
2017-06-11 04:32:56 +08:00
|
|
|
selector: 'gallery-map',
|
|
|
|
templateUrl: './map.gallery.component.html',
|
|
|
|
styleUrls: ['./map.gallery.component.css']
|
2017-01-23 05:31:29 +08:00
|
|
|
})
|
2017-02-06 00:27:58 +08:00
|
|
|
export class GalleryMapComponent implements OnChanges, IRenderable {
|
2017-01-23 05:31:29 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
@Input() photos: Array<PhotoDTO>;
|
|
|
|
@ViewChild(GalleryMapLightboxComponent) mapLightbox: GalleryMapLightboxComponent;
|
|
|
|
|
|
|
|
mapPhotos: Array<{ latitude: number, longitude: number }> = [];
|
|
|
|
mapCenter = {latitude: 0, longitude: 0};
|
|
|
|
@ViewChild("map") map: ElementRef;
|
|
|
|
|
|
|
|
//TODO: fix zooming
|
|
|
|
ngOnChanges() {
|
|
|
|
this.mapPhotos = this.photos.filter(p => {
|
|
|
|
return p.metadata && p.metadata.positionData && p.metadata.positionData.GPSData;
|
|
|
|
}).map(p => {
|
|
|
|
return {
|
|
|
|
latitude: p.metadata.positionData.GPSData.latitude,
|
|
|
|
longitude: p.metadata.positionData.GPSData.longitude
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
if (this.mapPhotos.length > 0) {
|
|
|
|
this.mapCenter = this.mapPhotos[0];
|
|
|
|
}
|
2017-01-23 05:31:29 +08:00
|
|
|
|
2017-01-24 04:29:07 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2017-01-23 05:31:29 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
click() {
|
|
|
|
this.mapLightbox.show(this.getDimension());
|
|
|
|
}
|
2017-02-06 00:27:58 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public getDimension(): Dimension {
|
|
|
|
return <Dimension>{
|
|
|
|
top: this.map.nativeElement.offsetTop,
|
|
|
|
left: this.map.nativeElement.offsetLeft,
|
|
|
|
width: this.map.nativeElement.offsetWidth,
|
|
|
|
height: this.map.nativeElement.offsetHeight
|
|
|
|
};
|
|
|
|
}
|
2017-01-23 05:31:29 +08:00
|
|
|
}
|
|
|
|
|