gmap3 icon indicating copy to clipboard operation
gmap3 copied to clipboard

No API key error

Open berarma opened this issue 7 years ago • 1 comments

I'm having problems using an API key. After loading the library I call $.gmap3({ key: "..." })'.

Sometimes it works sometimes it doesn't. The problem is that the Google API is loaded in the onReady event, but sometimes the onReady event has already fired when the JS loads. Thus the API is loaded before I get to set the key, and I can't set the key before loading the API.

I know this is the cause of the problem because if I move the code that loads the API inside the $.gmap3(), after storing the key, it always works.

berarma avatar Sep 03 '18 09:09 berarma

I've forked the code and moved the Google API loading code inside $.gmap3(). This gives me control over when and how scripts are loaded. I'm not doing a PR since I guess this is not what everybody wants.

I haven't found another way to make it work. When you have ten scripts in your site, all of them trying to be loaded first and none of them really needing to be the first you need to take control.

Nice regards.

berarma avatar Nov 08 '18 16:11 berarma