parent
cb37a9b695
commit
78cdabb260
7 changed files with 76 additions and 199 deletions
@ -1,49 +1,49 @@ |
||||
import React from "react"; |
||||
import MapView, { Marker } from "react-native-maps"; |
||||
// import React from "react";
|
||||
// import MapView, { Marker } from "react-native-maps";
|
||||
|
||||
//assets
|
||||
import markerIcon from "../assets/icons/marker.png"; |
||||
// //assets
|
||||
// import markerIcon from "../assets/icons/marker.png";
|
||||
|
||||
export default function MapSelector({ setAddress }) { |
||||
const [markerCoordinates, setMarkerCoordinates] = React.useState({ |
||||
latitude: 35.7219, |
||||
longitude: 51.3347, |
||||
}); |
||||
const getLocation = (location) => { |
||||
setMarkerCoordinates(location); |
||||
try { |
||||
fetch( |
||||
`https://map.ir/reverse/no?lat=${location.latitude}&lon=${location.longitude}`, |
||||
{ |
||||
headers: { |
||||
"Content-Type": "application/json", |
||||
"x-api-key": |
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIn0.eyJhdWQiOiIxNjk2MSIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIiwiaWF0IjoxNjQ0MzE3MDA5LCJuYmYiOjE2NDQzMTcwMDksImV4cCI6MTY0NjgyMjYwOSwic3ViIjoiIiwic2NvcGVzIjpbImJhc2ljIl19.Gckmd77Vw-wmsaztsmVmjYmfp4zXRSy2f0tXS-1p7IY8VJmvCCrk64y7WvCLbH0YfGZI9rG9ZUi5hRJDDGXu70l1ZafCYq2-EkMzcbx-PGTTq2bHGNZujF4ur1xtGoXd2kwGuldiR_6SJdqYLHcupbscFI7hHaQnkN1xWJ-L8476ZOKzUgiBvwH9uElGZXwD6SwfXoGW_R38_isrnfTXKfW9PPixyLaN3404tcjOU1r02HIurrplXlIKRKG9CVXxKsESfJJ8trwtZw6O4erxrnisxfL0VwAR7l69P6KcFb57vvM4j4hKFqxUDr4YvSq1qOTt3urYbAKehhvoiLhZxw", |
||||
}, |
||||
} |
||||
) |
||||
.then((response) => response.json()) |
||||
.then((data) => setAddress(data.address)); |
||||
} catch (err) { |
||||
console.log(err); |
||||
} |
||||
}; |
||||
// export default function MapSelector({ setAddress }) {
|
||||
// const [markerCoordinates, setMarkerCoordinates] = React.useState({
|
||||
// latitude: 35.7219,
|
||||
// longitude: 51.3347,
|
||||
// });
|
||||
// const getLocation = (location) => {
|
||||
// setMarkerCoordinates(location);
|
||||
// try {
|
||||
// fetch(
|
||||
// `https://map.ir/reverse/no?lat=${location.latitude}&lon=${location.longitude}`,
|
||||
// {
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// "x-api-key":
|
||||
// "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIn0.eyJhdWQiOiIxNjk2MSIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIiwiaWF0IjoxNjQ0MzE3MDA5LCJuYmYiOjE2NDQzMTcwMDksImV4cCI6MTY0NjgyMjYwOSwic3ViIjoiIiwic2NvcGVzIjpbImJhc2ljIl19.Gckmd77Vw-wmsaztsmVmjYmfp4zXRSy2f0tXS-1p7IY8VJmvCCrk64y7WvCLbH0YfGZI9rG9ZUi5hRJDDGXu70l1ZafCYq2-EkMzcbx-PGTTq2bHGNZujF4ur1xtGoXd2kwGuldiR_6SJdqYLHcupbscFI7hHaQnkN1xWJ-L8476ZOKzUgiBvwH9uElGZXwD6SwfXoGW_R38_isrnfTXKfW9PPixyLaN3404tcjOU1r02HIurrplXlIKRKG9CVXxKsESfJJ8trwtZw6O4erxrnisxfL0VwAR7l69P6KcFb57vvM4j4hKFqxUDr4YvSq1qOTt3urYbAKehhvoiLhZxw",
|
||||
// },
|
||||
// }
|
||||
// )
|
||||
// .then((response) => response.json())
|
||||
// .then((data) => setAddress(data.address));
|
||||
// } catch (err) {
|
||||
// console.log(err);
|
||||
// }
|
||||
// };
|
||||
|
||||
return ( |
||||
<MapView |
||||
initialRegion={{ |
||||
latitude: 35.7219, |
||||
longitude: 51.3347, |
||||
latitudeDelta: 0.0922, |
||||
longitudeDelta: 0.0421, |
||||
}} |
||||
style={{ |
||||
width: "100%", |
||||
height: "100%", |
||||
}} |
||||
onPress={(e) => getLocation(e.nativeEvent.coordinate)} |
||||
> |
||||
<Marker coordinate={markerCoordinates} image={markerIcon} /> |
||||
</MapView> |
||||
); |
||||
} |
||||
// return (
|
||||
// <MapView
|
||||
// initialRegion={{
|
||||
// latitude: 35.7219,
|
||||
// longitude: 51.3347,
|
||||
// latitudeDelta: 0.0922,
|
||||
// longitudeDelta: 0.0421,
|
||||
// }}
|
||||
// style={{
|
||||
// width: "100%",
|
||||
// height: "100%",
|
||||
// }}
|
||||
// onPress={(e) => getLocation(e.nativeEvent.coordinate)}
|
||||
// >
|
||||
// <Marker coordinate={markerCoordinates} image={markerIcon} />
|
||||
// </MapView>
|
||||
// );
|
||||
// }
|
||||
|
Loading…
Reference in new issue