تبليغاتX
. - english
Welcome to Google Earth! Once you download and install Google Earth,
your computer becomes a window to anywhere on the planet, allowing you
to view high-resolution aerial and satellite imagery, elevation terrain, road
and street labels, business listings, and more.

System Requirements
To use Google Earth on a Windows PC, you must have at least the following:
l Operating System: Windows 2000, Windows XP
l CPU: 500Mhz, Pentium 3
l System Memory (RAM): 128MB RAM
l Hard Disk: 400MB free space
l Network Speed: 128 Kbits/sec
l Graphics Card: 3D-capable with 16MB of VRAM
l Screen: 1024x768, "16-bit High Color" screen
Hacking Google® Maps and Google® Earth
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO
REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE
CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR
EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN
MAY NOT BE SUITABLE FOR EVERY SITUATION.THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE
PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF
PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON
SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES
ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A
CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE
AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY
PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET
WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK
WAS WRITTEN AND WHEN IT IS READ.

Introducing
Google Earth
All of the preceding chapters focused on the Google Maps API. The
Google Maps system provides a browser-based interface to the data
in the Google database, both in terms of the map and the satellite
photos. The API provides the ultimate in flexibility for building and incorporating
Google Maps data into web-based applications. That flexibility,
however, comes at the potential price of limiting the environment and
interface.
Even with the flexibility of the JavaScript language and the ability to create
and organize content in ways that suit the application, you can add additional
layers of data to the map information already demonstrated. In particular,
the web-based Google Maps interface is incapable of providing the
interaction and display of three-dimensional data. The limitations extend
not only to the base data, but also to the information that you can overlay
on the map.
Google Earth, on the other hand, has no restrictions on the interface and
how the user interacts with the Google Earth data. Google Earth is a desktop
application available for Windows and Mac OS X that enables you to
browse Google Earth images in a more dynamic environment. Using
Google Earth you move about the earth in 3D, moving and manipulating
the Google Earth data in real time. This provides additional information
that would be difficult to represent within the Google Maps interface, such
as “tilting” the earth so that you can see the relative height of different areas
of land.
This chapter looks at ways in which you can use Google Earth and how to
create some basic data to be used within the application to extend the information
and functionality of the application.
Google Earth Overview
The most critical difference between Google Maps and Google Earth is the
environment. Google Earth is a standalone application that is available for a
limited number of platforms. It is designed as an earth browser for showing
satellite images of the earth’s surface in an interactive, 3D environment. The
satellite images and the backup data (such as local businesses) in Google
Earth are the same as those in Google Maps in satellite mode. The difference
is in the way in which the information can be viewed and manipulated.
˛ Google Earth
overview
˛ Google Earth
overlays
˛ KML for extending
Google Earth
chapter
in this chapter
294 Part IV — Google Earth Hacks
Obtaining the Application
Google Earth can be downloaded from the Google Earth homepage (http://earth
.google.com). There are three versions of the Google Earth application:
  Google Earth is free for personal use and incorporates satellite images that cover the
entire surface of the earth. The free client also provides access to all of the different
Google Local–supported databases, including those that provide information about locations,
local businesses, and route finding. Google Earth also incorporates the technology
for generating and representing information based on the Keyhole Markup Language
(KML). This is the version that is described throughout the rest of this chapter.
  Google Earth Plus is an optional (and low-cost) upgrade to the free client that extends
the functionality of Google Earth to include interfaces to GPS devices, higher resolution
for printed images (higher than onscreen), extended annotation and drawing tools, and a
data importer that will read files in CSV format. Google Earth Plus is supported only on
Windows (at the time of writing).
  Google Earth Pro is a professional product and is therefore significantly more expensive
than the Google Earth Plus upgrade. It incorporates much faster download times and
data streaming, extended layers and overlay support, and improvements to the annotation
system that enable you to develop much more detailed overlays directly within the
Google Earth application. Google Earth Pro is supported only on Windows (at the time
of writing). Google Earth Pro also supports a number of extension modules, including
those for making movies (by “flying” through the Google Earth data), a high-resolution
printing module, and data modules providing traffic and shopping data.
For all three applications, Google Earth is merely the desktop interface to the data on the
Google Earth servers. You must first download the client that enables you to view and interact
with the data. Then you can connect to the Internet to obtain and download the images that
are displayed onscreen.
There is a fourth Google Earth application, Google Earth Enterprise, which is designed to provide
Google Earth features in combination with heavily customized information within an enterprise
environment. Google Earth Enterprise is technically a range of applications that work together to
provide Google Earth data, combined with your own enterprise information, such as statistical
and customer data. For more information see the Google Earth Enterprise web site at http://
earth.google.com/earth_enterprise.html.
Google Earth Features
The Google Earth application provides an interface to the Google satellite imagery, and
because it is not limited by the interface available through a web browser and JavaScript, there
is a lot more flexibility and interactivity in the Google Earth application. Some of the key differences
are detailed shortly. First, examine Figure 15-1, which shows the basic interface of the
Google Earth application.
Chapter 15 — Introducing Google Earth 295
FIGURE 15-1: The basic interface.
The interface is divided into three panels. The panel on the left provides the data points, overlays,
and search interface that enable you to add data and move around the map using town,
city, and other information point references. The panel at the bottom of the application window
provides an interface for moving and working around the earth. The larger, main panel is
the window to the Google Earth satellite imagery.
Core Functionality
The fundamental difference between Google Maps and Google Earth is the way in which the
satellite imagery can be viewed and manipulated. The satellite images are the same as Google
Maps, but the way in which the data is displayed differs in that it is slightly more fluid than the
Google Maps interface.
For example, the default start position is high above the United States.With Google Earth,
you can tell exactly how high. The information immediately beneath the Google Earth image
provides, from left to right:
296 Part IV — Google Earth Hacks
  The longitude/latitude of the current center point of the map (called the Pointer).
  The elevation (height above sea level) of that point.
  The status of the information satellite images that are streamed to the application.
  The altitude of the current view; that is, the height (above sea level) from which you see
information.
You can see, from Figure 15-1, just how high up you would have to be to see the same information.
If you double-click one of the points on the left, say, the Google Campus, you will “fly”
to the Google Campus, with the satellite imagery flowing past, until the map centers on the
Google Campus. This is almost impossible to represent within a book, but Figures 15-2
through 15-4 show some interstitial images from the starting point in Figure 15-1 to give you
some idea.
FIGURE 15-2: Starting the flight.
Chapter 15 — Introducing Google Earth 297
FIGURE 15-3: Almost there.
FIGURE 15-4: The Google Campus.
298 Part IV — Google Earth Hacks
At no time are areas of the map missing while Google Earth loads the satellite image data.
Instead Google Earth streams the necessary information from Google’s servers to gradually
load the image data as you zoom in through different levels.
This sequence is automatic and much more visual than even the panning option provided
within the Google Maps interface.To manually move around the map, a number of options are
available:
  Click and drag: The same basic method as available within Google Maps. Click anywhere
on the map, drag the map in the direction you want, and then release the mouse.
You will move to the new location.
  Cursor keys: The standard cursor keys on your keyboard move the map in the direction
you choose.
  Joystick: There is a built in “joystick” in the center of the control panel on the map.
Clicking the different arrows on the joystick moves the map.
  Click and move: If you click the mouse and move the map quickly and then release, the
map will begin to scroll in the direction you moved the mouse.To stop the scrolling,
click the red button in the middle of the joystick or click once on the map with the
mouse.
By default, your map will always be oriented to face north. You can rotate the map using the
two buttons to the top left and right of the joystick, which rotate the map counterclockwise
and clockwise. You can always tell the current orientation by using the built-in compass shown
in the bottom left of the map panel. You can reset it using the “N” button on the bottom left.
Finally, you can zoom in and out of the map using the slider on the left, or, if your mouse has a
scroll wheel, using the scroll wheel to zoom out (roll forward) and in (roll back).
Simple Overlays
Numerous built-in overlays are provided with the application.To see them in action, move to
Seattle by typing Seattle into the search box and clicking the search button. You should get a
window like the one shown in Figure 15-5.
From the Layers panel on the left, select “Crime Stats” and then zoom out slightly and you’ll
see the crime statistics for 2000 for a number of counties across the Seattle region, as shown in
Figure 15-6.
Chapter 15 — Introducing Google Earth 299
FIGURE 15-5: Seattle.
FIGURE 15-6: Crime statistics in Seattle.
300 Part IV — Google Earth Hacks
Each icon is an example of a data point, the equivalent of the GMarker object used in the
Google Maps to highlight a single point on the map.
Points of Interest
In addition to locating the key points on the map, you can also overlay and move to key points
of interest on the map. The Google headquarters was an example of this, and a huge number of
other examples exist throughout the Google Maps application. There is no point in listing
those examples here; they are far too numerous and constantly updating. Much of the content
is U.S.-centric at the moment, but more data is being added all the time.
You can add as many of these overlays to the map as you like. There is no limit, although the
application will slow down as you add more and more points and overlays to the map. The data
and overlay information can be extensive and interesting. For example, Figure 15-7 shows the
airports and train stations in Seattle.
FIGURE 15-7: Adding airport and train station data.
Routes and Paths
Searches for information and locations work just the same as they do within Google Maps. You
can move directly to an address and also find routes between two different points. If all you
want to see is an overlay of the roads, select the “roads” overlay from the Layers panel. This
provides a view similar to the Hybrid view in Google Maps, where roads are overlaid directly
on top of the satellite imagery. You can see this more clearly in Figure 15-8, where the roads
overlay has been added to the southern tip of Manhattan Island.
Chapter 15 — Introducing Google Earth 301
FIGURE 15-8: Roads in Google Earth.
Just as with Google Local, you can determine a route’s two points by searching for the first
point and using the pop-up panel to select the destination. Figure 15-9 shows a route between
Ambleside and Whitehaven in the Lake District in the U.K.
So far the routing shows nothing different from what you might expect within Google Maps.
There is, however, a slightly different view of the route available within Google Earth.
Terrain and Altitude
Google Earth includes altitude information for the whole of the earth. This means that you
can get a fairly accurate idea of the altitude of a particular point within Google Earth. Google
has, however, gone one stage further and provided the ability to display this information interactively
on the map. If you select the Terrain checkbox in the bottom left of the control panel,
the view of the map adjusts slightly, but probably imperceptibly.
But, change the attitude (or tilt) of your view, and the difference becomes obvious.To adjust
the tilt, use the slider on the right of the joystick in the control panel. Moving the slider down
tilts the map so that the top of the view rotates horizontally, moving your perspective closer to
the ground. Moving the slider up rotates the map up.
302 Part IV — Google Earth Hacks
FIGURE 15-9: Ambleside to Whitehaven in Google Earth.
The result is dramatic. You can see the altitude of the different areas of the map and the route,
and Google Earth now shows the route winding through some of the lower-lying mountains in
the Lake District (see Figure 15-10).
For another dramatic representation, try going to Sorrento. I visited Sorrento for a conference
and was immediately struck by the nearby mountains, which seemed to dominate the skyline
more than Vesuvius, a much more well-known entity on the beautiful coastline of Naples. The
mountains to the right of Sorrento (as you look northeast) came as a complete surprise by the
time I arrived at the hotel.What I should have done, of course, is quickly check Google Earth
to see the lay of the land, as shown in Figure 15-11, which shows the mountains immediately
to the right and behind the hotel. Vesuvius cannot be seen in this shot, but is immediately to
the left of the view shown here.
Chapter 15 — Introducing Google Earth 303
FIGURE 15-10: Ambleside to Whitehaven with altitude.
FIGURE 15-11: Sorrento and mountains.
304 Part IV — Google Earth Hacks
Buildings
The geological aspects of Google Earth are of course important, but man has had a significant
impact on how different locations around the world appear because of the buildings and structures
that he has created. For completeness, Google Earth includes some man-made structures
in the Google Earth map. If you visit Seattle and click the Buildings checkbox, Google Earth
displays the various buildings in Seattle on the map (see Figure 15-12).
FIGURE 15-12: Buildings in Seattle in Google Earth.
The result shows one of the effects we experienced: the apparent lack of very tall skyscrapers,
which helps give the wonderful impression of space and open-air feel that we discovered in
Seattle compared to New York.
Extending Google Earth Information
Earlier in this chapter, you saw the information that can be built and overlaid within Google
Earth. Google Earth obviously comes with its own massive library of data, information points,
and highlights that can be overlaid on the map. All of this information is provided through a
series of data files that are in the Keyhole Markup Language (KML) standard. KML is a
specialized type of XML that enables you to build and organize points, routes, and other
information.
Chapter 15 — Introducing Google Earth 305
The format of the data is not very difficult to understand or generate. Many of the principles
that have been used through the rest of the book, such as specifying the latitude and longitude
of a point and adding icons and other data, should be familiar. Unlike Google Maps, where the
applications that build and overlay this information on the map had to be encoded, the extension
method within Google Earth is provided entirely within the structure and format of the
KML files.
This section looks at some of the basics of the KML system.
Exporting Your Tags
The easiest way to generate and share points, routes, and other data within Google Earth is to
save the points you find and put them into your My Places folder (or another folder you create).
You can then save the folder contents into a KML or KMZ file (a Zipped version of a
KML file) that you can then share with other people by simply distributing the file. You can
see the result of the KML file generated during the earlier examples here:



My Places.kml

My Places
1

Seattle, WA, USA
Seattle, WA, USA

root://styleMaps#default+nicon=0x304+hicon=0x314

-122.330833,47.606389,0



New York, NY, USA
0
New York, NY, USA

root://styleMaps#default+nicon=0x304+hicon=0x314

-74.006389,40.714167,0



Ambleside, LA22, UK
0
Ambleside, LA22, UK

root://styleMaps#default+nicon=0x304+hicon=0x314

-2.9623,54.428376,0


306 Part IV — Google Earth Hacks

Ben Nevis, UK
0
Ben Nevis, UK

root://styleMaps#default+nicon=0x304+hicon=0x314

-5.003529,56.796859,0



sorrento
1

14.366667
40.616665
31855
0
0

root://styleMaps#default+nicon=0x304+hicon=0x314

14.366667,40.616665,0



Seattle, WA, USA
1
Seattle, WA, USA

root://styleMaps#default+nicon=0x304+hicon=0x314

-122.330833,47.606389,0





The structure and content of the file is, as you can see, very simple and doesn’t differ in many
respects from some of the XML documents that you used in examples earlier in this book.
Basic KML Principles
The KML standard is huge. Google’s own documentation on KML is almost 120 pages, and
the contents are not going to be reproduced here. Instead, look at the highlights and key
points, starting with the basic format of a KML file. The basis of the KML file structure is as
follows:
  The main KML XML root tag.
  The Document tag defines the content of the document (and contains global document
information and a number of folders).
  The Folder tag defines the contents of a single folder, with each folder containing the
