From 8ce460a7de65dac68fd1d57d973b5c101890dd65 Mon Sep 17 00:00:00 2001 From: rheo-chiti Date: Tue, 31 Mar 2020 01:17:44 +0530 Subject: [PATCH] View all reports worldwide --- js/components/reports/AllReports.js | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 js/components/reports/AllReports.js diff --git a/js/components/reports/AllReports.js b/js/components/reports/AllReports.js new file mode 100644 index 0000000..c7d774f --- /dev/null +++ b/js/components/reports/AllReports.js @@ -0,0 +1,74 @@ +import React from 'react'; +import MapView from 'react-native-maps'; +import { StyleSheet, View } from 'react-native'; +import firebase from 'firebase' +import '@firebase/firestore'; + +export default class AllReports extends React.Component { + state = { + markers: [], + reports: [] + } + + componentDidMount() { + reports = [] + markers = [] + const ref = firebase.firestore().collection('reports') + let allReports = ref.get().then(snapshot => { + snapshot.forEach(doc => { + reports.push(doc.data()) + let marker = { + title: doc.data().disease, + coordinate: { + latitude: doc.data().latitude, + longitude: doc.data().longitude + }, + description: doc.data().name + } + markers.push(marker) + }) + this.setState({ reports: reports, markers: markers }) + + }) + } + + render() { + return ( + + + {this.state.markers.map(marker => ( + + ))} + + + ); + } +} + +var styles = StyleSheet.create({ + + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: '#F5FCFF', + }, + map: { + position: 'absolute', + top: 0, + left: 0, + right: 0, + bottom: 0, + } +});