Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Geocoded search w/ Google Maps / Google Civic API WordPress

  • SOLVED

Hi all,

I'm trying to put together a custom search functionality which takes a geocoded address, runs it through the google civics API to grab the lower legislative branch open civic data code. In turn, I plan on having a page for each Congressional district -- which would have a custom field with the associated OCD data string that a geocoded search would return.

Here's a bit more of a data breakdown. For reference, here's the google civics API info:
https://developers.google.com/civic-information/docs/v2/representatives/representativeInfoByAddress#try-it

Note the parameters:
includeOffices = true
levels = country
roles = legislatorLowerBody

You'll see the response which google Civic returns contains the following:

divisions": {
"ocd-division/country:us/state:va/cd:10": {
"name": "Virginia's 10th congressional district",


So my plan is to have a post type called "districts" which I'll create manually, and assign a custom field "ocd" for which I'll manually fill in with the desired OCD string (in the above example that would be ocd-division/country:us/state:va/cd:10)

So what I'm looking to have done is the search functionality itself. Essentially:
- User see's a search box and enters their address
- Address is geocoded
- Redirect the user to the corresponding page which matches the value returned from the geocoded search (i.e. ocd-division/country:us/state:va/cd:10).

Any help here would be appreciated. Ideally looking for help putting together the whole block of code to handle the search & subsequent redirect. Everything else I can handle.

Thank you!

Answers (2)

2018-08-14

Arnav Joy answers:

are you still looking for help?


Andrew Clemente comments:

@Arnav yes I am

2018-08-10

Fahad Murtaza answers:

I am working on something similar and can help.


Andrew Clemente comments:

Shoot me an email [email protected]


Andrew Clemente comments:

Still looking for help on this. Happy to chip in a little more