Wednesday, September 27, 2006

Getting an API key

This site is the official site of OyajiMapper. At the same time this site is where I am going to test my OyajiMapper. In order to do so, I need a Google Maps API key for this site. It is simple to get an API key from the Google Maps API site. It takes only a few clicks from its home page to get your own API key. Your key can be used only by your site, whose URL will be asked by the Google Maps API site before Google giving you a key. If you try to use a key of someone else, the Google Maps API doesn't work and prompts an error message such as:
The Google Maps API key used on this web site was registered for a different website. You can generate a new key for this web site at http://www.google.com/apis/map/ .
The next thing to do is to add a HTML link element in the HTML head in your pages. As I am going to test here, so what I have to do is to edit my blogger template. How the link element should be coded is documented at the Google Maps API site and you can copy and paste it to your pages or blog template(s). The last thing to do is to verify the configuration. The Google Maps API site's page provide a whole HTML document sample which includes a sample JavaScript to use Google Maps API, as well as the HTML link element in the head which is to read a JavaScript file from Google with the API key as one of its parameters. I made a slight different verification because I don't like the sample JavaScript to be executed by body tag's onload attribute. So instead of executing the sample when a HTML page load is completed, I write a HTML a element (anchor), such that the provided function, load() is called to display a Google Map bellow by clicking here.
It was such an easy task. Partly because I had done the same things three times for the other sites. But even at the first time it was that easy. So now this site is ready for testing my JavaScipt, OyajiMapper.js, but it has no data or function definitions at all when I write this post. I will be back when I start writing some codes.

No comments: