onebusaway-gtfs-realtime-visualizer icon indicating copy to clipboard operation
onebusaway-gtfs-realtime-visualizer copied to clipboard

Support configurable Google Maps API key

Open answerquest opened this issue 7 years ago • 7 comments

Their terms of use have changed recently, and I guess we need to put in our API key somewhere. Pls suggest where.

Screenshot of page: click here

Link that google takes us to.

answerquest avatar Aug 12 '18 14:08 answerquest

@answerquest To be honest I'm not sure the best way to configure this, as I didn't create this project. Ideally we'd provide it as a command-line parameter if we want to allow it to be configured by the user at runtime, but I'm not sure the best way to accomplish this given how the project is set up. Alternately we could bake in a development key.

barbeau avatar Aug 13 '18 16:08 barbeau

@barbeau it's not too bad actually as I wanted the screen to be darkened anyways ;)

So yes, my thought was to look for the specific code in the source and.. Hey I found it! Last commit on one of the files was: "Remove Google Maps API key.". :1234: :rofl: So I'll just insert my key in here at this point and give it a spin.

EDIT : 'worked. Instructions for putting in your Google Maps API key:

  • Open src/main/resources/org/onebusaway/gtfs_realtime/visualizer/index.html
  • Find the <script.. tag line with "maps.googleapis.com" and replace sensor=false with key=[YOUR API KEY]

answerquest avatar Aug 14 '18 00:08 answerquest

Good job tracking the commit down! Yes, just editing the code and adding your own Maps API key there is the simplest solution to get it working - this is the "bake in a development key" approach. But this doesn't help someone if they are trying to run the JAR without recompiling the project themselves. And that's where I'm not immediately clear as to the best way of providing the key.

barbeau avatar Aug 14 '18 00:08 barbeau

Update: working well with the baked-in key. screenshot

answerquest avatar Aug 14 '18 01:08 answerquest

@answerquest Is this using your own Google Maps API key or the one that was originally included in this project in the commit you referenced? If it's the one that was included in the project we can just revert that previous commit and allow using it for demos.

barbeau avatar Aug 14 '18 13:08 barbeau

@barbeau no, I'm using my own API key, not the original one. I'll recommend expiring old keys (i.e. from the google api a/c settings) as with the tighter limits coming these will be vulnerable to be scraped and used by unknown folks or bots, and there's a risk of incurring bills unexpectedly.

The tool works without the API key also, the map displays, albeit in a darkened way as shown above, but still, functional enough. It's not a breaking issue.

IMHO It'll be better to work on parameterizing the key and making it part of the command line, or having a config file where user can save in their key. And I think there may be more options people might want to add if there's a config file, like including more fields in the popup which are feed-specific.

Another track: the mapping itself could be moved to leaflet / mapbox / openlayers.. but that would involve major re-writes in the way points and lines are drawn on it. See what works better.

I'll close this issue for now since I have a workaround fix for my needs, pls feel free to re-open or create new when development for a permanent fix takes place.

answerquest avatar Aug 15 '18 03:08 answerquest

@answerquest thanks, I agree that we need to have a configurable API key. Let's leave this open so it's obvious for others that this is a known issue.

barbeau avatar Aug 15 '18 12:08 barbeau