can anyone help me or give me solution to get value of
"position.coords.latitude"
i want that value update this.state "city" after user click button
class Home extends Component{
constructor(props){
super(props)
this.state = {
city: '',
lats : '',
long : ''
}
this.Kirim = this.Kirim.bind(this)
}
Kirim() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(Position){
this.setState({ city:position.coords.latitude}) // erorr here
})
} else {
}
}
render(){
let {city} = this.state
console.log(city)
return(
<Fragment>
<div className="form-add">
<button onClick={this.Kirim}>Kirim</button>
</div>
</Fragment>
)
}
}