1

I am using Geocoder PHP library to get spit on location information for an address. I get all data but the district code which I need as well. Where am I going wrong?

Below is the code I am using:

$adapter  = new \Geocoder\HttpAdapter\CurlHttpAdapter();
$GeoJSON  = new \Geocoder\Dumper\GeoJsonDumper;
$geocoder = new \Geocoder\Geocoder();

$lookfor = 'address goes here'; 
$geocoder->registerProvider(new \Geocoder\Provider\GoogleMapsProvider($adapter)); 
$result = $geocoder->geocode($lookfor);
echo $GeoJSON->dump($result);

Here is the current output:

{"type":"Feature","geometry":{"type":"Point","coordinates":[-77.2899939,38.875973]},"properties":{"streetNumber":"93","streetName":"Flower Lane","zipcode":"00412","city":"Onkle","county":"Fur County","countyCode":"Fur COUNTY","region":"Virginia","regionCode":"VA","country":"United States","countryCode":"US"},"bounds":{"south":38.875973,"west":-77.2899939,"north":38.875973,"east":-77.2899939}}
user3088202
  • 2,714
  • 5
  • 22
  • 36

2 Answers2

2

This question has been answered in part previously on Programmers.Stackexchange Is there an API for determining congressional districts

You're not going to be able to pull the info you're looking for from the Geocoder library as none of the APIs it ties into provide that service. You'll need to use another API after getting location info to get the districts. Two that currently provide this are the SmartyStreets which is a paid service and Sunlight Labs which is free.

Community
  • 1
  • 1
Chris Short
  • 71
  • 1
  • 3
0

This question has been answer previously on StackOverflow

Geo Coding Address - get district of a certain address (Google API)

The key part that you want is in 'sublocality'

Community
  • 1
  • 1
greg_diesel
  • 2,955
  • 1
  • 15
  • 24