No Description

Map.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import * as React from 'react';
  2. import MapView, { Marker } from 'react-native-maps';
  3. import { StyleSheet, Text, View, Dimensions, Pressable } from 'react-native';
  4. export default function Map() {
  5. const [pin, setPin] = React.useState({
  6. latitude: 18.4655,
  7. longitude: -66.1057,
  8. })
  9. return (
  10. <View style={styles.container}>
  11. <MapView style={styles.map}
  12. initialRegion={{
  13. latitude: 18.4655,
  14. longitude: -66.1057,
  15. latitudeDelta: 0.0922,
  16. longitudeDelta: 0.0421,
  17. }}
  18. onLongPress={(e) => {
  19. setPin({
  20. latitude: e.nativeEvent.coordinate.latitude,
  21. longitude: e.nativeEvent.coordinate.longitude
  22. })}}
  23. provider="google"
  24. >
  25. <Marker coordinate={pin} />
  26. </MapView>
  27. </View>
  28. );
  29. }
  30. const styles = StyleSheet.create({
  31. container: {
  32. flex: 1,
  33. backgroundColor: '#fff',
  34. alignItems: 'center',
  35. justifyContent: 'center',
  36. },
  37. map: {
  38. width: Dimensions.get('window').width,
  39. height: Dimensions.get('window').height,
  40. },
  41. });