diff --git a/src/components/map/AvatarForLocation.tsx b/src/components/map/AvatarForLocation.tsx
index 5afa0cd..ec3fac8 100644
--- a/src/components/map/AvatarForLocation.tsx
+++ b/src/components/map/AvatarForLocation.tsx
@@ -1,11 +1,7 @@
-import { locationOutline } from 'ionicons/icons';
import React, { useId } from 'react';
-import { useSelector } from 'react-redux';
import { geoPoint, lat2tile, lon2tile, Point } from '../../lib/geo';
-import { MapState } from '../../store/map';
-import { getSTile } from './Reticle';
import { tileProviders } from './tile';
interface AvatarForLocationProps {
diff --git a/src/components/map/LocationInfo.tsx b/src/components/map/LocationInfo.tsx
index def0ea0..1de1cda 100644
--- a/src/components/map/LocationInfo.tsx
+++ b/src/components/map/LocationInfo.tsx
@@ -12,24 +12,12 @@ import {
IonSpinner,
} from '@ionic/react';
import React, { Fragment, useRef, useState } from 'react';
-import {
- MainContainer,
- Sidebar,
- ConversationList,
- Conversation,
- ConversationHeader,
- ChatContainer,
- MessageList,
- Message,
- Avatar,
-} from '@chatscope/chat-ui-kit-react';
-import '@chatscope/chat-ui-kit-styles/dist/default/styles.min.css';
import { useSelector } from 'react-redux';
import i18n from '../../i18n';
import { geoPoint } from '../../lib/geo';
import { MapState } from '../../store/map';
-import AvatarForLocation from './AvatarForLocation';
+import OsmNotesChat from './OsmNotesChat';
const LocationInfo: React.FC<{}> = () => {
const scope = useSelector((state: { map: MapState }) => state.map.scope);
@@ -72,10 +60,17 @@ const LocationInfo: React.FC<{}> = () => {
console.log(`address: ${JSON.stringify(data)}`);
setAddress(data);
};
+ const roughDistance = (a: geoPoint, b: geoPoint): number => {
+ const pseudoDistanceInDegrees = Math.sqrt(
+ (a.lat - b.lat) ** 2 + (a.lon - b.lon) ** 2
+ );
+ const metresPerDegree =
+ 111111 * Math.cos((scope.center.lat * Math.PI) / 180);
+ return pseudoDistanceInDegrees * metresPerDegree;
+ };
const findNotes = async () => {
setNotes(undefined);
- setNoteIndex(0);
const metresPerDegree =
111111 * Math.cos((scope.center.lat * Math.PI) / 180);
const deltaDegrees = 5000 / metresPerDegree;
@@ -109,15 +104,6 @@ const LocationInfo: React.FC<{}> = () => {
findNotes();
};
- const roughDistance = (a: geoPoint, b: geoPoint): number => {
- const pseudoDistanceInDegrees = Math.sqrt(
- (a.lat - b.lat) ** 2 + (a.lon - b.lon) ** 2
- );
- const metresPerDegree =
- 111111 * Math.cos((scope.center.lat * Math.PI) / 180);
- return pseudoDistanceInDegrees * metresPerDegree;
- };
-
const localDate = (isoDate: string) => {
const date = new Date(isoDate);
const format = new Intl.DateTimeFormat(i18n.getLanguage(), {
@@ -127,32 +113,12 @@ const LocationInfo: React.FC<{}> = () => {
return format.format(date);
};
- const [noteIndex, setNoteIndex] = useState(0);
- const conversationClickHandlerFactory = (index: number) => (event: any) => {
- setNoteIndex(index);
- };
-
- const AvatarForFeature: React.FC<{
- feature: any;
- size: number;
- as: any;
- }> = (props: { feature: any; size: number; as: any }) => {
- const distance = roughDistance(scope.center, {
- lon: props.feature.geometry.coordinates[0],
- lat: props.feature.geometry.coordinates[1],
- });
- return (
-
-
-
+ const osmNotesChat =
+ notes !== undefined && notes.features.length ? (
+
+ ) : (
+ <>>
);
- };
return (
= () => {
{notes === undefined && }
- {notes !== undefined && notes.features.length > 0 && (
-
-
-
-
-
-
-
-
- {i18n.locationInfo!.at!(
- roughDistance(scope.center, {
- lon: notes.features[noteIndex].geometry
- .coordinates[0],
- lat: notes.features[noteIndex].geometry
- .coordinates[1],
- })
- )}
-
-
-
-
- {noteIndex < notes.features.length &&
- notes.features[noteIndex].properties.comments.map(
- (comment: any, index: number) => (
-
-
-
-
- {comment.user ? comment.user : '??'}
-
-
- )
- )}
-
-
-
-
- )}
+ {osmNotesChat}