Geolocation API in your browser or use a package on server-side
How to obtain latitude and longitude of user
https://api.darksky.net/forecast/[key]/[latitude],[longitude]
This Api i am using
You could do it with by passing the IP of the user to an API that will return you the latitute and longitude.
There are several services that offer this. Some of them are free with a maximum amount of calls per month and some of them are paid.
Just two of them
You can get the ip of the user with:
request()->ip();
// or
Request::ip();
how to get users IP
@m-rk:
request()->ip();
bear in mind that pulling it from IP address is about as accurate as asking the user what country they are in.
True that (and also good that it is not more accurate). But it is the most accurate you can get (as far as I know). And looking at the API the OP wants to use (weather) it is should not be a problem.
Is there any API that automatically detects user current location and display weather forecast because these two methods are not exactly identify user current location.
You could try the https://ipdata.co API, it's fast and has reliable performance. If you're interested in comparing the best Geolocation APIs, you could checkout this in-depth article - http://medium.com/@ipdata_co/what-is-the-best-commercial-ip-geolocation-api-d8195cda7027
Please or to participate in this conversation.