Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Maps API warning: NoApiKeys #1022

Closed
bingxie opened this issue Jun 1, 2016 · 16 comments
Closed

Google Maps API warning: NoApiKeys #1022

bingxie opened this issue Jun 1, 2016 · 16 comments

Comments

@bingxie
Copy link
Contributor

bingxie commented Jun 1, 2016

So we need a place to let users set their google map api key.

@pmackay
Copy link
Contributor

pmackay commented Jun 1, 2016

You mean so each instance has its own API key?

Would this make sense as an application.yml level config?

@pmackay
Copy link
Contributor

pmackay commented Nov 21, 2016

@bingxie @mkllnk what is the Google API key needed for now, if Map page uses OSM?

@mkllnk
Copy link
Member

mkllnk commented Nov 22, 2016

Unfortunately, OFN uses both at the moment. It uses Google Maps for searching and OSM for the tiles.

@pmackay
Copy link
Contributor

pmackay commented Nov 26, 2016

@mkllnk is that for doing address lookups? Is GMaps only needed on the maps page? (slightly different point)

@mkllnk
Copy link
Member

mkllnk commented Nov 27, 2016

GMaps is also used to search by location. For example, if you visit /shops and type "Melbourne", it uses Google Maps Geocode Service to find Melbourne and then filters enterprises by that location.

@elf-pavlik
Copy link
Member

I can't even find where this GMaps API key currently gets send

@mkllnk
Copy link
Member

mkllnk commented Dec 21, 2016

Does it even get set? Maybe the GMaps API works without key, but it prints the warning?

@elf-pavlik
Copy link
Member

On the staging I just deployed map breaks after few seconds https://ofn.hackers4peace.net/map

screen shot 2016-12-21 at 11 01 03 am

@mkllnk
Copy link
Member

mkllnk commented Dec 29, 2016

I can't find it either. But I found an answer saying that our domain works, because it was active before June 22nd 2016. All newer apps need an API key now. We have two options:

  • Add an option to configure an API key.
  • Get rid of Google Maps.

If we wanted to get rid of Google Maps, we need another service to know where places are. We receive GPS coordinates for places in the search and for addresses of businesses. We use that to compute the distance between places and filter the search.

@myriamboure
Copy link
Contributor

Just a question: if OSM is not so well fueled in Australia, why not taking the opportunity to map on OSM while registering new enterprises on OFN? Like when you put your address, if not found in the OSM database, you can clic to add it and you can select the spot on the map and save. Maybe I'm dreaming :-) But that could be a way to get rid of Google maps and contribute at the same time to enrich the OSM Commons...

@elf-pavlik
Copy link
Member

I think we need quick fix to allow Google Maps API key in config. And later work on providing toggle alternative to only depend on OSM. This way each instance can choose 'consumer' or 'pioneer' mode depending on region and community.

@pmackay
Copy link
Contributor

pmackay commented Jan 2, 2017

Could #1209 also be solved by removing the Google Maps dependency?

Have looked into this a bit more. Suspect Google will offer best performance for geocoding, for speed and quality. Nominatim from OSM is not likely to be good enough.

@mkllnk are there any current patterns used for managing API keys on the front end?

@elf-pavlik
Copy link
Member

PR #1359 adds GOOGLE_MAPS_API_KEY to config and uses it in layout following
https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API

with that patch now https://ofn.hackers4peace.net/map loads

@mkllnk
Copy link
Member

mkllnk commented Jan 4, 2017

@pmackay I know three currently used ways to provide api keys.

  1. The Spree configuration already contains settings for some keys and credentials. The Google Analytics key can be set in the admin panel, right?
  2. An environment variable set in application.yml. That's the quickest to implement and was chosen by @elf-pavlik in configurable google maps api key #1359 . It's probably a good place, because it is a quite important feature of OFN. But we should remember to include that in the ofn-install project as well.
  3. Local Ruby files in config/initializers/ are used to initialise code that needs api keys, for example for Bugsnag. This is good for custom code of completely optional services.

@pmackay
Copy link
Contributor

pmackay commented Jan 4, 2017

@mkllnk thanks! I was slightly more wondering about best practice to make keys available in the frontend and whether keeping it hidden is a concern, but if not thats fine (and it follows Google recommendations, so in this case I guess not!). Agree option 2 works well for this for backend.

@sstead
Copy link

sstead commented Jan 13, 2017

Testing notes:
Maps working normally. Can search on map, can place a new enterprise on the map, can search shops/producers by location. Group maps and directory searching also working as normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants