Skip to content

Commit

Permalink
Show location in the map from photo
Browse files Browse the repository at this point in the history
  • Loading branch information
rigon committed Jul 12, 2023
1 parent ade4ba0 commit b2282e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/photo.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (photo *Photo) FillInfo() error {
photo.Width = selected.Width
photo.Height = selected.Height
photo.Date = selected.Date
photo.Location = selected.Location
return nil
}

Expand Down
4 changes: 1 addition & 3 deletions src/PhotoInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const PhotoInfo: FC<InfoPanelProps> = ({ photos, selected, onClose }) => {
const hasBefore = index > 0;
const hasNext = index < photos.length - 1;

const mapLocation = data.findIndex(f => f?.imageinfo?.location?.present);

const handleClose = () => {
setIndex(-1);
if(onClose !== undefined)
Expand Down Expand Up @@ -129,7 +127,7 @@ const PhotoInfo: FC<InfoPanelProps> = ({ photos, selected, onClose }) => {
<img src={urls.thumb(photo)} alt={photo.title} style={{ width: "100%", height: "200px", objectFit: "cover" }} />
</Grid>
<Grid item xs={8}>
{mapLocation >= 0 && <Suspense><Map height="200px" mark={data[mapLocation].imageinfo.location} /></Suspense>}
{photo.location.present && <Suspense><Map height="200px" mark={photo.location} /></Suspense>}
</Grid>
</Grid>
{data.map((file: any) => (
Expand Down
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export interface PhotoType {
width: number;
height: number;
date: string;
info: string;
location: {
present: boolean;
lat: number;
lng: number;
}
files: FileType[];
}

Expand Down

0 comments on commit b2282e8

Please sign in to comment.