details of one or more placemarks, routes, or other structures.
Chapter 15 — Introducing Google Earth 307
Within a folder, you add placemarks, and these are composed of further elements and definitions
that describe the placemark and its components.
Placemarks
The placemark is the primary method of highlighting information within a Google Earth
KML document. A placemark is a single entity within the Google Earth application and can
refer to a single point, a line, a route, a polygon, or any combination of these. For example, a
placemark could be your house, or it could be a re-creation of the stones at Stonehenge. Both
are single entities but are composed of one and many points and coordinates, respectively.
The points that you define as part of a placemark can consist not just of the latitude and longitude,
but also the altitude and even the relationship between the ground and your point on the
map. You can also add a custom icon to the placemark (just as with a GMarker in Google
Maps).
Finally, you can control the appearance of the placemark, from the display text and information
panel to the name, style, and color of the label. You can also set the camera “view,” that is, the
location, altitude, direction, and tilt of the map when the user selects the placemark.
Geometry
Google Earth provides the ability to draw single points, lines, and polygons onto the map. All
geometry types consist of the coordinates (latitude, longitude), altitude, enabling points, lines,
and polygons to appear either on the ground or in the air. Coordinates are specified using the
coordinates tag, specifying the longitude, latitude, and altitude in that order. Hence, you
can find Sorrento using the KML:
14.366667,40.616665,0
All coordinates can be given a color, and polygons can be transparent (only their lines are
drawn) or solid (enabling you to construct buildings and other elements).
All points, lines, and polygons can be extruded; their location can be linked to another location.
For example, you can tether a coordinate to the ground even though it is displayed in the air.
For absolute flexibility you can group points, lines, and polygons into a collection, which in
turn can be used to describe single elements. For example, when constructing a building, you
could group the polygons that make up the building into a collection.
Overlays
Images can be overlaid on the map.Two types are available: a ground overlay and a screen overlay.
Ground overlays ping the image to specific areas on the ground of the map. Screen overlays
enable you to “float” information in the Google Earth display.
The overlay image can be a JPG, PNG, GIF, or TIFF. You can either make the image available
over the Internet (or other network) or embed the image into a KMZ file along with the KML
file that uses it.
308 Part IV — Google Earth Hacks
Wrapping Up
The Google Earth application provides a different environment for viewing the Google satellite
images in a method that also adds additional layers of information, such as terrain and 3D
buildings. The information displayed is the same as Google Maps, but the methods that are
available to extend the Google Earth application are different and rely on an XML-based format
called KML.
KML is limited to providing additional data points for overlaying on top of the Google Earth
data. There is little of the interactivity provided within Google Maps and the browser, but the
Google Earth application provides a richer environment for displaying some types of data.
Now that you know the basics of Google Earth and what the KML format is capable of, you
can examine some samples of overlays that use the data generated in the previous Google Maps
examples, but using the KML format in Google Earth.
Generating Google
Earth Feeds
With Google Maps, the JavaScript language and Google Maps
object environment were required to build the marker and then
overlay the marker onto the Google Map. Google Earth provides
a much simpler method for adding points of interest to the map.With
Google Earth, the Google Earth application does all of the overlay legwork.
All you need to do is create a suitable KML file that provides the bare
structure and coordinates of the point you want to highlight.
Because there is no programming involved, the structure and content of the
KML file is critical. This chapter describes the basics of the KML file format
required for a basic point, along with some extensions and examples of
dynamism that can be added to the system.
Showing Points
The basic KML point is the tag. There were some examples
of this in the previous chapter, but the structure is quite straightforward.
Only two components are required for a tag: the name and
the point (containing coordinates for latitude/longitude) to which the point
refers. You can also add further information, such as the
tag,
icons, and further descriptive data to the tag according to
your needs.
For example, here’s a small tag defining the location of the
Yorkshire Bank in Grantham:

Yorkshire Bank
10 High St,Grantham, NG31 6PU, United
Kingdom


-0.642539,52.913,0


The tag specifies the longitude, latitude, and altitude of
the point, in that order, separated by a comma.
˛ Create KML
placemarks
˛ Update KML
dynamically
˛ Link to networks
chapter
in this chapter
310 Part IV — Google Earth Hacks
Generating KML from Existing Data
To demonstrate how easy it is to create a KML document with appropriate information, you
can adapt the data that was generated for the database in Chapter 11 (local Grantham businesses)
and instead generate a KML document.
To generate the information, you follow the same basic method as in Chapter 11 to generate
the XML that was previously parsed by JavaScript. Unlike the Google Maps example, where
the XML was loaded on a business type-by-type basis, you can dump the entire database and
organize the information automatically by type by using the Google Earth folder system. The
Google Earth application can handle the filtering and selection process.
The KML document defines one set of data and therefore has only one folder in it.To further
subdivide information you have to add subfolders. The result is a KML file structure that looks
like this:
  Grantham Business Folder
■ Banks
■ Pharmacies
■ Restaurant
■ Sports
■ Travel
The Perl script for generating the file is as follows:
#!/usr/bin/perl
use DBI;
use strict;
my $dbh = DBI->connect( ‘dbi:mysql:database=mapsbookex;host=db.maps.mcslp.com’,
‘mapsbookex’,
‘examples’,
);
You start with the opening structure. The tag defines that the folder is open and the
contents should be displayed when the file is first opened within Google Earth:
print<


Grantham features
1
EOF
The SQL statement picks all available options but orders the information by type so that the
individual folders can be created:
Chapter 16 — Generating Google Earth Feeds 311
my $sth = $dbh->prepare(sprintf(‘select * from ch10 order by type’));
$sth->execute();
To generate the individual tags, you only have to generate a suitable XML
structure. The $currenttype variable is used to identify first the current type so that you can
determine whether to create a new folder. The $count variable is used to identify the count to
determine whether the closing tag needs to be created (for the first change of type, it doesn’t).
Note that for the subfolders, you don’t open the contents; this doesn’t affect whether the
enclosed points are displayed, only whether the list of points in the folder is displayed:
my ($currenttype,$count) = (‘’,0);
while (my $row = $sth->fetchrow_hashref())
{
if ($currenttype ne $row->{type})
{
if ($count > 0)
{
print “
”;
}
printf(“\n%s\n0\n”,$row->{type});
$currenttype = $row->{type};
}
$count++;
Each individual placemark is composed of the name, coordinates, and address of each entity in
the database:
printf(“\n%s\n
%s,%s
;
\n \n%s,%s,0 ;
\n
\n”,
$row->{title},
$row->{adda},
$row->{addb},
$row->{lng},
$row->{lat},
);
}
$sth->finish();
Finally, you close the last entity type folder, the global KML folder, and finally the KML document
itself:
print(“
\n
\n”);
Using the information that is in the final version of the database created in Chapter 11, the
preceding script generates the following KML. The quantity of KML included here is shown
to provide an overview of the overall structure, as well as the individual points. Even so, the
document has been shortened for inclusion in the book.
312 Part IV — Google Earth Hacks
The code for this chapter (and all chapters of the book) is available on the web site that accompanies
the book, http://maps.mcslp.com.



Grantham features
1

banks
0

Yorkshire Bank
10 High St,Grantham, NG31 6PU, United Kingdom


-0.642539,52.913,0



Abbey
1 St. Peters Hill,Grantham, NG31 6QB, United ;
Kingdom


-0.64075,52.9112,0



HSBC Bank plc
88 Westgate,Grantham, NG31 6LF, United ;
Kingdom


-0.644091,52.9119,0



Lloyds TSB Bank plc
42 St. Peters Hill,Grantham, NG31 6QF, United ;
Kingdom


-0.641202,52.9101,0



Alliance & Leicester plc
34 St. Peters Hill,Grantham, NG31 6QF, United ;
Kingdom


-0.641202,52.9101,0
Chapter 16 — Generating Google Earth Feeds 313


...

Travel Quest
8-9 Westgate,Grantham, NG31 6LT, United ;
Kingdom


-0.643614,52.9119,0



Voyager
99 Westgate,Grantham, NG31 6LE, United ;
Kingdom


-0.644091,52.9119,0



Quality Travel
50 East St,Grantham, NG31 6QJ, United Kingdom


-0.640053,52.9121,0



Global Flights
99 Westgate,Grantham, NG31 6LE, United ;
Kingdom


-0.644091,52.9119,0





If you save the file (for example, using redirection) and then open the file within Google Earth
(by selecting File➔Open), you get a window similar to the one shown in Figure 16-1.
You can see that Google Earth has zoomed to a point that shows all the loaded
tags. You can also see, in the panel on the left, that the folders you created within the KML are
displayed. Unlike Google Maps, where individual business types had to be enabled and disabled
through a JavaScript function you created, Google Earth now handles the selection process
for you. Figure 16-2 shows just banks and restaurants displayed on the map.
Of course, generating a static file and distributing it is not particularly efficient, especially if the
data changes frequently.
314 Part IV — Google Earth Hacks
FIGURE 16-1: Opening the Chapter 11 KML information.
FIGURE 16-2: Selecting folders for display.
Chapter 16 — Generating Google Earth Feeds 315
Generating KML Dynamically
The static KML file generation shown in the previous section is less than ideal when the data
changes regularly. For static elements, such as documenting the location of mountains or seas,
the information displayed is unlikely to change. For business details, the information is likely to
change at least monthly.
With some applications, you might want to update the information even more frequently than
that. For the moment, you’ll just handle the dynamic generation of information and how that
can be loaded into the Google Earth application.
Changing the Script
To generate the information dynamically, a similar change to that used when moving from the
static XML to dynamic XML system used in Chapters 9 and 10 for Google Maps applications
is required. The change comes down to a single line: The correct HTTP header and content
type must be output by the script.
Google Earth supports two file types: KML and KMZ. The former, the uncompressed version,
requires the following content type:
application/vnd.google-earth.kml+xml xml
For KMZ files use the following content type:
application/vnd.google-earth.kmz kmz
The script will be generating KML, so the change is very straightforward. The entire script is
included here for reference to show that there are no differences between this and the static
generation version:
#!/usr/bin/perl
use DBI;
use strict;
use CGI qw/:standard/;
print header(-type => ‘application/vnd.google-earth.kml+xml xml’);
my $dbh = DBI->connect( ‘dbi:mysql:database=mapsbookex;host=db.maps.mcslp.com’,
‘mapsbookex’,
‘examples’,
);
print<


