GMapsFX
GMapsFX copied to clipboard
Google API key
Do I need a Google API key to use this library? I didn't find any place where to enter the key.
I was quite surprised to see it worked out of the box without needing to input a key. Is that normal ?
The API key is supplied by using one of the com.lynden.gmapsfx.GoogleMapView constructors that takes a key argument.
@ManifoldFR apparently it does!
Thanks for the quick answer. I haven't download the code yet, I just had a look to the latest apidocs linked in the README.md, which is in Rev. 2.0.0. In this revision the constructor doesn't take the argument key.
This constructor has worked for me:
GoogleMapView mapView = new GoogleMapView("en-US", "My-Google-Map-API-Key");
@McAwesomeville @ManifoldFR
As far as I am aware, with v3 Google Maps will use either an API key or your IP Address if one is not given. However, I believe they REALLY want you to use a Key and not using one may provide problems in the future.
How do you go about securing your key, since you can't restrict the domain? Anyone who looks at your jar could retrieve the key and use your quota.
@ricmf Google does offer the ability to restrict referrers: https://developers.google.com/maps/documentation/javascript/get-api-key#key-restrictions
If you need more security, one way to deal with it would be to store the key somewhere else and pick it up before you instantiate the map. You can then secure the storage location, making sure it can only be accessed by your app from the location you choose. That could be as simple as BASIC auth on a http resource, or as complex as you can imagine.