Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

The Google


Maps API


T


he Google Maps API is based on a very simple suite of classes that
you use, within a JavaScript container, directly within an HTML
page. All of the functionality of a Google Map is based on this simple
premise of an embedded JavaScript object built into a web page.

The interface to the API is surprisingly straightforward, but the simplicity
hides some powerful classes, objects, and interfaces that enable you to manip-
ulate the Google Map. By combining this interface with the data that you
want to display, you can support interactive elements on the web page without
having to reload the page or redisplay portions of the map: The entire process
is handled within the JavaScript and Google Maps application.

Using the API Key.


Before you start using the API, you must register with Google and obtain a
Web API key. You cannot use the Google Maps API without a key; Google
will return an error and display nothing if you do not use a key or if you use
the wrong key when you try to use the Google Maps API. For this reason,
the Google Maps API key needs to be referenced in every Google Maps
application you create.

To obtain a Google Maps API key, you must already have an account on
the Google system. If you do not already have an account with Google, you
will need to register with Google first. You will be asked to supply an e-mail
address (which will be used to supply you with your API key).

Once you have you have registered with Google, go to the Google Maps
API web site (http://www.google.com/apis/maps/) and request a
key. The key only works when Google can verify the web site on which your
applications will work. This means that the web site on which you build
your applications must be publicly available on the Internet. Unfortunately,
this also means that you cannot develop applications locally within a net-
work that is not shared directly with the Internet. This includes most
servers in organizations behind firewalls and servers at small businesses and
homes connected to the Internet through a standard xDSL connection such
as ADSL.

̨Learn how to use
the API key

̨Basic components


̨Become familiar
with the API’s main
elements

̨Learn about the
Google Maps
classes

chapter


in this chapter

Free download pdf