PHP code example of leroy-merlin-br / geo
1. Go to this page and download the library: Download leroy-merlin-br/geo 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/ */
leroy-merlin-br / geo example snippets
$regionMatcher = new LeroyMerlin\GeoTools\RegionMatcher;
$regionMatcher->loadRegion('/path/to/myRegion.kml');
$regionMatcher->loadRegion('/path/to/intersectingRegion.kml');
$regionMatcher->loadRegion('/path/to/farAwayRegion.kml');
$regionMatcher->getRegionsThatMatches(23, 23);
// returns ['myRegion', 'intersectingRegion']
$locator = new LeroyMerlin\GeoTools\IpLocator;
$locator->getLocation('208.80.152.201');
// array(
// 'as' => 'AS14907 Wikimedia Foundation Inc.',
// 'city' => 'San Francisco',
// 'country' => 'United States',
// 'countryCode' => 'US',
// 'isp' => 'Wikimedia Foundation',
// 'lat' => 37.7898,
// 'lon' => -122.3942,
// 'org' => 'Wikimedia Foundation',
// 'query' => '208.80.152.201',
// 'region' => 'CA',
// 'regionName' => 'California',
// 'status' => 'success',
// 'timezone' => 'America/Los_Angeles',
// 'zip' => '94105'
// )
$locator->getCoordinates('208.80.152.201');
// array(
// 'x' => 37.7898,
// 'y' => -122.3942
// )