1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import * as React from 'react';
- import MapView, { Marker } from 'react-native-maps';
- import { StyleSheet, Text, View, Dimensions, Pressable } from 'react-native';
-
- export default function Map() {
- const [pin, setPin] = React.useState({
- latitude: 18.4655,
- longitude: -66.1057,
- })
-
- return (
- <View style={styles.container}>
- <MapView style={styles.map}
- initialRegion={{
- latitude: 18.4655,
- longitude: -66.1057,
- latitudeDelta: 0.0922,
- longitudeDelta: 0.0421,
- }}
- onLongPress={(e) => {
- setPin({
- latitude: e.nativeEvent.coordinate.latitude,
- longitude: e.nativeEvent.coordinate.longitude
- })}}
- provider="google"
- >
- <Marker coordinate={pin} />
- </MapView>
- </View>
- );
- }
-
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#fff',
- alignItems: 'center',
- justifyContent: 'center',
- },
- map: {
- width: Dimensions.get('window').width,
- height: Dimensions.get('window').height,
- },
- });
|