|
|
@@ -3,8 +3,20 @@ import { Text, View, StyleSheet } from "react-native"; |
|
|
|
// import Geocoder from "react-native-geocoder"; |
|
|
|
import MapView from "react-native-maps"; |
|
|
|
import Geolocation from "@react-native-community/geolocation"; |
|
|
|
import opencage from "opencage-api-client"; |
|
|
|
// import opencage from "opencage-api-client"; |
|
|
|
import { Marker } from "react-native-maps"; |
|
|
|
import { |
|
|
|
api_url1, |
|
|
|
address_list, |
|
|
|
address_delete, |
|
|
|
img_url, |
|
|
|
last_active_address, |
|
|
|
font_title, |
|
|
|
font_description, |
|
|
|
no_address_lottie, |
|
|
|
} from "../config/Constants"; |
|
|
|
import * as colors from "../assets/css/Colors"; |
|
|
|
import { Button } from "react-native-elements"; |
|
|
|
// import { address } from "../config/Constants"; |
|
|
|
|
|
|
|
export default class AddressMap extends Component { |
|
|
@@ -21,7 +33,7 @@ export default class AddressMap extends Component { |
|
|
|
|
|
|
|
this.handleUserNavigation(); |
|
|
|
|
|
|
|
this.getData(); |
|
|
|
// this.getData(); |
|
|
|
// this.onRegionChange(); |
|
|
|
// this.getAddress(this.state.latitude,this.state.longitude); |
|
|
|
} |
|
|
@@ -35,36 +47,36 @@ export default class AddressMap extends Component { |
|
|
|
|
|
|
|
getAddress = async(ny) => { |
|
|
|
|
|
|
|
await Geocoder.fallbackToGoogle('AIzaSyB_mBINSZ5m6dVyK6ANTLoEhkZq1nH9dG8'); |
|
|
|
try { |
|
|
|
let res = await Geocoder.geocodePosition(ny); |
|
|
|
let addr = res[0].formattedAddress; |
|
|
|
alert(addr); |
|
|
|
this.setState({ |
|
|
|
address: addr, |
|
|
|
}); |
|
|
|
} catch (err) { |
|
|
|
alert(err); |
|
|
|
} |
|
|
|
// await Geocoder.fallbackToGoogle('AIzaSyB_mBINSZ5m6dVyK6ANTLoEhkZq1nH9dG8'); |
|
|
|
// try { |
|
|
|
// let res = await Geocoder.geocodePosition(ny); |
|
|
|
// let addr = res[0].formattedAddress; |
|
|
|
// alert(addr); |
|
|
|
// this.setState({ |
|
|
|
// address: addr, |
|
|
|
// }); |
|
|
|
// } catch (err) { |
|
|
|
// alert(err); |
|
|
|
// } |
|
|
|
|
|
|
|
}; |
|
|
|
newOne=()=>{ |
|
|
|
const ny={lat:this.state.latitude,lng:this.state.latitude} |
|
|
|
this.getAddress(ny); |
|
|
|
} |
|
|
|
// newOne=()=>{ |
|
|
|
// const ny={lat:this.state.latitude,lng:this.state.latitude} |
|
|
|
// this.getAddress(ny); |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
getData=()=>{ |
|
|
|
Geocoder.setApiKey('AIzaSyB_mBINSZ5m6dVyK6ANTLoEhkZq1nH9dG8'); |
|
|
|
Geocoder.getFromLatLng(41.89,12.49).then( |
|
|
|
// getData=()=>{ |
|
|
|
// Geocoder.setApiKey('AIzaSyB_mBINSZ5m6dVyK6ANTLoEhkZq1nH9dG8'); |
|
|
|
// Geocoder.getFromLatLng(41.89,12.49).then( |
|
|
|
|
|
|
|
json=>{ |
|
|
|
var address_component=json.results[0].address_component[0] |
|
|
|
alert(address_component.long_name) |
|
|
|
} |
|
|
|
) |
|
|
|
// json=>{ |
|
|
|
// var address_component=json.results[0].address_component[0] |
|
|
|
// alert(address_component.long_name) |
|
|
|
// } |
|
|
|
// ) |
|
|
|
|
|
|
|
} |
|
|
|
// } |
|
|
|
|
|
|
|
// reverseGeocode = () => { |
|
|
|
// const key = "320646a99ec348baa3beb82943516ae6"; |
|
|
@@ -126,8 +138,8 @@ getData=()=>{ |
|
|
|
initialRegion={{ |
|
|
|
latitude: this.state.latitude, |
|
|
|
longitude: this.state.longitude, |
|
|
|
latitudeDelta: 0.0922, |
|
|
|
longitudeDelta: 0.0421, |
|
|
|
latitudeDelta: .001, |
|
|
|
longitudeDelta: .05, |
|
|
|
}} |
|
|
|
> |
|
|
|
<Marker |
|
|
@@ -139,6 +151,33 @@ getData=()=>{ |
|
|
|
description={(this.state.address) } |
|
|
|
/> |
|
|
|
</MapView> |
|
|
|
<View |
|
|
|
style={{ |
|
|
|
height:'20%',paddingHorizontal:22 |
|
|
|
}} |
|
|
|
> |
|
|
|
<Text |
|
|
|
style={{fontSize:23}} |
|
|
|
> |
|
|
|
Your location : {this.state.latitude} , {this.state.longitude} |
|
|
|
|
|
|
|
</Text> |
|
|
|
<Text |
|
|
|
style={styles.reg_style13} |
|
|
|
> |
|
|
|
|
|
|
|
Accuracy:({this.state.coords.accuracy}) |
|
|
|
</Text> |
|
|
|
<Button |
|
|
|
title="Next" |
|
|
|
onPress={()=>this.props.navigation.navigate('AddressEnter')} |
|
|
|
buttonStyle={{ |
|
|
|
backgroundColor: colors.theme_bg, |
|
|
|
fontFamily: font_title,}} |
|
|
|
titleStyle={{ color: colors.theme_bg_three, |
|
|
|
fontFamily: font_description,}} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
); |
|
|
|
} |
|
|
@@ -152,6 +191,8 @@ const styles = StyleSheet.create({ |
|
|
|
bottom: 0, |
|
|
|
alignItems: "center", |
|
|
|
justifyContent: "flex-end", |
|
|
|
height:'100%' |
|
|
|
|
|
|
|
}, |
|
|
|
mapStyle: { |
|
|
|
position: "absolute", |
|
|
@@ -159,5 +200,6 @@ const styles = StyleSheet.create({ |
|
|
|
left: 0, |
|
|
|
right: 0, |
|
|
|
bottom: 0, |
|
|
|
height:'80%' |
|
|
|
}, |
|
|
|
}); |