1.0-beta
2016-05-20 17:42 UTC
Requires
- curl/curl: ~1.1.0
- icecave/isolator: ~3.0.3
- phayes/geophp: dev-master
- vlucas/phpdotenv: ^1.1|^2.0
Requires (Dev)
- mockery/mockery: ~0.9.1
- phpunit/phpunit: ~4.3
This package is auto-updated.
Last update: 2022-02-01 12:46:10 UTC
README
leroy-merlin-br/geo
是一套简单易用的地理位置工具。它建立在强大的 phayes/geophp
之上。
地区匹配
使用 LeroyMerlin\GeoTools\RegionMatcher
,你可以轻松地测试一个坐标是否在某个地区内。
使用示例
$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']
IP到地理位置
LeroyMerlin\GeoTools\IpLocator
使用 ip-api.com 来确定给定IP地址的地理位置。
使用示例
$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 // )