Laravel Geocoding

Laravel Geocoding

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.

Filed in: News / packages
Laravel News Partners

Laravel Jobs

Senior PHP developer
Brussels
Paynovate
PHP Developer - Full time w/ benefits, US Only
Northern Virginia or Remote (US Only)
Guidance Residential
Full Stack Developer
Remote
Wehaa.com
Laravel API Developer
Las Vegas, NV (Must work on-site)
V Shred
Laravel Developer (Vue, SQL Server)
Remote
World Trade Organization

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.