react-native-maps#MapEvent TypeScript Examples
The following examples show how to use
react-native-maps#MapEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From NextLevelWeek with MIT License | 6 votes |
SelectMapPosition: React.FC = () => {
const navigation = useNavigation();
const [position, setPosition] = useState({ latitude: 0, longitude: 0 });
function handleNextStep() {
navigation.navigate('OrphanageData', { position });
}
function handleSelectMapPosition(e: MapEvent) {
setPosition(e.nativeEvent.coordinate);
}
return (
<Container>
<Map
initialRegion={{
latitude: -5.8045832,
longitude: -35.1972851,
latitudeDelta: 0.060,
longitudeDelta: 0.060,
}}
onPress={handleSelectMapPosition}
>
{position.longitude !== 0 && (
<Marker
icon={mapMarkerImg}
coordinate={{ latitude: position.latitude, longitude: position.longitude }}
/>
)}
</Map>
{position.longitude !== 0 && (
<NextButton onPress={handleNextStep}>
<NextButtonText>Próximo</NextButtonText>
</NextButton>
)}
</Container>
);
}
Example #2
Source File: SelectMapPosition.tsx From happy with MIT License | 5 votes |
export default function SelectMapPosition() {
const navigation = useNavigation();
const [position, setPosition] = useState({ latitude: 0, longitude: 0});
function handleNextStep() {
navigation.navigate('OrphanageData', { position });
}
function handleSelectMapPosition(event: MapEvent) {
setPosition(event.nativeEvent.coordinate);
}
return (
<View style={styles.container}>
<MapView
initialRegion={{
latitude: -27.2092052,
longitude: -49.6401092,
latitudeDelta: 0.008,
longitudeDelta: 0.008,
}}
style={styles.mapStyle}
onPress={handleSelectMapPosition}
>
{position.latitude !== 0 && (
<Marker
icon={mapMarkerImg}
coordinate={{ latitude: position.latitude, longitude: position.longitude }}
/>
)}
</MapView>
{position.latitude !== 0 && (
<RectButton style={styles.nextButton} onPress={handleNextStep}>
<Text style={styles.nextButtonText}>Próximo</Text>
</RectButton>
)}
</View>
)
}
Example #3
Source File: SelectMapPosition.tsx From nlw-03-omnistack with MIT License | 5 votes |
export default function SelectMapPosition() {
const navigation = useNavigation();
const [position, setPosition] = useState({ latitude: 0, longitude: 0});
function handleSelectMapPosition(event: MapEvent) {
setPosition(event.nativeEvent.coordinate);
}
function handleNextStep() {
navigation.navigate('OrphanageData', { position });
}
return (
<View style={styles.container}>
<MapView
initialRegion={{
latitude: -27.2092052,
longitude: -49.6401092,
latitudeDelta: 0.008,
longitudeDelta: 0.008,
}}
onPress={handleSelectMapPosition}
style={styles.mapStyle}
>
{ !!position.latitude && (
<Marker
icon={mapMarkerImg}
coordinate={position}
/>
)}
</MapView>
{ !!position.latitude && (
<RectButton style={styles.nextButton} onPress={handleNextStep}>
<Text style={styles.nextButtonText}>Próximo</Text>
</RectButton>
)}
</View>
)
}