我已经通过使用react-geolocated显示了纬度和经度。现在,我想和他们一起显示我的国家名称。我能怎么做?也许我必须使用IP地址或其他名称。这是我的代码:
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 isn't 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… </div>;
}
}
export default geolocated({
userDecisionTimeout: 5000,
})(App);