Grantham features
1
EOF
316 Part IV — Google Earth Hacks
my $sth = $dbh->prepare(sprintf(‘select * from ch10 order by type’));
$sth->execute();
my ($currenttype,$count) = (‘’,0);
while (my $row = $sth->fetchrow_hashref())
{
if ($currenttype ne $row->{type})
{
if ($count > 0)
{
print “
”;
}
printf(“\n%s\n0\n”,ucfirst($row-> ;
{type}));
$currenttype = $row->{type};
}
$count++;
printf(“\n%s\n
%s,%s
\n ;
\n%s,%s,0\n
\n”,
$row->{title},
$row->{adda},
$row->{addb},
$row->{lng},
$row->{lat},
);
}
$sth->finish();
print(“
\n
\n”);
Although not demonstrated in this script, error handling with dynamic KML files is very
strict, because Google Earth refuses to use the network link if the file is not valid. Therefore, all
dynamic KML generators should always return an HTTP response of 200.To show an error,
generate the appropriate KML, for example:



Error loading file
1


Care should be taken to ensure you follow this approach.
Chapter 16 — Generating Google Earth Feeds 317
Subscribing to a Network Resource
The CGI method shown in the previous section generates the necessary KML with the correct
headers and structure. However, you need to load the file within Google Earth using a specific
option so that that the KML is requested from the URL, rather than loaded from a file.
To add a network resource to your Google Earth application, you choose Network Link from
the Add menu in Google Earth. You are presented with a window like the one shown in
Figure 16-3.
FIGURE 16-3: Opening Network resources in Google Earth.
Give the Network Link a name. In the Location field, provide the URL of the CGI script that
generates the KML.To use the previously detailed example script, use the URL http://
maps.mcslp.com/examples/ch16-02.cgi.
You should get a Google Earth display like the one in Figure 16-4.
318 Part IV — Google Earth Hacks
FIGURE 16-4: Viewing the dynamic Grantham entities.
Here you can see that the resulting folder structure is more or less identical to that produced
using the static option. The difference is that the information is being loaded from KML that
has been generated dynamically. Now the database can be updated and the Google Earth
application can load the updates. The information is manually refreshed when you open the
application, when you re-select the Network Link, or when you specifically request a refresh by
right-clicking the Network Link and selecting Refresh.
Using the Auto-Update Function
The network source for KML can be further enhanced by enabling the auto-update function.
Using this option, the network KML source is regularly reloaded at an interval that you can
specify.To demonstrate this functionality in action, first change the Grantham network
resource to automatically reload at specific intervals. Right-click the link generated in the previous
option and select Edit. You should see the window in Figure 16-5.
Click the checkbox for Refresh Parameters and then set the parameters. You can specify that
the refresh occurs at specified intervals or when the view changes (including setting a delay
after the view has changed).
Within the book, it’s difficult to demonstrate this in perfect action, but you can see some simple
changes. First, see Figure 16-6, which shows Google Earth and the dynamic KML in its
initial state. Refresh has been set for every five minutes.
Chapter 16 — Generating Google Earth Feeds 319
FIGURE 16-5: Setting refresh options.
FIGURE 16-6: Dynamic KML.
320 Part IV — Google Earth Hacks
Using the script in Chapter 11 that adds new entities to the database, Saddler’s, Shoe Shops,
and Stationers have been added to the database. Figure 16-7 shows the new changes after the
automatic reload.
FIGURE 16-7: Automatic reload of KML data.
In this example, the data is unlikely to be reloaded and regenerated so regularly, but the refresh
system can be used to help regenerate all sorts of information. For example, KML could be
generated to show the current location of an aircraft or a team on an expedition. Each reload
would update the position accordingly.
Creating a Self-Reloading KML File
Not only can this be controlled from within the Google Earth application, but you can set the
refresh parameters from within a KML file. You cannot set it in the file that you generate, but
you can instead generate a static KML file that refers to the dynamic KML file and includes
the refresh parameters.
Following is a sample of the KML file, designed to refresh the dynamic example:
Chapter 16 — Generating Google Earth Feeds 321



1

ExtremeTech Google Maps: Grantham Entities

http://maps.mcslp.com/examples/ch16-03.cgi
onInterval
300
onStop
7




Looking at the individual elements, you can pick out the main points. First, you define the
name of the network link:
ExtremeTech Google Maps: Grantham Entities
Then you specify the URL, the refresh mode, the interval (specified in seconds), and the viewing
format. Open the KML file in Google Earth, and the dynamic KML will automatically be
loaded.
Adding Icons
You can stylize a tag with a custom icon by using the Style element. The
Style element enables you to set custom styles for a tag. The IconStyle
element defines the icon details. For example:

The element defines the location of the icon graphic. In this case, the location specified
is the same as that used for the Bank icon example demonstrated in Chapter 11. You can
use a single source file for the icon and extract the icon using the x/y reference of the left/bottom
edge and the height and width of the icon (using the and tags).
For the final example, you’ll use a simple icon, chosen using the type name to generate the
icon, just as used in Chapter 11. The resulting script is shown as follows:
322 Part IV — Google Earth Hacks
#!/usr/bin/perl
use DBI;
use strict;
use CGI qw/:standard/;
print header(-type => ‘application/vnd.google-earth.kml+xml xml’);
my $dbh = DBI->connect( ‘dbi:mysql:database=mapsbookex;host=db.maps.mcslp.com’,
‘mapsbookex’,
‘examples’,
);
print<


Grantham features
1
EOF
my $sth = $dbh->prepare(sprintf(‘select * from ch10 order by type’));
$sth->execute();
my ($currenttype,$count) = (‘’,0);
while (my $row = $sth->fetchrow_hashref())
{
if ($currenttype ne $row->{type})
{
if ($count > 0)
{
print “
”;
}
printf(“\n%s\n0\n”,ucfirst($row-> ;
{type}));
$currenttype = $row->{type};
}
$count++;
printf(“\n%s\n
%s,%s
\n”,
$row->{title},
$row->{adda},
$row->{addb},
);
Chapter 16 — Generating Google Earth Feeds 323
printf(“”,lc($row->{type}));
printf(“\n1\nrelativeToGround ;
\n%s,%s,250\n
\n”,
$row->{lng},
$row->{lat},
);
}
$sth->finish();
print(“
\n
\n”);
The preceding script also introduces another concept. You extrude the point from the ground.
This creates a line between the icon used to represent the entity and its actual location on the
ground.To do this, when defining the tag of the KML you add the extrude option:
1
You then need to set the altitude of the point, first by defining the relationship between the actual
point on the ground and the elevation at which you want to create the tag:
relativeToGround
The relativeToGround specification sets the system so that the height is relative to the
height of the ground where the marker is created. So, if you specify the altitude of the point as
250m, but the elevation of the location is already 68m, then the marker would display at 318m
above sea level.
Other options are clampedToGround (the altitude is ignored, this is the default mode) and
absolute, where the altitude is exactly as specified (250m would display at 250m above sea
level, even if the elevation of that point was more than that amount).
Figure 16-8 shows the resulting information in Google Earth. You can see how the markers
appear to float above the map, but a line is clearly connected from the marker to the real latitude/
longitude of the point.
Because the information is floating, rotating the map shows the icons constantly associated
with the right location (see Figure 16-9).
Although the view is quite confusing here, users have the ability to include and exclude the different
businesses they want to view because businesses are grouped into appropriate folders.
The organization (providing the KML is generated appropriately) is automatic and is a lot easier
to use than the system that had to be developed within Google Maps.
324 Part IV — Google Earth Hacks
FIGURE 16-8: Using custom icons and extruding information.
FIGURE 16-9: Viewing icons with a tilted and rotated map.
Chapter 16 — Generating Google Earth Feeds 325
Wrapping Up
Google Earth handles a lot of the application logic that requires JavaScript and programming
in Google Maps.To create similar effects within Google Earth you need only generate the
appropriate KML.
This chapter covered the basics of generating markers and points within KML. The basic point
is easy to create. In most cases it requires only the latitude and longitude of the point. Markers
can then be further customized by adding icons and you can even help to improve the visibility
by extruding the icon above the map, making the marker more visible, particularly when the
map is rotated or tilted.
You also saw how to refresh KML data. The refresh system allows KML to be automatically
reloaded, and that provides an element of interactivity that enables sequences or time-based
interaction to be overlaid on top of the Google Earth satellite data.

