Các bác cho em hỏi. Em đã làm theo ví dụ trên mạng và lấy được tọa độ hiện tại của mình. Vậy có cách nào hiển thị tên nước dựa theo tọa độ đó ko ạ
có thể là phải sử dụng cả địa chỉ IP hay gì đó
import React, {Component} from 'react';
import {geolocated} from 'react-geolocated';
class App extends Component {
render() {
return !this.props.isGeolocationAvailable
? <div>Bs doesn't support Geolocation</div>
: !this.props.isGeolocationEnabled
? <div>Geolocation is not enabled</div>
: this.props.coords
? <table>
<tbody>
<tr>
<td>Latitude</td>
<td>{this.props.coords.latitude}</td>
</tr>
<tr>
<td>Longitude</td>
<td>{this.props.coords.longitude}</td>
</tr>
</tbody>
</table>
: <div>Getting the location data&hellip; </div>;
}
}
export default geolocated({
userDecisionTimeout: 5000,
})(App);
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?