diff --git a/src/app/screens/MapFeedScreen.js b/src/app/screens/MapFeedScreen.js index dc072e0..42359ae 100644 --- a/src/app/screens/MapFeedScreen.js +++ b/src/app/screens/MapFeedScreen.js @@ -1,73 +1,33 @@ -import React, { useRef, useState } from "react"; -import { Button, StyleSheet, Text, TouchableOpacity, View } from "react-native"; +import React, { useState, useEffect, useContext } from "react"; +import { StyleSheet, Text, TouchableOpacity, View } from "react-native"; import OpenStreetMap from "../components/map/OpenStreetMap"; -import assets from "../config/assets" +import { CurrentLocationContext } from "../context/CurrentLocationContext"; export default function MapFeedScreen() { const [position, setPosition] = useState(null); const [clickListener, setClickListener] = useState(""); const [markerListener, setMarkerListener] = useState(""); - console.log(clickListener); + const context = useContext(CurrentLocationContext); + const location = context.currentCoordinates; + + useEffect(() => { + setPosition({ + lat: location["latitude"], + long: location["longitude"], + zoom: 16.5, + }); + }, [location]); + - const markers = [ - { - ID: "1", - title: "Casa da LĂ­via", - cords: { - lat: 51.505, - long: -0.09, - }, - icon: require("../components/map/icon.html"), - }, - { - ID: "2", - title: "Casa do Daniel", - icon: ` `, - cords: { - lat: 51.5032, - long: -0.09589, - }, - }, - { - ID: "3", - title: "Casa do Gabriel", - icon: ` `, - cords: { - lat: 51.509, - long: -0.09581, - }, - }, - ]; return ( - - { - setPosition({ lat: -23.644957, long: -46.528012, zoom: 10 }); - }} - > - UFABC - - - { - setPosition({ lat: 51.505, long: -0.09, zoom: 14 }); - }} - > - Londres - - - {JSON.stringify(clickListener)} {JSON.stringify(markerListener)} @@ -111,3 +71,4 @@ const styles = StyleSheet.create({ color: "white", }, }); +