Feat: add panoramax link to 'browse nearby images'

This commit is contained in:
Pieter Vander Vennet 2024-09-30 12:44:44 +02:00
parent d772edb7e0
commit 06363e808f
2 changed files with 48 additions and 43 deletions

View file

@ -1462,10 +1462,6 @@ input[type="range"].range-lg::-moz-range-thumb {
margin-right: 4rem; margin-right: 4rem;
} }
.mb-4 {
margin-bottom: 1rem;
}
.mt-4 { .mt-4 {
margin-top: 1rem; margin-top: 1rem;
} }
@ -1482,6 +1478,10 @@ input[type="range"].range-lg::-moz-range-thumb {
margin-bottom: 4rem; margin-bottom: 4rem;
} }
.mb-4 {
margin-bottom: 1rem;
}
.ml-1 { .ml-1 {
margin-left: 0.25rem; margin-left: 0.25rem;
} }
@ -1698,14 +1698,14 @@ input[type="range"].range-lg::-moz-range-thumb {
height: 6rem; height: 6rem;
} }
.h-screen {
height: 100vh;
}
.h-full { .h-full {
height: 100%; height: 100%;
} }
.h-screen {
height: 100vh;
}
.h-fit { .h-fit {
height: -webkit-fit-content; height: -webkit-fit-content;
height: -moz-fit-content; height: -moz-fit-content;
@ -2536,6 +2536,10 @@ input[type="range"].range-lg::-moz-range-thumb {
row-gap: 2rem; row-gap: 2rem;
} }
.gap-x-8 {
column-gap: 2rem;
}
.space-y-4 > :not([hidden]) ~ :not([hidden]) { .space-y-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0; --tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse))); margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));

View file

@ -23,6 +23,7 @@
import type { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson" import type { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson"
import { onDestroy } from "svelte" import { onDestroy } from "svelte"
import { BBox } from "../../Logic/BBox" import { BBox } from "../../Logic/BBox"
import PanoramaxLink from "../BigComponents/PanoramaxLink.svelte"
export let tags: UIEventSource<OsmTags> export let tags: UIEventSource<OsmTags>
@ -37,7 +38,7 @@
let imagesProvider = state.nearbyImageSearcher let imagesProvider = state.nearbyImageSearcher
let loadedImages = AllImageProviders.LoadImagesFor(tags).mapD( let loadedImages = AllImageProviders.LoadImagesFor(tags).mapD(
(loaded) => new Set(loaded.map((img) => img.url)) (loaded) => new Set(loaded.map((img) => img.url)),
) )
let imageState = imagesProvider.getImagesAround(lon, lat) let imageState = imagesProvider.getImagesAround(lon, lat)
let result: Store<P4CPicture[]> = imageState.images.mapD( let result: Store<P4CPicture[]> = imageState.images.mapD(
@ -46,22 +47,22 @@
.filter( .filter(
(p: P4CPicture) => (p: P4CPicture) =>
!loadedImages.data.has(p.pictureUrl) && // We don't show any image which is already linked !loadedImages.data.has(p.pictureUrl) && // We don't show any image which is already linked
!p.details.isSpherical !p.details.isSpherical,
) )
.slice(0, 25), .slice(0, 25),
[loadedImages] [loadedImages],
) )
let asFeatures = result.map(p4cs => p4cs.map(p4c => (<Feature<Point>>{ let asFeatures = result.map(p4cs => p4cs.map(p4c => (<Feature<Point>>{
type: "Feature", type: "Feature",
geometry: { geometry: {
type: "Point", type: "Point",
coordinates: [p4c.coordinates.lng, p4c.coordinates.lat] coordinates: [p4c.coordinates.lng, p4c.coordinates.lat],
}, },
properties: { properties: {
id: p4c.pictureUrl, id: p4c.pictureUrl,
rotation: p4c.direction rotation: p4c.direction,
} },
}))) })))
let selected = new UIEventSource<P4CPicture>(undefined) let selected = new UIEventSource<P4CPicture>(undefined)
@ -70,28 +71,28 @@
type: "Feature", type: "Feature",
geometry: { geometry: {
type: "Point", type: "Point",
coordinates: [s.coordinates.lng, s.coordinates.lat] coordinates: [s.coordinates.lng, s.coordinates.lat],
}, },
properties: { properties: {
id: s.pictureUrl, id: s.pictureUrl,
selected: "yes", selected: "yes",
rotation: s.direction rotation: s.direction,
} },
}] }]
}) })
let someLoading = imageState.state.mapD((stateRecord) => let someLoading = imageState.state.mapD((stateRecord) =>
Object.values(stateRecord).some((v) => v === "loading") Object.values(stateRecord).some((v) => v === "loading"),
) )
let errors = imageState.state.mapD((stateRecord) => let errors = imageState.state.mapD((stateRecord) =>
Object.keys(stateRecord).filter((k) => stateRecord[k] === "error") Object.keys(stateRecord).filter((k) => stateRecord[k] === "error"),
) )
let highlighted = new UIEventSource<string>(undefined) let highlighted = new UIEventSource<string>(undefined)
onDestroy(highlighted.addCallbackD(hl => { onDestroy(highlighted.addCallbackD(hl => {
const p4c = result.data?.find(i => i.pictureUrl === hl) const p4c = result.data?.find(i => i.pictureUrl === hl)
selected.set(p4c) selected.set(p4c)
} },
)) ))
let map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined) let map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined)
@ -111,28 +112,27 @@
zoomToFeatures: true, zoomToFeatures: true,
onClick: (feature) => { onClick: (feature) => {
highlighted.set(feature.properties.id) highlighted.set(feature.properties.id)
} },
}) })
ShowDataLayer.showMultipleLayers( ShowDataLayer.showMultipleLayers(
map, map,
new StaticFeatureSource([feature]), new StaticFeatureSource([feature]),
state.layout.layers state.layout.layers,
) )
onDestroy( onDestroy(
asFeatures.addCallbackAndRunD(features => { asFeatures.addCallbackAndRunD(features => {
if(features.length == 0){ if (features.length == 0) {
return return
} }
let bbox = BBox.get(features[0]) let bbox = BBox.get(features[0])
for (const f of features) { for (const f of features) {
bbox = bbox.unionWith(BBox.get(f)) bbox = bbox.unionWith(BBox.get(f))
} }
mapProperties.maxbounds.set(bbox.pad(4)) mapProperties.maxbounds.set(bbox.pad(4))
}) }),
) )
new ShowDataLayer(map, { new ShowDataLayer(map, {
@ -140,12 +140,10 @@
layer: geocodedImageLayer, layer: geocodedImageLayer,
onClick: (feature) => { onClick: (feature) => {
highlighted.set(feature.properties.id) highlighted.set(feature.properties.id)
} },
}) })
</script> </script>
<div class="flex flex-col"> <div class="flex flex-col">
@ -169,13 +167,16 @@
{/each} {/each}
</div> </div>
{/if} {/if}
<span class="self-end pt-2"> <div class="w-full flex flex-wrap justify-end gap-x-8 pt-2">
<PanoramaxLink
<MapillaryLink large={false}
large={false} mapProperties={{ zoom: new ImmutableStore(16), location: new ImmutableStore({ lon, lat }) }}
mapProperties={{ zoom: new ImmutableStore(16), location: new ImmutableStore({ lon, lat }) }} />
/> <MapillaryLink
</span> large={false}
mapProperties={{ zoom: new ImmutableStore(16), location: new ImmutableStore({ lon, lat }) }}
/>
</div>
<div class="my-2 flex justify-between"> <div class="my-2 flex justify-between">