Browse Source

Fixing frozen map in MapForm that occours in IOS.

master
GabrielTrettel 4 years ago
parent
commit
ef32644bd5
  1. 37
      src/app/screens/MapFormScreen.js

37
src/app/screens/MapFormScreen.js

@ -24,11 +24,7 @@ const MapFormScreen = (props) => {
const address = await Location.reverseGeocodeAsync(coordenadas); const address = await Location.reverseGeocodeAsync(coordenadas);
if (address[0] != undefined) { if (address[0] != undefined) {
context.saveNewLocation( context.saveNewLocation(
address[0].street +
", " +
address[0].name +
"\n" +
address[0].district,
address[0].street + ", " + address[0].name + "\n" + address[0].district,
coordenadas coordenadas
); );
} else { } else {
@ -48,16 +44,19 @@ const MapFormScreen = (props) => {
longitudeDelta: map_scale * (screen_width / screen_height), 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 ( return (
<View style={styles.container}> <View style={styles.container}>
<MapView <MapView
style={styles.mapStyle} style={styles.mapStyle}
showsUserLocation={true} showsUserLocation={true}
initialRegion={{
latitude: -23.533773,
longitude: -46.62529,
...lat_long_delta,
}}
initialRegion={{ ...default_location }}
region={{ region={{
latitude: marker.latitude, latitude: marker.latitude,
longitude: marker.longitude, longitude: marker.longitude,
@ -67,7 +66,7 @@ const MapFormScreen = (props) => {
console.log(r); console.log(r);
setMarker({ latitude: r.latitude, longitude: r.longitude }); setMarker({ latitude: r.latitude, longitude: r.longitude });
}} }}
></MapView>
/>
<View style={styles.markerFixed}> <View style={styles.markerFixed}>
<Image <Image
style={styles.marker} style={styles.marker}
@ -75,14 +74,8 @@ const MapFormScreen = (props) => {
source={require("../assets/map-marker.png")} source={require("../assets/map-marker.png")}
/> />
</View> </View>
<View
style={{
flexDirection: "column",
flex: 1,
justifyContent: "flex-end",
padding: 10,
}}
>
<View style={styles.submit_btn}>
<TouchableOpacity onPress={() => setLocation()}> <TouchableOpacity onPress={() => setLocation()}>
<View style={styles.button}> <View style={styles.button}>
<Text style={styles.text}>Confirmar</Text> <Text style={styles.text}>Confirmar</Text>
@ -94,6 +87,12 @@ const MapFormScreen = (props) => {
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
submit_btn: {
position: "absolute",
bottom: 0,
width: "100%",
padding: 20,
},
container: { container: {
backgroundColor: colors.black, backgroundColor: colors.black,
flex: 1, flex: 1,

Loading…
Cancel
Save