Browse Source

Cambios para que funcione el mapa al ver citas pendientes

gilberto.cancel 2 years ago
parent
commit
77afadc0f2
1 changed files with 71 additions and 29 deletions
  1. 71
    29
      screens/main/Map.js

+ 71
- 29
screens/main/Map.js View File

@@ -5,47 +5,89 @@ import { Button, StyleSheet, Text, View, Dimensions, Pressable } from 'react-nat
5 5
 
6 6
 
7 7
 export default function Map({route, navigation} ) {
8
+    
9
+  console.log('In map params')
10
+  console.log(route.params)
11
+  
8 12
 
9 13
     
10 14
     const {
11 15
     Appointment = route.params.Appointment_Date ,
12 16
     int_id = route.params.int_id,
13
-    mapflag = route.params.Flag 
17
+    mapflag = route.params.Flag, 
18
+    i_token = route.params.I_Token,
19
+    u_token =  route.params.U_Token,
20
+    View_Only = route.params.View_Only
14 21
     } = route.params
15 22
     
16 23
 
17
-    console.log('In map params')
18
-    console.log(route.params)
24
+    
25
+
26
+  
27
+
28
+  if(View_Only == true){
29
+
30
+    const Retrive_pin = route.params.Pin;
31
+
32
+  console.log("Retrieve lat", Retrive_pin.Pin[0])
19 33
 
20
-  const [pin, setPin] = React.useState({
21
-    latitude: 18.4655,
22
-    longitude: -66.1057,
34
+  const [pin2, setPin2] = React.useState({
35
+    latitude: Retrive_pin.Pin[0],
36
+    longitude: Retrive_pin.Pin[1],
23 37
   })
24 38
 
39
+  console.log("Pin2", pin2)
25 40
   
26
-  return (
27
-    <View style={styles.container}>
28
-      <MapView style={styles.map}
29
-        initialRegion={{
30
-          latitude: 18.4655,
31
-          longitude: -66.1057,
32
-          latitudeDelta: 0.0922,
33
-          longitudeDelta: 0.0421,
34
-        }}
35
-        onLongPress={(e) => {
36
-          setPin({
37
-            latitude: e.nativeEvent.coordinate.latitude,
38
-            longitude: e.nativeEvent.coordinate.longitude
39
-          })}}
40
-        provider="google"
41
-      >
42
-        <Marker coordinate={pin} />
43
-      </MapView>
44
-        <View style = {{position: 'absolute', bottom: '5%'}}>
45
-            <Button title= 'Confirm Location' onPress = {() => navigation.navigate('StateTime' , {Pin : pin , Appointment : Appointment, int_id : int_id, mapflag : mapflag})}/>
46
-        </View>
47
-    </View>
48
-  );
41
+    return (
42
+      <View style={styles.container}>
43
+        <MapView style={styles.map}
44
+          initialRegion={{
45
+            latitude: pin2.latitude,
46
+            longitude: pin2.longitude,
47
+            latitudeDelta: 0.0922,
48
+            longitudeDelta: 0.0421,
49
+          }}
50
+          provider="google"
51
+        >
52
+          <Marker coordinate={pin2} />
53
+        </MapView>
54
+      </View>
55
+    );
56
+  }
57
+  else{
58
+
59
+    const [pin1, setPin1] = React.useState({
60
+      latitude: 18.4655,
61
+      longitude: -66.1057,
62
+    })
63
+
64
+    return (
65
+      <View style={styles.container}>
66
+        <MapView style={styles.map}
67
+          initialRegion={{
68
+            latitude: 18.4655,
69
+            longitude: -66.1057,
70
+            latitudeDelta: 0.0922,
71
+            longitudeDelta: 0.0421,
72
+          }}
73
+          onPress={(e) => {
74
+            setPin1({
75
+              latitude: e.nativeEvent.coordinate.latitude,
76
+              longitude: e.nativeEvent.coordinate.longitude
77
+            })
78
+          }}
79
+          
80
+          provider="google"
81
+        >
82
+          <Marker coordinate={pin1} />
83
+        </MapView>
84
+          <View style = {{position: 'absolute', bottom: '5%'}}>
85
+              <Button title= 'Confirm Location' onPress = {() => navigation.navigate('StateTime' , {Pin : pin1 , Appointment : Appointment, int_id : int_id, mapflag : mapflag, I_Token: i_token, U_Token: u_token})}/>
86
+          </View>
87
+      </View>
88
+      
89
+    );
90
+  }
49 91
 
50 92
     
51 93
 }