Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Website freezes when location is disabled. #2

Open
BishamKunwor opened this issue Apr 4, 2023 · 5 comments
Open

BUG: Website freezes when location is disabled. #2

BishamKunwor opened this issue Apr 4, 2023 · 5 comments

Comments

@BishamKunwor
Copy link

BishamKunwor commented Apr 4, 2023

When location is enabled, the application is working fine.

Before:

image

After Location is turned off:

image

End Result:

image

@Ahadkhan-12
Copy link
Owner

Ahadkhan-12 commented Apr 6, 2023

Do u have any fix for this. We can set a default location for this but in that case the browser doesnt ask for permission , the user when turn on location and reload the location will update . Any suggestion?
@BishamKunwor

@Ahadkhan-12
Copy link
Owner

@BishamKunwor Do u have any idea what can we do to solve this issue?

@BishamKunwor
Copy link
Author

Here Are the steps for How I'd go about solving the Issue.

  1. Check If Browser permitted our app to use the user's location. If so then use the location.
  2. If the Browser did not let us have user's location then I'd use their IP and get location from the IP and use it as It is better than Default location which is static.
  3. Lastly, I'd check if we have grabbed IP from 1 and 2 step. If there is issue in both steps (API failure) then I'd set a default location to avoid any error while page loads.

@Ahadkhan-12 Feel free to suggest If I'd missed something.

@Ahadkhan-12
Copy link
Owner

Ahadkhan-12 commented Apr 9, 2023

For point 1 : I tired to do that but failed to do so .
For point 3 : I have set lat and lng for Delhi as default input. Which solve the Website freezing .

For point 1 : Can u provide how to proceed with that , i cant find good reference to implement it.
@BishamKunwor

@BishamKunwor
Copy link
Author

BishamKunwor commented Apr 11, 2023

This guide should cover all that is required by you
https://www.javascripttutorial.net/web-apis/javascript-geolocation/

Your code only handles success case but not error case as seen in useEffect hook

image

set a callback for when the location permission is denied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants