Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

javascript - geo location is not working on chrome browser

I want to use geo location to show content on the screen if user gave permission,

it worked fine but suddenly it does not work any more

it works fine in firefox

also does not work in the google map either, so i think it is not because of insecure websites

I'm using GeoLocated package

here is the code

const AddUserPage = ({ coords, isGeolocationEnabled }) => {
  const [location, setLocation] = useState(null)
  useEffect(() => {
    if (coords) {
      setLocation({ lat: coords.latitude, lng: coords.longitude })
    }

  }, [coords])

  const changeLocation = (location) => {
   setLocation(location)
  }

  if (!isGeolocationEnabled) {
    return <div>fuck you</div>
  }
  if (coords) {
    return (
      <div style={{ width: '300px', height: "300pc" }}>
        <UserMap changeLocation={changeLocation} lat={coords.latitude} lng={coords.longitude}></UserMap>
        <Button onClick={()=>{
          console.log(location)
        }}>current location</Button>
      </div>
    );
  }
  return <div>nslknl;ij'poj</div>
};

export default geolocated({
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
})(AddUserPage);
question from:https://stackoverflow.com/questions/65837936/geo-location-is-not-working-on-chrome-browser

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...