如何使用 Geocoder php 库和 GeoJSON 提取国会选区
How to extract congressional district using Geocoder php library and GeoJSON
我正在使用 Geocoder PHP 库获取地址的位置信息。我得到了所有数据,但也得到了我需要的地区代码。我哪里错了?
下面是我使用的代码:
$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);
这是当前输出:
{"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}}
这个问题之前已经在 Whosebug 上回答过
Geo Coding Address - get district of a certain address (Google API)
你要的关键部分在'sublocality'
此问题之前已在 Programmers.Stackexchange Is there an API for determining congressional districts
上得到部分回答
您将无法从 Geocoder 库中提取您要查找的信息,因为 none 与 API 相关以提供该服务。在获取位置信息后,您需要使用另一个 API 来获取地区。目前提供此功能的两个是免费的 SmartyStreets which is a paid service and Sunlight Labs。
我正在使用 Geocoder PHP 库获取地址的位置信息。我得到了所有数据,但也得到了我需要的地区代码。我哪里错了?
下面是我使用的代码:
$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);
这是当前输出:
{"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}}
这个问题之前已经在 Whosebug 上回答过
Geo Coding Address - get district of a certain address (Google API)
你要的关键部分在'sublocality'
此问题之前已在 Programmers.Stackexchange Is there an API for determining congressional districts
上得到部分回答您将无法从 Geocoder 库中提取您要查找的信息,因为 none 与 API 相关以提供该服务。在获取位置信息后,您需要使用另一个 API 来获取地区。目前提供此功能的两个是免费的 SmartyStreets which is a paid service and Sunlight Labs。