Geocod.io the geocoding service created by Mathias Hansen has just released a PHP and Laravel library for integrating with the service. It includes geocoding, reverse geocoding, and data matching for US and Canadian addresses.
Here is an example:
$response = Geocodio::geocode('1109 N Highland St, Arlington, VA');
/*
{
"input": {
"address_components": {
"number": "1109"
"predirectional": "N"
"street": "Highland"
"suffix": "St"
"formatted_street": "N Highland St"
"city": "Arlington"
"state": "VA"
"country": "US"
}
"formatted_address": "1109 N Highland St, Arlington, VA"
}
"results": array:2 [
0 => {
"address_components": {
"number": "1109"
"predirectional": "N"
"street": "Highland"
"suffix": "St"
"formatted_street": "N Highland St"
"city": "Arlington"
"county": "Arlington County"
"state": "VA"
"zip": "22201"
"country": "US"
}
"formatted_address": "1109 N Highland St, Arlington, VA 22201"
"location": {
"lat": 38.886672
"lng": -77.094735
}
"accuracy": 1
"accuracy_type": "rooftop"
"source": "Arlington"
}
1 => {
"address_components": {
"number": "1109"
"predirectional": "N"
"street": "Highland"
"suffix": "St"
"formatted_street": "N Highland St"
"city": "Arlington"
"county": "Arlington County"
"state": "VA"
"zip": "22201"
"country": "US"
}
"formatted_address": "1109 N Highland St, Arlington, VA 22201"
"location": {
"lat": 38.886665
"lng": -77.094733
}
"accuracy": 1
"accuracy_type": "rooftop"
"source": "Virginia Geographic Information Network (VGIN)"
}
]
}
*/
Of course, this is just the basics and geocoding can be useful for a myriad of things while we are building applications. This could be everything from finding latitude/longitude, addresses, proper zip codes, timezones, or even Congressional information.
You can find out more details and try out the package from their Github repo and the first 2,500 lookups per day are free.
0 comments:
Post a Comment
Thanks