Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markuskooche/geocode
A simple wrapper for (reverse) geocoding
https://github.com/markuskooche/geocode
geocode googlemaps laravel openstreetmap package php reverse
Last synced: 3 months ago
JSON representation
A simple wrapper for (reverse) geocoding
- Host: GitHub
- URL: https://github.com/markuskooche/geocode
- Owner: markuskooche
- License: mit
- Created: 2022-05-06T21:10:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-03T14:03:41.000Z (over 1 year ago)
- Last Synced: 2024-10-14T15:03:56.892Z (3 months ago)
- Topics: geocode, googlemaps, laravel, openstreetmap, package, php, reverse
- Language: PHP
- Homepage:
- Size: 118 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Geocode - A simple wrapper for (reverse) geocoding
## Installation
```
composer require markuskooche/geocode
```## Usage
### How to geocode
``` php
use Illuminate\Support\Collection;
use Markuskooche\Geocode\Geocode;// Get the longitude and latitude of a location.
$street = 'Pennsylvania Avenue Northwest';
$number = '1917';
$city = 'Washington';
$zip = '20500';
// You only need api key for the google maps driver.
// The standard driver will use the openstreet maps api.
$geocode = new Geocode();
$coordinates = $geocode->coordinates($street, $number, $city, $zip);
```
``` php
/**
* The coordinates is returned as a collection.
* @var Collection $coordinates
*/
$coordinates = [
'longitude' => '-77.037852'
'latitude' => '38.898556',
];
```### How to reverse geocode
``` php
use Illuminate\Support\Collection;
use Markuskooche\Geocode\Geocode;// Get the street, number, city and zip of a location.
$longitude = -77.0442641;
$latitude = 38.9004915;// You only need api key for the google maps driver.
// The standard driver will use the openstreet maps api.
$geocode = new Geocode();
$address = $geocode->address($longitude, $latitude);
```
``` php
/**
* The address is returned as a collection.
* @var Collection $address
*/
$address = [
'street' => 'Pennsylvania Avenue Northwest',
'number' => '1917',
'city' => 'Washington',
'zip' => '20500',
];
```### Export the configuration
``` php
php artisan vendor:publish --provider="Markuskooche\Geocode\GeocodeServiceProvider" --tag="config"
```## Licence
Geocode is an open-sourced software licensed under the [MIT license](LICENSE.md).