salmanzafar/laravel-geocode
A Laravel Library to find Lat and Long of a given Specific Address
5,043
15
| Install | |
|---|---|
composer require salmanzafar/laravel-geocode |
|
| Latest Version: | v1.0.5 |
| PHP: | ^7.0 || ^7.1 || ^7.2 || ^7.3 || ^7.4 |
| License: | MIT |
| Last Updated: | May 17, 2022 |
| Links: | GitHub · Packagist |
Maintainer: salmanzafar949
laravel-geocode
Laravel Package to get Lat and Long from Specific Address.
Table of contents
Installation
composer require salmanzafar/laravel-geocode
Configuration
Publish the configuration file
php artisan vendor:publish --provider="Salman\GeoCode\GeoCodeServiceProvider"
Config/geocode.php
'API_KEY' => env('GOOGLE_GEOCODE_API_KEY', ''),
Enable the package (Optional)
This package implements Laravel auto-discovery feature
Usage
You need a Google map geocode api key in order to use this
Finding Coordinates
use Salman\GeoCode\Services\GeoCode;
public function lookForPoints()
{
$address = "1600 Amphitheatre Parkway,Mountain View";
$getPoints = new GeoCode();
return $getPoints->getLatAndLong($address);
}
Finding Coordinates using Facade
use GeoCode;
public function lookForPoints()
{
$address = "1600 Amphitheatre Parkway,Mountain View";
return GeoCode::getLatAndLong($address);
}
Finding Coordinates using Helper Function
public function lookForPoints()
{
$address = "1600 Amphitheatre Parkway,Mountain View";
return findAddressCoordinates($address);
}
Response
It will return a Laravel collection as response
{
"address_components": [
{
"long_name": "1600",
"short_name": "1600",
"types": [
"street_number"
]
},
{
"long_name": "Amphitheatre Parkway",
"short_name": "Amphitheatre Pkwy",
"types": [
"route"
]
},
{
"long_name": "Mountain View",
"short_name": "Mountain View",
"types": [
"locality",
"political"
]
},
{
"long_name": "Santa Clara County",
"short_name": "Santa Clara County",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "California",
"short_name": "CA",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "United States",
"short_name": "US",
"types": [
"country",
"political"
]
},
{
"long_name": "94043",
"short_name": "94043",
"types": [
"postal_code"
]
}
],
"formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
"geometry": {
"location": {
"lat": 37.4220579,
"lng": -122.0840897
},
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": 37.42340688029149,
"lng": -122.0827407197085
},
"southwest": {
"lat": 37.4207089197085,
"lng": -122.0854386802915
}
}
},
"place_id": "ChIJtYuu0V25j4ARwu5e4wwRYgE",
"plus_code": {
"compound_code": "CWC8+R9 Mountain View, CA, USA",
"global_code": "849VCWC8+R9"
},
"types": [
"street_address"
]
}
Related Packages
iisustudio/laravel-mqtt
A simple Laravel Library to connect/publish/subscribe to MQTT broker
4,711
0
salmanzafar/laravel-mqtt
A simple Laravel Library to connect/publish/subscribe to MQTT broker
160,337
102
laravel
laravel mqtt
laravel mqtt library
laravel-10
laravel-11
laravel-12
laravel-5
laravel-6
laravel-7
laravel-8
laravel-9
laravel-mqtt
laravel10
laravel11
laravel12
laravel5
laravel6
laravel7
laravel8
laravel9
mqtt laravel
mqtt-laravel
mqtt-laravel-publisher
mqtt-laravel-subscriber
php
php 7.4
php 8
php 8.1
php 8.2
php 8.3
php 8.4
gihan/invisible-captcha
Invisible reCAPTCHA For Laravel (Including 8). Forked albertcht/invisible-recapt...
1,232
3
salmanzafar/laravel-geo-fence
A Laravel Library to calculate distance between two longitude and latitudes
7,486
15