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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…