juskiewicz/geolocation

Biblioteka obsługująca Geocoding API firmy Google

v1.1 2018-11-14 19:27 UTC

This package is auto-updated.

Last update: 2025-03-17 01:52:34 UTC


README

Latest Stable Version License

Klasa Geolocation łączy się z Google Maps API i wyszukuje współrzędne lub adres.

Instalacja

Composer

Za pomocą Composer możesz zawsze pobrać najnowszą wersję.

composer require juskiewicz/geolocation

Sprawdź w Packagist.

Przykłady użycia

getCoordinatesByObject

Pobiera obiekt Coordinates za pomocą obiektu Address.

$streetName = 'Maltańska';
$streetNumber = '1',
$postalCode = '61-131',
$locality = 'Poznań',
$country = 'Polska',

$address = new Address(
    null,
    $streetName,
    $streetNumber,
    $postalCode,
    $locality,
    $country
);

$geolocation = new Geolocation('YOUR_GOOGLE_MAPS_API_KEY', 'pl', 'pl');
$coordinates = $coordinates = $geolocation->getCoordinatesByObject($address);

// Współrzędne
$latitude = $coordinates->getLatitude();
$longitude = $coordinates->getLongitude();
$tablica = $coordinates->toArray();

getCoordinatesByString

Pobiera obiekt Coordinates za pomocą stringu.

$address = "Maltańska 1, 61-131 Poznań, Polska";
$geolocation = new Geolocation('YOUR_GOOGLE_MAPS_API_KEY', 'pl', 'pl');
$coordinates = $geolocation->getCoordinatesByString($address);

getAddress

Pobiera obiekt Address za pomocą obiektu Coordinates.

$latitude = 51.8990865;
$longitude = 17.7863699;

$coordinates = new Coordinates($latitude, $longitude);

$geolocation = new Geolocation('YOUR_GOOGLE_MAPS_API_KEY','pl', 'pl');
$address = $geolocation->getAddress($coordinates);

Sprawdź źródło klasy Geolocation. Sprawdź źródło klasy Address. Sprawdź źródło klasy Coordinates.