|
|
@ -1,4 +1,4 @@ |
|
|
|
import React, { useContext, useState } from "react"; |
|
|
|
import React, { useContext, useState, useEffect } from "react"; |
|
|
|
import { StyleSheet, View, Text, Image } from "react-native"; |
|
|
|
|
|
|
|
import colors from "../config/colors"; |
|
|
@ -14,7 +14,16 @@ import OpenStreetMap from "../components/map/OpenStreetMap"; |
|
|
|
|
|
|
|
const MapFormScreen = (props) => { |
|
|
|
const context = useContext(EventLocationContext); //local do evento
|
|
|
|
const contextLocation = useContext(CurrentLocationContext); //local do usuário
|
|
|
|
const [position, setPosition] = useState(null); |
|
|
|
const location = useContext(CurrentLocationContext).currentCoordinates; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setPosition({ |
|
|
|
lat: location["latitude"], |
|
|
|
long: location["longitude"], |
|
|
|
zoom: 16.5, |
|
|
|
}); |
|
|
|
}, [location]); |
|
|
|
|
|
|
|
const [moveEndListener, setMoveEndListener] = useState(""); |
|
|
|
console.log(moveEndListener); |
|
|
@ -39,23 +48,13 @@ const MapFormScreen = (props) => { |
|
|
|
props.navigation.goBack(null); |
|
|
|
}; |
|
|
|
|
|
|
|
const map_scale = 0.003; |
|
|
|
const lat_long_delta = { |
|
|
|
latitudeDelta: map_scale, |
|
|
|
longitudeDelta: map_scale * (screen_width / screen_height), |
|
|
|
}; |
|
|
|
|
|
|
|
const default_location = { |
|
|
|
latitude: -12.901799, |
|
|
|
longitude: -51.692116, |
|
|
|
latitudeDelta: 70, |
|
|
|
longitudeDelta: 70 * (screen_width / screen_height), |
|
|
|
}; |
|
|
|
return ( |
|
|
|
<View style={styles.container}> |
|
|
|
<OpenStreetMap |
|
|
|
style={styles.mapStyle} |
|
|
|
animateToPosition={position} |
|
|
|
moveEndListener={setMoveEndListener} |
|
|
|
|
|
|
|
/> |
|
|
|
<View style={styles.markerFixed}> |
|
|
|
<Image |
|
|
|