Brigitte Brigitte - 10 months ago 78
jQuery Question

How to load Google Map API key

i have downloaded an open source code from https://github.com/geirke/optimap and his code is working on his live site at http://gebweb.net/optimap/ however i get the following error in the browser console when attempting to run on my own server

Google Maps API error: MissingKeyMapError
Google Maps API warning: NoApiKeys
Google Maps API warning: SensorNotRequired

Of course i went and got an API key for my self but no matter what combination of passing the API key i do it does not work. Here are the following attemps

function onBodyLoad() {
google.load("maps", "3", {callback: init, other_params:"sensor=false"});
}

function onBodyLoad() {
google.load("maps", "3", {key: "abcdefghijklmnop", callback: init, other_params:"sensor=false"});
}

function onBodyLoad() {
google.load("maps", "3", {key: abcdefghijklmnop, callback: init, other_params:"sensor=false"});
}


I have searched online and I see that google does not require an API key, and passing the api key via an argument such as ?api=abcdefghijklmnop&callback ect.

If someone would be kind enough to assist me ive been at this all day. Thank you in advance.

Answer Source

Pass the key in the "other parameters" field:

google.load("maps", "3", {callback: init, other_params:"key=abcdefghijklmnop"});

(the sensor parameter is no longer required, but the API key is).