I am working on the geolocation code, on android studio using windows. But for some reason my present location is not being picked. I tried to use other options like enableHighAccuracy:false. also tried to run Telnet, and apply geo fix long lat, but nothing happens.
Please see relevant code that actually works when i tested on expo snacks.
findCurrentLocationAsync=()=>{
navigator.geolocation.getCurrentPosition(
(position) => {
// console.log(position);
let lat=position.coords.latitude;
let long=position.coords.longitude;
this.setState({
markerPosition: {
lat: lat,
lng: long
},
mapPosition: {
latitude: lat,
longitude: long,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}
});
Geocoder.from( this.state.mapPosition.latitude , this.state.mapPosition.longitude ).then(
response => {
const address = response.results[0].formatted_address,
addressArray = response.results[0].address_components,
city = this.getCity( addressArray ),
area = this.getArea( addressArray ),
state = this.getState( addressArray );
zip = this.getZip( addressArray );
console.log(addressArray)
this.setState( {
address: ( address ) ? address : '',
area: ( area ) ? area : '',
city: ( city ) ? city : '',
state: ( state ) ? state : '',
zip: ( zip ) ? zip : '',
} )
},
error => {
// console.error( error );
}
)
},
//{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 },
///()=>console.log(lat)
);
};
I would appreciate suggestions
thanks sal
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.