No Description

Map.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import * as React from 'react';
  2. import { useState } from 'react';
  3. import MapView, { Marker } from 'react-native-maps';
  4. import { Button, StyleSheet, Text, View, Dimensions, Pressable } from 'react-native';
  5. export default function Map({route, navigation} ) {
  6. const {
  7. Appointment = route.params.Appointment_Date ,
  8. int_id = route.params.int_id,
  9. mapflag = route.params.Flag
  10. } = route.params
  11. console.log('In map params')
  12. console.log(route.params)
  13. const [pin, setPin] = React.useState({
  14. latitude: 18.4655,
  15. longitude: -66.1057,
  16. })
  17. return (
  18. <View style={styles.container}>
  19. <MapView style={styles.map}
  20. initialRegion={{
  21. latitude: 18.4655,
  22. longitude: -66.1057,
  23. latitudeDelta: 0.0922,
  24. longitudeDelta: 0.0421,
  25. }}
  26. onLongPress={(e) => {
  27. setPin({
  28. latitude: e.nativeEvent.coordinate.latitude,
  29. longitude: e.nativeEvent.coordinate.longitude
  30. })}}
  31. provider="google"
  32. >
  33. <Marker coordinate={pin} />
  34. </MapView>
  35. <View style = {{position: 'absolute', bottom: '5%'}}>
  36. <Button title= 'Confirm Location' onPress = {() => navigation.navigate('StateTime' , {Pin : pin , Appointment : Appointment, int_id : int_id, mapflag : mapflag})}/>
  37. </View>
  38. </View>
  39. );
  40. }
  41. const styles = StyleSheet.create({
  42. container: {
  43. flex: 1,
  44. backgroundColor: '#fff',
  45. alignItems: 'center',
  46. justifyContent: 'center',
  47. },
  48. map: {
  49. width: Dimensions.get('window').width,
  50. height: Dimensions.get('window').height,
  51. },
  52. container2: {
  53. flex: 1,
  54. alignItems: 'center',
  55. justifyContent: 'center',
  56. backgroundColor: '#307ecc',
  57. padding: 16,
  58. },
  59. });