1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-26 15:04:18 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/BoxVisualizationMap.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-05-20 09:39:40 +00:00
import React, { useContext } from "react"
import BoxMap from "../base/BoxMap"
import ContextLanguage from "../../contexts/ContextLanguage"
import { Marker, Popup } from "react-leaflet"
2021-05-21 14:37:30 +00:00
import { Location } from "../../utils/location"
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
2021-05-20 09:39:40 +00:00
2021-05-21 14:37:30 +00:00
export default function BoxVisualizationMap({ ...props }) {
2021-05-20 10:16:01 +00:00
const { strings } = useContext(ContextLanguage)
2021-05-21 14:37:30 +00:00
const {tweets} = useContext(ContextRepositoryViewer)
2021-05-20 09:39:40 +00:00
console.debug(tweets)
const markers = tweets.filter(tweet => tweet.location).map(tweet => {
2021-05-21 14:37:30 +00:00
const location = Location.fromTweet(tweet)
2021-05-20 09:39:40 +00:00
return (
2021-05-21 14:37:30 +00:00
<Marker key={tweet["snowflake"]} position={location.toArray()}>
2021-05-20 09:39:40 +00:00
<Popup>
<p>
{tweet["content"]}
</p>
<p>
<a href={`https://twitter.com/${tweet["poster"]}/status/${tweet["snowflake"]}`}>@{tweet["poster"]}</a>
</p>
</Popup>
</Marker>
)
})
return (
2021-05-20 16:28:08 +00:00
<BoxMap header={strings.visualMap} {...props}>
2021-05-20 09:39:40 +00:00
{markers}
</BoxMap>
)
}