Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

36 Part I — Basics


If you don’t already have a publicly accessible web site service, you will need to sign up to a
server provided by a hosting company, where many different solutions are available. All the
examples shown in this book, for example, are hosted on a service provided by Dreamhost
(www.dreamhost.com).

The Google Maps API is, in fact, more specific than simply the web site hostname. The API
key will only work within a specific directory. So, if you register with a URL of
http://maps.mcslp.com/examples, Google Maps applications will only work when
loaded from this precise URL. Other directories above or below this URL will not work.

Thus,http://maps.mcslp.com/examples/simple.htmlwould be valid for the key
registered with the preceding URL. But http://maps.mcslp.com/simple.htmlwould
be invalid. So would the same example placed into a subdirectory:
http://maps.mcslp.com/examples/simple/simple.html.

These limits mean that you cannot register an entire domain for hosting Google Maps applica-
tions unless all the applications are placed into the same directory. The restrictions are designed
to protect both Google and your own applications from being stolen and abused because the
correct key must be used.

Once you have a web site URL for your Google Maps applications, you can register for a key
by going to the “Sign up for an API key” page, entering the URL for your web site, and click-
ing Submit. Your Google Maps API key will be e-mailed to you. Make sure you keep the
e-mail message as well as a separate note of the key in a secure location. Although you can
request keys again, and even request multiple keys for multiple web sites, keeping the key safe
is a good idea.

Limits and Usage

As mentioned, your Google Maps API key is unique to your web site. You cannot copy the code
that you have developed (or that anybody else has developed, for that matter) and use it on a
different web site without separately registering for an additional key and modifying the key
information.

Once you have an API key, you can create, use, and support as many Google Maps applications
as you like. But you need to be sensible about the information and services that you provide. For
example, you cannot claim that the Google Map and the information that it contains is solely
your copyright. Nor can you claim that there is any official affiliation between yourself and
Google just because you are using its mapping service.

The Google Maps API web site contains a full guide to the terms of usage that you agree to
when you request an API key. I strongly recommend that you read these notes before signing
up for a key and developing applications to ensure that you are aware of the issues and limita-
tions of using the service.
Free download pdf