History and Planning
with Google Earth
Location Photos
Iwas fortunate enough to go Pompeii during the writing of this book.
Pompeii is a fascinating place, because almost the entire town (or at least
that which has been uncovered) is intact—an amazing feat considering it
is almost 2,000 years old and was buried under many feet of volcanic ash
from the eruption of Mount Vesuvius in 87 A.D. As a Roman town it offers
a unique insight into Roman life.
While there I took hundreds of photos, but though I can show and describe
the contents of the photos, it is difficult to give a context in terms of the
layout of the town to someone who has never been there.
Using Google Earth, the photos taken at Pompeii can be shown in the context
of a satellite shot of the Pompeii site. The view can include the heading
and even the photo itself to help the viewer make sense of both the satellite
image and the photo.
Using a Photo for a Placemark
In Chapter 16, icons were used to highlight particular areas on the map that
related to specific businesses. Using a photo as an alternative mark is one
way of highlighting the places you visited while on vacation. It can also be
used with any photo to give the photos some context. For example, Realtors
could use photos of a property and a satellite image (or the view from the
windows of different rooms) to show what the real estate looks like from
different directions.
When using this method, be aware that the photos may overlap each other.
Some careful placing—using altitude and extrusion—to highlight the
points can help to make the individual items visible. Figure 17-1 shows an
example using icons in this way, and Figure 17-2 shows the same information
but with a slightly different camera angle, to show how the overlapping
of the icons can obscure, rather than help, the display of information.
To achieve this display, a number of different techniques were used.
˛ Create placemarks
from photos
˛ Create KMZ files
˛ Generate
3D models
chapter
in this chapter
328 Part IV — Google Earth Hacks
FIGURE 17-1: Using photos for icons.
FIGURE 17-2: An alternative photo-based icon view.
Chapter 17 — History and Planning with Google Earth 329
Scaling the Icon
By default, Google Earth creates a relatively small icon based on the image that is provided,
regardless of the size of the image. This is to prevent the image from dominating the map,
when it is only really referring to a placemark.
To alter this behavior, styles must be defined that specify the format of the icon and the label
used to highlight the placemark. The key element in the following code is the Icon reference,
which refers to the image that will be used for an icon, and the scale entity, which scales the
size of the icon in the placemark:

Figure 17-3 shows the difference between a non-scaled and a scaled icon.
FIGURE 17-3: A non-scaled (small) and scaled (large) icon.
330 Part IV — Google Earth Hacks
Setting a View
When dealing with photographs, the direction in which the camera was pointing when the
photograph was taken is a significant part of what makes the photo special. For example, a
photo of the Bay of Naples, where Pompeii is located, can show a number of different elements.
If the photo was taken from Naples facing the southeast, you’d be taking a photo of
some mountains.To a visitor to the area, they are quite obviously the mountains to the east of
Sorrento, but they could easily be confused for a picture of Vesuvius. By adding a heading and
direction to a placemark, the direction of the camera lens is obvious.
To achieve this, a LookAt element must be included with each tag.When the user doubleclicks
a tag, the information in the LookAt tag is used to determine the camera (or eye) view
point within Google Earth. There are six elements to the LookAt fragment:
  Longitude: The longitude of the point.
  Latitude: The latitude of the point.
  Altitude of the point: (Optional.) The altitude of the point.
  Range: The altitude of the camera or eye.
  Tilt: The angle of the camera.
  Heading: The compass heading of the camera.
Thus a view point equal to a bird’s-eye view of the main square in Pompeii can be created using
the following code:

14.4850001287074
40.74889804414286
0
254.0000000037327
67.63540763119519
-17.02539065750064

The LookAt element is placed immediately within the Placemark element:

Council Building
1

...


When the placemark is double-clicked, the camera moves to this location.When it is single
clicked, nothing happens.
Chapter 17 — History and Planning with Google Earth 331
Adding Detail to a Placemark
The info window in Google Maps is an effective way of providing more detailed information
for a placemark. Google Earth automatically creates these windows based on information
within the tag within a placemark. For example, the Pompeii town square
placemark can be described using this:
The Pompeii town square photo was taken here.
The content in this section can be plain text, as shown here, but it can also be HTML.To
embed HTML it must be escaped. There is a longer solution for this that requires escaping the
HTML (particularly the angle brackets), like this:
The main square of Pompeii, looking towards the ;
temple. <img src=”images/DSC01155.JPG”>

A simpler method is to use the XML data embedding format. For example, you could include
the photo in the placemark window using the following:
temple. ]]>
Using this method, the points on the map could be returned to standard placemarks and the
placemark window used to display the photo.
Final KML
Putting everything in the previous sections together, you can build a single KML file that
describes a number of points, and the photos taken at those points, for the trip to Pompeii.
Only three points are detailed here, but an unlimited number could theoretically be introduced:



Pompeii.kmz

Pompeii
1

Council Building
the main square. ]]>
1

14.48469513913974
40.75006838268123
0
498.0008872980769
67.6354076394704
105.3299769917819

332 Part IV — Google Earth Hacks

1
relativeToGround
14.48469513930003,40.75006838317384,0



Main Square from Temple
this time from the temple and looking through the arch from one of the ;
streets leading off the square. ]]>


14.48442827437565
40.75001642868543
0
254.000032893549
67.63460936190043
160.5058044783431


1
relativeToGround
14.48442827406559,40.7500164285698,0



Pompeii Main Square
towards the temple. ]]>
1

14.4850001287074
40.74889804414286
0
254.0000000037327
67.63540763119519
-17.02539065750064


1
relativeToGround
14.4850001287074,40.74889804414284,0





Figure 17-4 shows the main map, with Figures 17-5 and 17-6 showing two of the photos from
the available points. Note that in each case the placemark has been double-clicked to move the
map to the new viewpoint.
Chapter 17 — History and Planning with Google Earth 333
FIGURE 17-4: Basic placemark in Pompeii.
FIGURE 17-5: A council building in Pompeii.
334 Part IV — Google Earth Hacks
FIGURE 17-6: Looking backwards toward the main square.
Generating the Information in Google Earth
Although it is tempting to produce all of the information completely manually (which is
certainly possible for typical addresses and locations that can be determined using techniques
shown earlier in this book), an easier alternative is to use the Google Earth application.To
create a new point, choose File➔Add➔New Placemark.
All of the options, including the camera view, description, elevation, and extrusion information
can be set entirely within the panel. Click the Advanced checkbox to set the additional options.
You can see the various settings across three different panels: Style (Figure 17-7), Location
(Figure 17-8), and View (Figure 17-9).
Once you have created the various placemarks that you want, you can save the placemarks into
a separate file and even generate a suitable folder structure. If you have included graphics for
icons into your placemarks, Google Earth will create a KMZ file rather than a KML file that
incorporates the KML and images into a single Zip file.
The same method can be used with your own creations.
Chapter 17 — History and Planning with Google Earth 335
FIGURE 17-7: Setting a placemark Style.
FIGURE 17-8: Setting a placemark Location, altitude, and extrusion.
336 Part IV — Google Earth Hacks
FIGURE 17-9: Setting the View for a placemark.
Generating a KMZ File
Generating a plain KML file is fine when either the information or the icons and other data
are available freely on the Internet. However, there are times when you want to create a standalone
file that incorporates the KML with the icons, images, and any other files that make
your Google Earth file.
The format is quite straightforward. It is simply a Zip file that contains the KML and images.
For clarity, you should use the following format:
  doc.kml: The main KML file.
  images/: A directory for icons and photos to be included in the file.
