RefugeRestrooms / refugerestrooms

REFUGE restrooms indexes and maps safe restroom locations for trans, intersex, and gender nonconforming individuals.
http://www.refugerestrooms.org
GNU Affero General Public License v3.0
894 stars 261 forks source link

Google Maps API needs key? #297

Closed lgdean closed 7 years ago

lgdean commented 7 years ago

Running the app locally, I searched in San Francisco, clicked on one of the results in the list (http://localhost:3000/restrooms/10), and got a page with info about the bathroom, and an error from Google instead of a map.

In the JS console, I found a Google Maps API error: MissingKeyMapError error, and two warnings.

See attached screenshot.

screen shot 2017-03-13 at 8 39 03 pm

Chrome 56 on a Mac, in case it matters.

lgdean commented 7 years ago

My friend tried too, and was sometimes getting the error, and sometimes not.

The wifi is too slow, at the moment, to see whether the same problem happens in production.

dannypaz commented 7 years ago

@lgdean This looks to be an issue w/ the data from db/export.csv. Philz Coffee and the associated data no longer exist at 3901 18th st.

The 2 warnings from Google Maps API should not affect the features of the application.

dannypaz commented 7 years ago

@lgdean I've made a separate issue to address this https://github.com/RefugeRestrooms/refugerestrooms/issues/303

An address that should work locally is New College.

tkwidmer commented 7 years ago

This is the geocoding endpoint: https://maps.googleapis.com/maps/api/geocode/json?address=3901+18th+Street,+San+Francisco,+CA

which seems to be functional

mi-wood commented 7 years ago

I'm heading on vacation until next week, but if this is still up when I get back, I'll take a stab at this along with #299

mi-wood commented 7 years ago

Taking a first glance and it seems like the last time we deployed was 12 months ago and as of last June they started requiring an API key for the JS API: https://maps-apis.googleblog.com/2016/06/building-for-scale-updates-to-google.html

We'll need to follow this and distribute the key: https://developers.google.com/maps/documentation/javascript/get-api-key

Haven't gone through the setup yet, but it seems like it has to be updated here: https://github.com/RefugeRestrooms/refugerestrooms/blob/e379eb8057c68173111b6827df0dbbec8be658f6/app/views/layouts/_head.html.haml#L9

It doesn't matter how well encrypted/stored it is, since you could get it just by querying our app, but it should be thrown into a config. That being said, I'm not seeing if there's an easy way to stop someone from rate limiting rate limiting us unless we do the queries server side or maybe google has IP based rate limiting built in for us?

Anyways, mostly seems administrative (making a google account and creating the key).

tkwidmer commented 7 years ago

Yeah, limiting seems to be my only concern here. Since as i understood it the last time I had a conversation with google folks. The advantage with doing client side was we wouldn't be rate limited. We tried geocoding searches on our servers but we quickly hit the limit. I can probably try to take care of this. I may have some time on Sunday afternoon to work on it.

DeeDeeG commented 7 years ago

Acrcording to #316 this is fixed, looks like this issue here can be closed.