Add support for mapillary api v4, fixes #364

This commit is contained in:
Pieter Vander Vennet 2021-09-15 01:33:52 +02:00
parent 5d81e7d792
commit c8eacaa409
9 changed files with 117 additions and 63 deletions

53
test.ts
View file

@ -1,41 +1,16 @@
import {UIEventSource} from "./Logic/UIEventSource";
import DirectionInput from "./UI/Input/DirectionInput";
import Loc from "./Models/Loc";
import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers";
import Minimap from "./UI/Base/Minimap";
const client_token = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
const location = new UIEventSource<Loc>({
zoom: 18,
lat: 51.2,
lon: 4.3
})
DirectionInput.constructMinimap = options => new Minimap(options)
new DirectionInput(
AvailableBaseLayers.SelectBestLayerAccordingTo(location, new UIEventSource<string | string[]>("map")),
location
).SetStyle("height: 250px; width: 250px")
.SetClass("block")
.AttachTo("maindiv")
/*
new VariableUiElement(Hash.hash.map(
hash => {
let json: {};
try {
json = atob(hash);
} catch (e) {
// We try to decode with lz-string
json =
Utils.UnMinify(LZString.decompressFromBase64(hash))
}
return new Combine([
new FixedUiElement("Base64 decoded: " + atob(hash)),
new FixedUiElement("LZ: " + LZString.decompressFromBase64(hash)),
new FixedUiElement("Base64 + unminify: " + Utils.UnMinify(atob(hash))),
new FixedUiElement("LZ + unminify: " + Utils.UnMinify(LZString.decompressFromBase64(hash)))
]).SetClass("flex flex-col m-1")
const image_id = '196804715753265';
const api_url = 'https://graph.mapillary.com/' + image_id + '?fields=thumb_1024_url&&access_token=' + client_token;
fetch(api_url,
{
headers: {'Authorization': 'OAuth ' + client_token}
}
))
.AttachTo("maindiv")*/
).then(response => {
return response.json()
}).then(
json => {
const thumbnail_url = json["thumb_1024"]
console.log(thumbnail_url)
}
)