Within the KML, you can refer to files directly according to this structure. For example, a
photo could be included in the description for a placemark using this:

You can use any appropriate Zip-compatible software. From a Unix or Linux machine (including
Mac OS X) with a command-line client, you could use the following, for example:
$ zip -r Pompeii.kmz doc.kml images/
Chapter 17 — History and Planning with Google Earth 337
Within Windows you can use WinZip to create a suitable file, but you need to rename the file
to have the .kmz extension.
Revisiting the Realtor’s Toolkit
In Chapter 12 examples of both archaeological- and realty-related tools in Google Maps were
examined. Both followed similar principles, the overlay of information that is known about a
location, either in the past or the potential in the future.
Within Google Earth the same principles can be used to display information, either in an
identical manner or in a far more interesting alternative.
Using an Overlay
A simple overlay was used in Chapter 12 to suggest a potential office plan and layout. The display
was simplistic, partially because of limitations in Google Maps, but also because with just
a flat image to play with, there is very little that could be done to alter the view and representation
of the office plan.With Google Earth you can follow the same principles to add an image
overlay to the map.
Figure 17-10 shows the overlay in an almost identical situation to the one used in Chapter 12.
FIGURE 17-10: Display of a simple overlay.
338 Part IV — Google Earth Hacks
Because this is Google Earth, the overlay is of course attached to the map. If the view is
rotated or tilted, the overlay rotates and tilts with the map accordingly, as demonstrated in
Figure 17-11.
FIGURE 17-11: Rotated map and overlay.
The KML generated in the preceding process shows how the image is overlaid. Unlike Google
Maps, where the TPhoto extension was used, Google Earth supports the operation directly
within the application using KML to define the structure:



New Office Layout.kmz

New Office Layout
77ffffff

images/ch11-overlay.png
0.75


35.2838663590014
35.27641626890076
Chapter 17 — History and Planning with Google Earth 339
-97.58248738034948
-97.59315654329896




The key element is how the location of the overlay is associated with the map. The north,
south, east, and west elements set the borders of the image as it will be associated on the
map. The other elements are as follows:
  Icon: Defines the overlay image.
  viewBoundScale: Specifies how much of the display real estate should be used to
show the overlay.
  Color: Specifies the color and opacity of the overlay. The color is specified as four twocharacter
hexadecimal values, between 0 and 255. The first value is the alpha (opacity)
channel. The value specified in this case is 77 (hex), or 119 decimal, or about 47 percent.
Although the information displayed is useful, with a 3D environment it would be much better
to give a proper 3D representation of the offices.
Creating a 3D Structure
To create a 3D structure, for example, the representation of an office, you combine latitude/
longitude references with extrusion and altitude to generate a “solid” 3D object on the map.
The key is the Polygon element, a base structure that defines a simple multi-point shape
made up of the lines that connect latitude/longitude points.Without extrusion, a Polygon
would draw a simple shape.With extrusion and altitude you solidify the polygon. The basic
structure for a polygon is as follows:

1
1
relativeToGround



-97.59277582168579, 35.282008632343754,100
-97.59277582168579, 35.278137436300966,100
-97.59017944335938, 35.278137436300966,100
-97.59017944335938, 35.282008632343754,100
-97.59277582168579, 35.282008632343754,100




340 Part IV — Google Earth Hacks
The outerBoundary element defines the outer line of the polygon. Everything inside is considered
part of the solid shape. The coordinates are specified, one per line, but really you need
only separate each coordinate by a space. Remember, just as with bounding boxes in Google
Maps, you must specify at least one more point for each side of the shape because you are
drawing lines from point to point to point. In this case, four sides require five points, each of
the four corners and the first corner again to complete the polygon.
You can also generate shapes based on multiple polygons by using the MultiGeometry
option, including each Polygon definition within the MultiGeometry element.
Using these techniques, the simple flat image overlay demonstrated earlier could be redeveloped
into a 3D model of the office building using the following KML:





Sales Building
The new sales building, showing a readical structure to ;
provide a view for
clients.

#myDefaultStyles


1
1
relativeToGround


-97.58590936660767, 35.27654336061367, ;
50 -97.58590936660767,
35.28360260045482, 50 -97.58260488510132, ;
35.28360260045482, 50 -97.58260488510132,
35.27654336061367, 50 -97.58590936660767, ;
35.27654336061367, 50





1
1
relativeToGround
Chapter 17 — History and Planning with Google Earth 341


-97.58590936660767, 35.279, ;
100 -97.58590936660767, 35.28360260045482,
100 -97.58260488510132, 35.28360260045482, ;
100 -97.58260488510132, 35.279, 100
-97.58590936660767, 35.279, 100





1
1
relativeToGround


-97.58590936660767, 35.28, ;
250 -97.58590936660767, 35.28360260045482,
250 -97.58260488510132, 35.28360260045482, ;
250 -97.58590936660767, 35.28, 250







Administration building
A straightforward office structure
#myDefaultStyles

1
1
relativeToGround


-97.58904218673706, ;
35.282008632343754,150 -97.58904218673706,
35.278137436300966,150 -97.58638143539429, ;
35.278137436300966,150 -97.58638143539429,
35.282008632343754,150 -97.58904218673706, ;
35.282008632343754,150






Packaging/delivery warehouse
A lower structure, open plan internally.
342 Part IV — Google Earth Hacks
#myDefaultStyles

1
1
relativeToGround


-97.59277582168579, ;
35.282008632343754,100 -97.59277582168579,
35.278137436300966,100 -97.59017944335938, ;
35.278137436300966,100 -97.59017944335938,
35.282008632343754,100 -97.59277582168579, ;
35.282008632343754,100







The resulting 3D office plan can be seen in Figure 17-12, and, because it is a proper 3D structure,
Figure 17-13 shows an alternative view.
FIGURE 17-12: A 3D office demonstration.
Chapter 17 — History and Planning with Google Earth 343
FIGURE 17-13: An alternative view.
Unfortunately, I am no 3D artist, but you can find numerous other examples of 3D structures
defined within the Google Earth application when you add the Buildings overlay to your map.
Wrapping Up
The facilities in Google Earth can turn the basic principles learned in Google Maps into a
much richer environment for showing information. Because the map can be rotated and
manipulated, unlike the flat model used by Google Maps, you can develop much more interesting
views of data and information, such as holiday photos. Because direction and orientation
are implied in the display, the photos are given much more context than simple pushpoints on
the map.
Using built-in 3D modeling, you can represent offices, buildings, and other elements in a way
that provides a much easier-to-understand representation of a structure.With some manipulation
of the camera, you could even give a representation of what a buyer could expect to see
through the windows of stores in the buildings.

