GMapsFX icon indicating copy to clipboard operation
GMapsFX copied to clipboard

Google API key

Open McAwesomeville opened this issue 6 years ago • 7 comments

Do I need a Google API key to use this library? I didn't find any place where to enter the key.

McAwesomeville avatar Mar 10 '18 10:03 McAwesomeville

I was quite surprised to see it worked out of the box without needing to input a key. Is that normal ?

ManifoldFR avatar Mar 11 '18 22:03 ManifoldFR

The API key is supplied by using one of the com.lynden.gmapsfx.GoogleMapView constructors that takes a key argument.

@ManifoldFR apparently it does!

GeoffCapper avatar Mar 11 '18 23:03 GeoffCapper

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.

McAwesomeville avatar Mar 12 '18 17:03 McAwesomeville

This constructor has worked for me: GoogleMapView mapView = new GoogleMapView("en-US", "My-Google-Map-API-Key");

touhiDroid avatar Mar 29 '18 08:03 touhiDroid

@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.

Snipedown avatar Apr 03 '18 19:04 Snipedown

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 avatar Jan 26 '19 19:01 ricmf

@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.

GeoffCapper avatar Jan 29 '19 00:01 GeoffCapper