summaryrefslogtreecommitdiffstats
path: root/modules/Map.js
blob: a979424833974f4243f44d2478cca61edaf58c23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import MapView, { Marker } from 'react-native-maps'
import * as React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import AsyncStorage from "@react-native-async-storage/async-storage";

const L_KEY = 'locs_key'

export default function Home(props) {
  const [markers, setMarkers] = React.useState([])
  const startFn = async () => {
    setMarkers(JSON.parse(await AsyncStorage.getItem(L_KEY)))
  };
  React.useEffect(() => {startFn()}, [])
  return (
    <MapView
      style={{ flex: 1 }}
      initialRegion={{
        latitude: 49.9741841,
        longitude: 20.1000589,
        latitudeDelta: 0.001,
        longitudeDelta: 0.001,
      }}
    >
      {markers.filter(m => m.c).map(m => {
        return <Marker
          coordinate={{
            latitude: m.l.coords.latitude,
            longitude: m.l.coords.longitude,
          }}
          title={""}
          description={""}
          key={m.l.timestamp}
        />
      })}
    </MapView>
  )
}

const styles = StyleSheet.create({
  cont: {
    flexDirection: "column",
    marginTop: 10,
    paddingTop: 10,
    backgroundColor: "#3D54BB",
    justifyContent: "center",
    alignItems: "center",
    height: "100%",
  },
})