parent
2611d03510
commit
b93c1a351d
9 changed files with 112 additions and 64 deletions
After Width: | Height: | Size: 3.2 KiB |
@ -1,22 +1,49 @@ |
|||||||
import React from "react"; |
import React from "react"; |
||||||
// import Mapir from "mapir-react-native-sdk";
|
import MapView, { Marker } from "react-native-maps"; |
||||||
|
|
||||||
// const X_API_KEY =
|
//assets
|
||||||
// "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIn0.eyJhdWQiOiIxNjk2MSIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIiwiaWF0IjoxNjQ0MzE3MDA5LCJuYmYiOjE2NDQzMTcwMDksImV4cCI6MTY0NjgyMjYwOSwic3ViIjoiIiwic2NvcGVzIjpbImJhc2ljIl19.Gckmd77Vw-wmsaztsmVmjYmfp4zXRSy2f0tXS-1p7IY8VJmvCCrk64y7WvCLbH0YfGZI9rG9ZUi5hRJDDGXu70l1ZafCYq2-EkMzcbx-PGTTq2bHGNZujF4ur1xtGoXd2kwGuldiR_6SJdqYLHcupbscFI7hHaQnkN1xWJ-L8476ZOKzUgiBvwH9uElGZXwD6SwfXoGW_R38_isrnfTXKfW9PPixyLaN3404tcjOU1r02HIurrplXlIKRKG9CVXxKsESfJJ8trwtZw6O4erxrnisxfL0VwAR7l69P6KcFb57vvM4j4hKFqxUDr4YvSq1qOTt3urYbAKehhvoiLhZxw";
|
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() { |
|
||||||
onRegionDidChange = (e) => {}; |
|
||||||
return ( |
return ( |
||||||
<></> |
<MapView |
||||||
// <Mapir
|
initialRegion={{ |
||||||
// apiKey={X_API_KEY}
|
latitude: 35.7219, |
||||||
// onRegionDidChange={(e) => onRegionDidChange(e)}
|
longitude: 51.3347, |
||||||
// style={{
|
latitudeDelta: 0.0922, |
||||||
// width : '100%',
|
longitudeDelta: 0.0421, |
||||||
// height : 250
|
}} |
||||||
// }}
|
style={{ |
||||||
// >
|
width: "100%", |
||||||
// <Mapir.Camera zoomLevel={13} centerCoordinate={[51.422548, 35.732573]} />
|
height: "100%", |
||||||
// </Mapir>
|
}} |
||||||
|
onPress={(e) => getLocation(e.nativeEvent.coordinate)} |
||||||
|
> |
||||||
|
<Marker coordinate={markerCoordinates} image={markerIcon} /> |
||||||
|
</MapView> |
||||||
); |
); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue