From e8e0cde79623108ba6c6a692eed378e27c6c3e37 Mon Sep 17 00:00:00 2001 From: Priyatham Sai chand Date: Sun, 15 May 2022 15:16:42 +0530 Subject: [PATCH] add marker to HouseLocation --- components/HouseLocation.js | 58 +++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/components/HouseLocation.js b/components/HouseLocation.js index 1e17eb3..53f82ae 100644 --- a/components/HouseLocation.js +++ b/components/HouseLocation.js @@ -1,6 +1,6 @@ import React from 'react'; -import {StyleSheet, View} from 'react-native'; -import MapView, {PROVIDER_GOOGLE} from 'react-native-maps'; // remove PROVIDER_GOOGLE import if not using Google Maps +import {StyleSheet, View, Text} from 'react-native'; +import MapView, {PROVIDER_GOOGLE, Marker, Callout} from 'react-native-maps'; // remove PROVIDER_GOOGLE import if not using Google Maps const styles = StyleSheet.create({ container: { ...StyleSheet.absoluteFillObject, @@ -16,18 +16,44 @@ const styles = StyleSheet.create({ }, }); -const HouseLocation = () => ( - - - -); +const HouseLocation = () => { + const [marker, setMarker] = React.useState({ + latitude: 37.78825, + longitude: -122.4324, + }); + return ( + + + { + setMarker({ + latitude: e.nativeEvent.coordinate.latitude, + longitude: e.nativeEvent.coordinate.longitude, + + }) + + + + }} + > + + {marker.latitude.toFixed(3)}, {marker.longitude.toFixed(3)} + + + + + + + ); +}; export default HouseLocation;