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:
Note the parameters:
includeOffices = true
levels = country
roles = legislatorLowerBody
You'll see the response which google Civic returns contains the following:
"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.