AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Google maps ip address location3/14/2024 So, it is reliable to a certain level, if you want to get your city name, you can use it, but if you want an accurate position, I don’t recommend it, you can use Google Maps API instead as it has a more accurate way of Geolocation. If you’ve tried it, you’ll notice that the location given by IP address is not so accurate, you can read the reason here. Then, you can see your location info and direct it to Google Maps! DownsideĪs I’ve mentioned, there’s a downside to this method. Other tutorials I’ve read told me to register the package class in config/app.php, but since the documentation said we can skip it if we use Laravel 5.5 or above, I did and it worked normally.īut if you’re using below Laravel 5.5, then please add or modify these lines in config/app.php. Php artisan vendor:publish -provider="Stevebauman\Location\LocationServiceProvider" To install the package, you just have to run 2 commands (assuming you’re using Laravel 5.5 or above) composer require stevebauman/location It is very useful to get user location by IP so you don’t have to use Google Maps API, but after I’ve tried it myself (so you don’t have to), there’s a downside to this method which I’ll discuss later below. We’ll use stevebauman’s location package (You can check the documentation here). composer create-project laravel/laravel laravel-get-location 2. If you want more detail about creating a Laravel project, you can read my other post, but this command is enough. These are the steps we’ll take :įirst things first, of course we have to create a Laravel project with this command. If that’s the case, I’m gonna show you how you can do it with a Laravel package. But what if you don’t want to trouble yourself with getting the API key and paying to use the API? Getting user location is important for a lot of applications and the most obvious way to do it is using Google Maps API.
0 Comments
Read More
Leave a Reply. |