📜  从 brwoser react 获取位置 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:10.831000             🧑  作者: Mango

代码示例2
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);