Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

60 Part I — Basics


Each individual query counts as 1 toward your 1,000-per-day limit. The limit is by query, not by
unique query string. In this case, you had to perform nine queries to get all of the results for just
one query string.

Comparing Language Samples


Google Maps examples consist of JavaScript and the HTML that makes up the page. But the
backend information that you might store or compose will probably be sourced through an
alternative language.

The Google Web API uses the Simple Object Access Protocol (SOAP), which means that it is
accessible from just about any language. This section concentrates on Perl and Java for backend
solutions, because they are two of the more common languages in use.

Perl
With Perl, you first need to download and install the SOAP::Litepackage and all the other
modules on which the SOAP::Litemodule relies (including the XML::Parserand others).

If you are familiar with CPAN, this should be a simple task. Just use the following command
(under Unix/Linux):perl -MCPAN -e ‘CPAN::Shell->install(“SOAP::Lite”)’.

Without CPAN, you’ll need to manually download the main SOAP::Litepackage and the
modules on which it relies. When using the ActivePerl distribution in Windows, use the Perl
Package Manager (PPM) or Visual Package Manager (VPM).

Once you install the SOAP::Litemodule, submitting the query to the Google search service
is relatively simple. Listing 4-1 shows a simple search (without any processing or printing of
the results).

Beyond Searches

The primary reason for using the Google Web API is to get a list of web sites that match a par-
ticular query and, thus, might be useful to you when building your Google Maps. You can, how-
ever, access two other Google systems through the Google Web API: the spelling system and
the cache system.

The spelling system provides alternate spellings for words or phrases that you supply. The same
system uses the information in the Google database to suggest sensible alternatives when you
submit a search (for example, if you searched for “Bratney Spires,” it would suggest an alter-
nate — and correct — spelling: “Britney Spears”).

The cache system returns the cached document content for a given URL. The text returned is
the raw HTML for the URL, assuming that it exists in the Google database, as it was stored from
the last Google web crawl.

Both these systems are described further in the Google Web API documentation but are not
generally useful for Google Maps applications.
Free download pdf