@ -9,6 +9,7 @@ import * as Location from "expo-location";
import { EventLocationContext } from "../context/EventLocationContext" ;
import { EventLocationContext } from "../context/EventLocationContext" ;
import { TouchableOpacity } from "react-native-gesture-handler" ;
import { TouchableOpacity } from "react-native-gesture-handler" ;
import { CurrentLocationContext } from "../context/CurrentLocationContext" ;
import { CurrentLocationContext } from "../context/CurrentLocationContext" ;
import OpenStreetMap from "../components/map/OpenStreetMap" ;
// NOTE: Implementação posterior: É interessante adcionar um searchBox para que o usuário busque um endereço (google places autocomplete é uma api paga)
// NOTE: Implementação posterior: É interessante adcionar um searchBox para que o usuário busque um endereço (google places autocomplete é uma api paga)
@ -18,6 +19,10 @@ const MapFormScreen = (props) => {
const [ marker , setMarker ] = useState ( context . eventCoordinates ) ;
const [ marker , setMarker ] = useState ( context . eventCoordinates ) ;
const [ moveEndListener , setMoveEndListener ] = useState ( "" ) ;
console . log ( moveEndListener ) ;
const getAddress = async ( coordenadas ) => {
const getAddress = async ( coordenadas ) => {
Location . setGoogleApiKey ( "AIzaSyD_wuuokS3SVczc8qSASrsBq0E5qIpdyMc" ) ;
Location . setGoogleApiKey ( "AIzaSyD_wuuokS3SVczc8qSASrsBq0E5qIpdyMc" ) ;
@ -34,7 +39,7 @@ const MapFormScreen = (props) => {
} ;
} ;
const setLocation = ( ) => {
const setLocation = ( ) => {
getAddress ( mark er ) ;
getAddress ( moveEndListen er ) ;
props . navigation . goBack ( null ) ;
props . navigation . goBack ( null ) ;
} ;
} ;
@ -51,9 +56,15 @@ const MapFormScreen = (props) => {
longitudeDelta : 70 * ( screen_width / screen_height ) ,
longitudeDelta : 70 * ( screen_width / screen_height ) ,
} ;
} ;
return (
return (
< View style = { styles . container } >
< View style = { styles . container } >
< MapView
< OpenStreetMap
moveEndListener = { setMoveEndListener }
/ >
{ / * < M a p V i e w
style = { styles . mapStyle }
style = { styles . mapStyle }
showsUserLocation = { true }
showsUserLocation = { true }
initialRegion = { { ... default_location } }
initialRegion = { { ... default_location } }
@ -66,14 +77,14 @@ const MapFormScreen = (props) => {
// console.log(r);
// console.log(r);
setMarker ( { latitude : r . latitude , longitude : r . longitude } ) ;
setMarker ( { latitude : r . latitude , longitude : r . longitude } ) ;
} }
} }
/ >
< View style = { styles . markerFixed } >
/>*/ }
{ / * < V i e w s t y l e = { s t y l e s . m a r k e r F i x e d } >
< Image
< Image
style = { styles . marker }
style = { styles . marker }
resizeMode = "contain"
resizeMode = "contain"
source = { require ( "../assets/map-marker.png" ) }
source = { require ( "../assets/map-marker.png" ) }
/ >
/ >
< / V i e w >
< /View>*/ }
< View style = { styles . submit_btn } >
< View style = { styles . submit_btn } >
< TouchableOpacity onPress = { ( ) => setLocation ( ) } >
< TouchableOpacity onPress = { ( ) => setLocation ( ) } >
@ -116,12 +127,14 @@ const styles = StyleSheet.create({
} ,
} ,
markerFixed : {
markerFixed : {
left : "50%" ,
left : "50%" ,
marginLeft : - 24 ,
marginLeft : - 19 ,
marginTop : - 48 ,
marginTop : - 48 ,
alignItems : "center" ,
position : "absolute" ,
position : "absolute" ,
top : "50%" ,
height : 48 ,
width : 48 ,
bottom : "50%" ,
top : "50%" ,
height : "20%" ,
width : 38 ,
} ,
} ,
text : {
text : {
color : colors . white ,
color : colors . white ,
@ -130,8 +143,17 @@ const styles = StyleSheet.create({
fontWeight : "bold" ,
fontWeight : "bold" ,
} ,
} ,
marker : {
marker : {
height : 48 ,
width : 48 ,
height : "40%" ,
alignSelf : "center" ,
width : 38 ,
} ,
callback : {
bottom : 100 ,
alignSelf : "center" ,
alignItems : "center" ,
backgroundColor : "gray" ,
width : "80%" ,
padding : 10 ,
} ,
} ,
} ) ;
} ) ;