Where to declare an API key? I'm confused about the following:

I'm working on a module that creates a interactive Google Maps background, I've added the Javascript to my module ( which is run at hook_init), but when I try to load the page, the maps background doesn't show up.

Before I decided to create a module, I used the same Javascript code which was called on page load through the header-section (through script>src) in my page.tpl.php file, and everything worked as it was supposed to.

So I'm suspecting that, because I call the module with hook_init, my Javascript cannot show up because the API key hasn't yet been validated/declared by the page.

What's the best way to tackle this problem? Can I declare the API key in my .module file? or even my module.js file? Or should I change the hooks to something else, in that case, is there a hook that lets me call the module.js file after the head of my page is loaded?

&lt;?php function maps_markers_init() {
$markerAantal = 0;
$latitudes = db_query('SELECT field_latitude_value FROM {field_data_field_latitude}')-&gt;fetchCol();
$longitudes = db_query('SELECT field_longitude_value FROM {field_data_field_longitude}')-&gt;fetchCol();

json_encode($latitudes);
echo "&lt;br&gt;";
json_encode($longitudes);
};


And to load the Javascript:

function maps_markers_page_build(){
drupal_add_js(drupal_get_path('module', 'maps_markers') .'/maps_markers.js');
};
Eventually things got fixed, learned that you can just add a .js file into your module with the HOOK_init() since they get stored to use at a later stage.

What obviously was causing the problem, was the wrong declaration of the API key, this was fixed by adding the line:

drupal_add_js("https://maps.googleapis.com/maps/api/js?key=[MY API KEY]", "external");


to the document.
After that, I could call the .JS file with:

drupal_add_js(drupal_get_path('module', 'maps_markers') .'/maps_markers.js');


More information on how everything was fixed can be found here:
Module conflicting with JQuery