mapcomplete/UI/Image/AttributedImage.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

import Combine from "../Base/Combine";
import Attribution from "./Attribution";
import Img from "../Base/Img";
import ImageProvider, {ProvidedImage} from "../../Logic/ImageProviders/ImageProvider";
import BaseUIElement from "../BaseUIElement";
2021-10-01 02:57:41 +02:00
import {Mapillary} from "../../Logic/ImageProviders/Mapillary";
export class AttributedImage extends Combine {
constructor(imageInfo: {
url: string,
provider?: ImageProvider,
date?: Date
}
) {
let img: BaseUIElement;
2021-10-01 02:57:41 +02:00
img = new Img(imageInfo.url, false, {
2021-11-07 16:34:51 +01:00
fallbackImage: imageInfo.provider === Mapillary.singleton ? "./assets/svg/blocked.svg" : undefined
2021-10-01 02:57:41 +02:00
});
let attr: BaseUIElement = undefined
if(imageInfo.provider !== undefined){
attr = new Attribution(imageInfo.provider?.GetAttributionFor(imageInfo.url),
imageInfo.provider?.SourceIcon(),
imageInfo.date
)
}
super([img, attr]);
this.SetClass('block relative h-full');
}
}