1. Go to this page and download the library: Download sslah/location-finder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sslah / location-finder example snippets
use LocationFinder;
// Search for locations
$results = LocationFinder::search('ankara');
// Geocode an address to get coordinates
$location = LocationFinder::geocode('Kızılay, Ankara');
// Reverse geocode coordinates to get address
$address = LocationFinder::reverseGeocode(39.9208, 32.8541);
use Sslah\LocationFinder\Services\GeocodingService;
class LocationController
{
public function __construct(private GeocodingService $locationFinder)
{
}
public function search(Request $request)
{
$results = $this->locationFinder->search($request->query);
return response()->json($results);
}
}
// In your AppServiceProvider
use Sslah\LocationFinder\Services\GeocodingService;
public function boot()
{
$this->app->bind(GeocodingService::class, function ($app) {
return new GeocodingService([
'country_code' => 'us',
'language' => 'en',
'max_results' => 5,
]);
});
}
use Sslah\LocationFinder\Services\GeocodingService;
class MyController extends Controller
{
public function search(Request $request, GeocodingService $geocoding)
{
$results = $geocoding->search($request->input('query'));
return response()->json($results);
}
}
bash
php artisan location-finder:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.