˛ Useful resources
for Google.com
˛ Additional sources
of information
˛ Geocoder links
˛ Google Maps tools
˛ Other mapping
services
appendix
in this appendix
Resources
Google Maps has generated a significant following, and this has, in
turn, led to a stunning array of web sites that provide information,
examples, tutorials, and help for working with and developing
Google Maps applications. I’ve distilled the basics of these links into this
appendix.
Please note that the information in this appendix was correct at the time it
was written. For a more complete and up-to-date resource page, please visit
the MCslp Map Works web site (http://maps.mcslp.com).
Google Resources
As a web company, Google has done a lot to provide access to as much
information as possible on as many different sites as possible. The primary
considerations for this appendix, of course, are the main map sites that
Google uses to provide the information.
You can view any part of the world through the Google Maps interface.
Google also has specially allocated URLs that take you to specific countries
so that you don’t have to go to the generic U.S. site and search or scroll until
you find the area you want. Of course, you can go wherever you like when
developing your own Google Maps.
Table A-1 provides a list of the main sites, including Google Moon.
Table A-1: Google Map Services
Map URL
Google Maps USA http://maps.google.com
Google Maps UK http://maps.google.co.uk
Google Maps Japan http://maps.google.co.jp
Google Maps China http://bendi.google.com
Google Moon http://moon.google.com
Google Earth http://earth.google.com
346 Part IV — Google Earth Hacks
The Google Moon site is unique in that it shows only the area (and the associated markers)
used for the moon landings. The site was released on July 20, 2005, to mark the 36th anniversary
of the Apollo 11 moon landing.
Google Maps API
www.google.com/apis/maps/
You can find more information, read the documentation, and view help pages on the main
Google Maps API site.
Google Maps API Documentation
www.google.com/apis/maps/documentation/
This is the main documentation page for the entire Google Maps service. The information
provided on this page is the current version of the Google Maps API documentation. You
should visit the site regularly to ensure that there have not been any important changes to the
documentation and API.
Google Maps API Help
www.google.com/apis/maps/faq.html
Here you can find the FAQ for working and using the Google Maps API.
Google Web API
www.google.com/apis/
The Google Web APIs provide an interface to the Google system for searching the Google
databases for information.
Google Maps Groups
There are two groups for Google Maps:
  The Google Maps group (http://groups-beta.google.com/group/Google-
Maps) provides basic information and discussion on the Google Maps service.
  The Google Maps API group (http://groups-beta.google.com/group/
Google-Maps-API) provides discussion of the Google Maps API and information on
how to construct web sites based on the Google Maps system.
Appendix A — Resources 347
Information Sources
To get the most out of the Google Maps service, you will almost certainly need to make use of
additional Google Maps resources and web sites. This section lists some of the key components,
including sites that themselves provide more information on and links to the Google
Maps service.
Google Maps Mania
http://googlemapsmania.blogspot.com/
This blog documents Google Maps services, changes to the documentation and service offerings,
and general information on the web-mapping world. Overall, it provides one of the
best ranges of resources, as well as links both to vital resources and to example Google Maps
services.
Maplandia.com
The Maplandia site provides links to Google Maps pages that take you straight to a specific
country, town, city, or other location through a series of geographical locations. Once you’ve
found the location you want, you can further search for locations within the specific area.
Google Maps on Wikipedia
http://en.wikipedia.org/wiki/Google_maps
The Google Maps entry on Wikipedia provides a range of additional links and information on
the Google Maps service and associated web sites.
Google Sightseeing
www.googlesightseeing.com/
This site shows images taken from Google Maps and Google Earth that show interesting
structures or images.
Geocoders
Google does not provide a geocoding mechanism (that is, a way of mapping a given address or
worldwide location into the latitude and longitude required to redirect Google Maps to a specific
location). This section lists a number of solutions to this problem. You can use some of
them directly within a Google Maps browser application; others can be used from within a
server-side application to build a list of points for your main application.
348 Part IV — Google Earth Hacks
MGeocoder
http://brainoff.com/gmaps/mgeocoder.html
MGeocoder provides a JavaScript overlay that enables you to search directly for a given
location.
Geocode America
www.geocodeamerica.com/
This is a web service–based interface to a Geocode database for America. You can supply any
U.S. address and obtain the Geocode information you require.
Geocoder
http://geocoder.us/
This is another web service–based interface for finding Geocodes from addresses. Primarily a
U.S. service, Geocoder also provides a Canadian and Argentinean service.
Google Maps Tools
A number of tools have been produced to make it easier to produce Google Maps and to
provide examples and extensions to the Google Maps functionality.
gMap it!
The gMap extension for Firefox allows you to find and search for information based on publicly
listed phone numbers, which can then be used to display the location and directions
within Google Maps.
Mobile GMaps
www.mgmaps.com/
Being able to use Google Maps on a mobile device is obviously a good combination, and
Mobile GMaps enables you to use Google Maps on mobile devices (phones, PDAs) that
support the J2ME ( Java Mobile Environment) standard.
MapBuilder
www.mapbuilder.net/
MapBuilder provides a complete web environment for building Google Maps. You can specify
locations, add HTML (to be displayed in map points and pop-ups), and choose your point
Appendix A — Resources 349
icon. The result is a web page that you can download and use in your own applications once
you use your own Google Maps API key.
MapKi
http://mapki.com
A Wiki that provides information and resources on using mapping APIs, including Google
Maps.
Competitors and Alternatives
Although Google Maps and Google Earth are not the first search services available on the
Internet, they were the first to make a publicly available API to enable programmers and other
individuals to embed Google Map–based applications into their own web pages instead of
redirecting users to another site.
MapQuest
http://mapquest.com/
The MapQuest site provides street maps only of the U.S.; Canada; and much of western,
southern, and northern Europe. MapQuest is part of AOL.
Virtual Earth
Virtual Earth is part of the Microsoft Network (MSN) web site; it overlays satellite imagery
and aerial photography of the earth over a 3D map. As well as providing map-search functions,
Virtual Earth can also show maps according to specific addresses, towns, or cities, or via a business
name or type search.
Yahoo! Maps
http://maps.yahoo.com/
Yahoo! Maps provides mapping information for the U.S. and Canada.
A9 Maps
Amazon’s search engine, A9, has a mapping service that provides U.S. street maps and driving
directions. In an interesting twist to the basic street-mapping service, A9 Maps also provides
street-level photography that allows you to see what a street looks like in addition to viewing its
location on the map.
350 Part IV — Google Earth Hacks
Multimap.com
www.multimap.com/
Multimap.com is a U.K.-based provider of mapping information. It is a full road-mapping service
(for the U.K., continental Europe, and the U.S.) combined with aerial photographs and
local information. Multimap was one of the early Internet-based mapping companies, and U.K.
companies often use the site to direct people to businesses.
Map24
http://map24.com
Map24 is an Internet mapping application that uses a Java-based interactive interface for
building the maps and providing the interactive elements of the Map interface. The site currently
supports the U.S., Europe, Brazil, and the Middle East.














Additional Support
In addition to this user guide, Google offers a number of resources that can help you use and enjoy
Google Earth. These include:
l FAQs: View a list answers to frequently asked questions (FAQs) about Google Earth.
l Google Earth Help Center: Use the Help Center at any time to find additional information.
l Troubleshooting: View information that specifically pertains to troubleshooting issues with
Google Earth.
l Google Earth Community: Learn from other Google Earth users by asking questions and
sharing answers on the Google Earth Community forums.
Navigating in Google Earth
In Google Earth, you see the Earth and its terrain in the 3D viewer. You can navigate through this
3D view of the globe in several ways:
l Using a mouse
l Using the navigation controls
You can also manipulate your view of the earth by tilting the terrain for perspectives other than a topdown
view. Finally, you can reset the default view for a north-up, top-down view wherever you are.
Using a Mouse
To get started navigating with your mouse, simply position the cursor in the middle of the 3D viewer
(image of the earth), click one of the buttons (right or left), move the mouse and note what happens
in the viewer. Depending upon which mouse button you press, the cursor changes shape to indicate
a change in behavior. By moving the mouse while pressing one of the buttons, you can:
l Drag the view in any direction
l Zoom in or out
l Tilt the view (requires middle button or scroll wheel)
l Rotate the view (requires middle button or scroll wheel)
The following list describes all the actions you can accomplish using the mouse.
l Move the view in any direction (north, south, east, or west) - To move the view, position
the mouse cursor on the viewer and press the LEFT/main mouse button.
Notice that the cursor icon changes from an open hand to a closed hand . Pull the
viewer as if the hand cursor is like a hand on an actual globe, and you want to drag a new
part of the earth into view.
You can drag in any direction to reveal new parts of the globe, and you can even drag in
circular motions.
l Drift continuously across the earth - If you want to drift continuously in any direction, hold
the left/main mouse button down. Then, briefly move the mouse and release the button, as if
you are "throwing" the scene. Click once in the 3D viewer to stop motion.
l Zoom in - There are a number of ways to zoom in with the mouse.
m You can double-click anywhere in the 3D viewer to zoom in to that point. Single-click
to stop, or double-click to zoom in more.
m If your mouse has a scroll wheel, use it to zoom in by scrolling towards you. Use the
ALT (alt/option on the Mac) key in combination with the scroll wheel to zoom in by
smaller increments.
m You can also position the cursor on the screen and press the RIGHT mouse button
(CTRL click on the Mac). Once the cursor changes to a double arrow, move the
mouse backward or pull toward you, releasing the button when you reach the desired
elevation.
If you want to zoom continuously in, hold the button down and briefly pull the mouse
down and release the button, as if you are "throwing" the scene. Click once in the
viewer to stop the motion.
m On some Macintosh laptops, you can drag two fingers across the trackpad to zoom in
and out.
l Zoom out - There are a number of ways to zoom out with the mouse.
m Using the RIGHT mouse button (CTRL click on the Mac), double-click anywhere in
the 3D viewer to zoom out from that point. The viewer will zoom out by a certain
amount. Single-click to stop, or right double-click (CTRL click on the Mac) to zoom out
more.
m If your mouse has a scroll wheel, you can use the scroll wheel to zoom out by
scrolling away from you (forward motion). Use the ALT (alt/option on the Mac) key in
combination with the scroll wheel to zoom out by smaller increments.
m You can also position the mouse cursor on the screen and press the RIGHT mouse
button (CTRL click on the Mac).
Once the cursor changes to a double arrow, move the mouse forward or push away
from you, releasing the button when you reach the desired elevation.
If you want to zoom continuously out, hold the right button (CTRL click on the Mac)
down and briefly push the mouse forward and release the button, as if you are
"throwing" the scene. Click once in the viewer to stop motion.
l Tilt the view - If your mouse has a either middle button or a depressible scroll wheel, you
can tilt the view by depressing the button and moving the mouse forward or backward. If
your mouse has a scroll wheel, you can tilt the view by pressing the SHIFT key and scrolling
DOWN to tilt the earth to "top down" view, or scrolling UP to tilt the earth for horizon view.
See Tilting and Viewing Hilly Terrain for more information.
l Rotate the view - If your mouse has either a middle button or a depressible scroll wheel,
you rotate the view to the left by clicking on the middle button and moving the mouse to the
left. To rotate the view right, click on the middle button and move the mouse to the right. You
can also use the CTRL ( on the Mac) key in combination with the scroll wheel to rotate the
view. Press CTRL ( on the Mac) and scroll UP to rotate clockwise, CTRL ( on the Mac)
+ scroll DOWN to rotate counter-clockwise. See Tilting and Viewing Hilly Terrain for more
information.
l Mouse Wheel - See above. To change these settings, click Tools > Options > Navigation >
Navigation Mode > Mouse Wheel Settings (on the Mac: Google Earth > Preferences >
Navigation > Navigation Mode > Mouse Wheel Settings). Move the slider to set how fast or
slow your viewpoint of the earth zooms in or out. Check Invert Mouse Wheel Zoom Direction
to reverse the direction of zooming when you use the mouse wheel.
l Pan and Zoom navigation - This mode is on by default when you start Google Earth. You
can return to this mode from other modes by doing one of the following:
m Type Ctrl ( on the Mac) +T. When this mode is activated, the cursor changes to a
hand symbol.
m (Windows and Linux) Tools > Options > Navigation > Navigation Mode > Pan and
Zoom . (Mac) Google Earth > Preferences > Navigation > Navigation Mode > Pan and
Zoom
If you use a joystick or other non-mouse controller, you can also change how
perspective moves in the 3D viewer under Controller settings. Choose User-Based to
move your particular vantage point or Earth Based to move the globe. Check Reverse
Controls to reverse the actions of the joystick.
l GForce navigation (advanced) - To change to this navigation mode, do one of the
following:
m Type Ctrl ( on the Mac) + G to change when window focus is in the 3D viewer
m (Windows and Linux) Tools > Options > Navigation > Navigation Mode > Flight
Control. (Mac) Google Earth > Preferences > Navigation > Navigation Mode > Flight
Control
This mode is in effect when the navigation cursor changes to an airplane. In addition,
the effects of G-Force mode are most noticeable the closer you are to the terrain, and
become less exaggerated the higher your eye elevation. The behavior of this
navigation mode simulates that of a joystick, where the direction your mouse moves
indicates specific joystick moves. If you are familiar with using a joystick, you'll be
able to use this mode easily.
To pan left or right, or to tilt the horizon left or right, left-click and move the mouse
right/left of center. To tilt to top-down view, left-click and move the mouse forward
(away from you). To tilt to horizon view, left click and move the mouse back (toward
you). To accelerate, right-click (CTRL click on the Mac) and move the mouse forward.
To decelerate, right-click (CTRL click on the Mac) and move the mouse backward.
The response in the 3D viewer to your mouse movements is related to the
vigorousness of your mouse movements, so you can test this mode out slowly using
movements.
To return to standard trackball navigation mode, type Ctrl ( on the Mac) + T. To
stop motion in the viewer at any time, press the spacebar.
l Click-and-Zoom navigation - To change to this navigation mode, choose:
m (Windows and Linux) Tools > Options > Navigation > Navigation Mode > Click-and-
Zoom
m (Mac) Google Earth > Preferences > Navigation > Navigation Mode > Click-and-Zoom
When the 3D viewer enters this navigation mode, the cursor changes to a cross-hair mark.
Here, navigation with the mouse is limited: left-click to zoom in a set distance, and right-click
(CTRL click on the Mac) to zoom out a set distance. Use the navigation controls to pan and
rotate. Return to the standard trackball mode by typing Ctrl ( on the Mac) +T.
Using the Navigation Controls
Note - To view and use the navigation controls, move the cursor over right corner of the 3D viewer.
The navigation controls automatically appear whenever you do this; they fade from sight when you
move the cursor elsewhere. See also Showing or Hiding Items in the 3D Viewer.
The Google Earth navigation controls offer the same type of navigation action that you can achieve
with mouse navigation. In addition, you can use the controls to tilt the view (perhaps for a
perspective on terrain) or to rotate the viewer around the center. The following diagram shows the
controls and explains their functions.
1. Use the tilt slider to tilt the terrain toward a horizon view. Move the slider to the left for a topdown
view or to the right for a horizon view. Click the icons at the end of the slider to reset
the tilt all the way to a top-down view or to a horizon view.
2. Use the joystick to move the center point of the view down, up, right or left. Click the center,
hold the mouse button, and move in any direction.
3. Click the direction arrows to move the view in the direction you wish.
4. Click the north up button to reset the view so that north is at the top of the screen.
5. Use the zoom slider to zoom in or out (+ to zoom in, - to zoom out). Click the icons at the end
of the slider to reset the zoom all the in or out.
6. Click and drag the navigation ring to rotate the view.
Note: You can also use the keyboard to control navigation, see 3D Viewer Navigation in Keyboard
Controls for more information.
Tilting and Viewing Hilly Terrain
When you first start Google Earth, the default view of the earth is a "top-down" view, which looks
like the view straight down out of an airplane window when you are sufficiently zoomed in.
l Tilt the terrain from 0 - 90 degrees - You can use the mouse or the navigation controls to
tilt the view in order to see a different perspective of the area you're exploring. You can tilt to
a maximum of 90 degrees, which provides a view of the object as well as the horizon, in
some cases.
l Turn on terrain - Using the tilt feature is particularly interesting when you are looking at a
part of the earth where the terrain is hilly, so be sure to also have the terrain check box
selected in the Layers panel when tilting the view.
l Rotate the view for a new perspective - Once you have tilted the view so that you are
looking at a particular object, such as a hill, you can also rotate around that object. When
you do this, the object remains in the center of the view, but you look at it from different
perspectives (i.e., north, south, east, west) as you rotate around it.
l Use the middle mouse button (if available) for seamless movement - If your mouse has
a middle button or a depressible scroll wheel, you can depress the button to both tilt and
rotate the view. Movements up or down tilt the view, and movements left or right rotate the
view. See Using a Mouse for more information.
The following figures show a comparison view of Mount Shasta in California with and without tilt
enabled.
Top down view
Tilted view
You can adjust the appearance of the terrain if you would like the elevation to appear more
pronounced. To do this, click Tools > Options > 3D View from the Tools menu (for the Mac, choose
Google Earth > Preferences > 3D View) and change the Elevation Exaggeration figure. You can set
it to any value from 1 to 3, including decimal points. A common setting is 1.5, which achieves an
obvious yet natural elevation appearance. See Viewing Preferences for more information.
Resetting the Default View
After tilting and rotating the 3D view in Google Earth, you can always quickly reset to the default
north-up and top-down view by clicking on the appropriate buttons in the navigation controls.
l Click the North-up button to reset the view so that north is at the top of the viewer.
l Click the Reset Tilt button to reset tilt to the default "top-down" view.
l (Windows and Linux only) Click in the 3D