From 5a7402313e285cc0a5583b1061c63105bc397c5f Mon Sep 17 00:00:00 2001 From: evlist Date: Mon, 10 Oct 2022 22:08:50 +0200 Subject: [PATCH] Improved version of OSM notes shown as chat messages. --- src/components/map/LocationInfo.tsx | 226 ++++++++++++++-------------- src/theme/map.css | 6 + 2 files changed, 115 insertions(+), 117 deletions(-) diff --git a/src/components/map/LocationInfo.tsx b/src/components/map/LocationInfo.tsx index 8e64071..ec953a7 100644 --- a/src/components/map/LocationInfo.tsx +++ b/src/components/map/LocationInfo.tsx @@ -79,7 +79,7 @@ const LocationInfo: React.FC<{}> = () => { setNotes(undefined); const metresPerDegree = 111111 * Math.cos((scope.center.lat * Math.PI) / 180); - const deltaDegrees = 1000 / metresPerDegree; + const deltaDegrees = 2000 / metresPerDegree; const response = await fetch( `https://api.openstreetmap.org/api/0.6/notes.json?bbox=${ scope.center.lon - deltaDegrees @@ -122,6 +122,31 @@ const LocationInfo: React.FC<{}> = () => { setNoteIndex(index); }; + const AvatarForFeature: React.FC<{ feature: any; as: any }> = (props: { + feature: any; + as: any; + }) => { + const distance = roughDistance(scope.center, { + lon: props.feature.geometry.coordinates[0], + lat: props.feature.geometry.coordinates[1], + }); + const distDark = (255 * distance) / 3000; + const distLight = 1 - distDark; + return ( + + ); + }; + return ( = () => { {notes === undefined && } - {notes !== undefined && ( - - - - {notes.features!.map((feature: any, index: number) => ( - - - - ))} - - - - - - - {i18n.locationInfo!.at!( - roughDistance(scope.center, { - lon: notes.features[noteIndex].geometry - .coordinates[0], - lat: notes.features[noteIndex].geometry - .coordinates[1], - }) - )} - - - - - - {notes.features[noteIndex].properties.comments.map( - (comment: any, index: number) => ( - 0 && ( +
+ + + + {notes.features!.map((feature: any, index: number) => ( + + + + ))} + + + + + + - - - - ) - )} - - - + {i18n.locationInfo!.at!( + roughDistance(scope.center, { + lon: notes.features[noteIndex].geometry + .coordinates[0], + lat: notes.features[noteIndex].geometry + .coordinates[1], + }) + )} + + + + + + {notes.features[noteIndex].properties.comments.map( + (comment: any, index: number) => ( + + + + + + ) + )} + + + +
)} diff --git a/src/theme/map.css b/src/theme/map.css index e10fecc..65c8ebe 100644 --- a/src/theme/map.css +++ b/src/theme/map.css @@ -91,3 +91,9 @@ ion-modal ion-content { .hidden { display: none; } + +@media (max-width: 576px) { + #chat-sidebar { + display: block; + } +}