dheeraj singhal
dheeraj singhal

Reputation: 53

how to pass google map api key to initialize google map in GWT based java application

I am using gwt-maps-api jar to embed google map in my GWT application.Till one month back it was working fine.We changed the domain name of our application this month and it stopped working.Now locations are not coming in auto-complete drop-down and it may be because of google's last month update to make api key mandatory to access google map api for new domains.Now I am not sure how to pass this key while initializing map api with gwt-maps-api classes.Please help.Sample code is mentioned below.

ArrayList<LoadLibrary> loadLibraries = new ArrayList<LoadApi.LoadLibrary>();
loadLibraries.add(LoadLibrary.GEOMETRY);
loadLibraries.add(LoadLibrary.PLACES);
Runnable onLoad = new Runnable() {
  public void run() {
    initMapRegions();
  }

};

LoadApi.go(onLoad, loadLibraries, false);

Upvotes: 1

Views: 637

Answers (1)

mxlse
mxlse

Reputation: 2784

Try to add a String with the API-key as parameter to the call of the go method:

String otherParameters = "key=YOUR_API_KEY";
LoadApi.go(onLoad, loadLibraries, false, otherParameters);

This should add your API-key to the injected JS. You can add multiple parameters to the string like key=YOUR_API_KEY&v=3.24&....

Upvotes: 1

Related Questions