📅  最后修改于: 2022-03-11 15:02:10.831000             🧑  作者: Mango
import React from "react";import { geolocated } from "react-geolocated"; class Demo extends React.Component { render() { return !this.props.isGeolocationAvailable ? ( Your browser does not support Geolocation ) : !this.props.isGeolocationEnabled ? ( Geolocation is not enabled ) : this.props.coords ? ( latitude {this.props.coords.latitude} longitude {this.props.coords.longitude} altitude {this.props.coords.altitude} heading {this.props.coords.heading} speed {this.props.coords.speed}
) : ( Getting the location data… ); }} export default geolocated({ positionOptions: { enableHighAccuracy: false, }, userDecisionTimeout: 5000,})(Demo);