forked from MapComplete/MapComplete
Add support for mapillary api v4, fixes #364
This commit is contained in:
parent
5d81e7d792
commit
c8eacaa409
9 changed files with 117 additions and 63 deletions
|
|
@ -2,16 +2,26 @@ import Combine from "../Base/Combine";
|
|||
import Attribution from "./Attribution";
|
||||
import Img from "../Base/Img";
|
||||
import ImageAttributionSource from "../../Logic/ImageProviders/ImageAttributionSource";
|
||||
import BaseUIElement from "../BaseUIElement";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
|
||||
|
||||
export class AttributedImage extends Combine {
|
||||
|
||||
constructor(urlSource: string, imgSource: ImageAttributionSource) {
|
||||
urlSource = imgSource.PrepareUrl(urlSource)
|
||||
super([
|
||||
new Img(urlSource),
|
||||
new Attribution(imgSource.GetAttributionFor(urlSource), imgSource.SourceIcon())
|
||||
]);
|
||||
const preparedUrl = imgSource.PrepareUrl(urlSource)
|
||||
let img: BaseUIElement;
|
||||
let attr: BaseUIElement
|
||||
if (typeof preparedUrl === "string") {
|
||||
img = new Img(urlSource);
|
||||
attr = new Attribution(imgSource.GetAttributionFor(urlSource), imgSource.SourceIcon())
|
||||
} else {
|
||||
img = new VariableUiElement(preparedUrl.map(url => new Img(url, false, {fallbackImage: './assets/svg/blocked.svg'})))
|
||||
attr = new VariableUiElement(preparedUrl.map(url => new Attribution(imgSource.GetAttributionFor(urlSource), imgSource.SourceIcon())))
|
||||
}
|
||||
|
||||
|
||||
super([img, attr]);
|
||||
this.SetClass('block relative h-full');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue