PHP code example of jensostertag / geocoding-util

1. Go to this page and download the library: Download jensostertag/geocoding-util 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/ */

    

jensostertag / geocoding-util example snippets




use jensostertag\Geocoding\Geocoding;

$geocoding = new Geocoding();
$geocoding->setStreet("James-Franck-Ring")
          ->setHouseNumber("1")
          ->setCity("Ulm")
          ->setZipCode("89081")
          ->setCountry("Germany");
$coordinates = $geocoding->getCoordinates();
$lat = $coordinates["latitude"];
$lng = $coordinates["longitude"];



use jensostertag\Geocoding\Geocoding;
    
$geocoding = new Geocoding();
$geocoding->setCoordinates(48.4253584, 9.956179)
          ->toAddress();
$address = $geocoding->getAddress();
$street = $address["street"];
$houseNumber = $address["houseNumber"];
$city = $address["city"];
$zipCode = $address["zipCode"];
$country = $address["country"];
$formattedAddress = $geocoding->getFormattedAddress();



use jensostertag\Geocoding\Geocoding;

Geocoding::setUserAgent("MyApplication/1.0");



use jensostertag\Geocoding\Geocoding;

Geocoding::setApiUrl("https://nominatim.mydomain.com");