datamade / my-reps

:busts_in_silhouette: Enter your address to find your elected representatives. Powered by the Google Civic Information API
https://myreps.datamade.us
MIT License
70 stars 178 forks source link

control levels of government returned as query parameters #14

Closed derekeder closed 7 years ago

derekeder commented 7 years ago

From @ghing in #13:

I see that you can configure levels in js/lookup_tools.js, but it would be better to read these from URL query parameters. That way, someone could iframe in the search and just change the iframe URL to specify different levels of government.

What pattern is easiest?

ghing commented 7 years ago

Another option:

I'd say use whichever format makes the parsing code in the JavaScript easiest, smallest.

My gut feeling is that it's /?results_level=fed,state,county,local.

URLSearchParams would make this easy, but it has limited browser support.

derekeder commented 7 years ago

Yup we should be able to pull those params either way. I'll go ahead and start a PR

derekeder commented 7 years ago

@ghing finally got around to this. I ended up adding checkboxes below the search box that lets you select the level of government you want returned. This is also saved in the URL.

Here's an example: http://myreps.datamade.us/#/?address=1515%20W%20Augusta%20Blvd%2C%20Chicago%2C%20IL%2C%20United%20States&results_level=local&results_level=county

screen shot 2017-05-30 at 5 30 34 pm