Hacking Google Maps and Google Earth. Wiley

Martin C. Brown

Create Your Own Cutom Mapping Applications

Building on Your Map, Build a Space Station Tracker

e-books shop
Hacking Google Maps and Google Earth


About the Author
A professional writer for more than six years, Martin C. Brown (MC) is the author of both the
Perl and Python Annotated Archives and Complete Reference books (all four Osborne/McGraw-
Hill), Microsoft IIS 6 Delta Guide (Sams Publishing), and 14 other published computing titles.
His expertise spans myriad development languages and platforms—Perl, Python, Java,
JavaScript, Basic, Pascal, Modula-2, C, C++, Rebol, Gawk, Shellscript,Windows, Solaris,
Linux, BeOS, Microsoft WP, Mac OS, and more—as well as web programming, systems
management, and integration. MC is a regular contributor to ServerWatch.com and IBM
developerWorks.

He is also a regular writer of white papers and how-to guides for Microsoft on subjects such as
migrating Solaris/Unix/Linux development and systems administration to Windows 2000 and
2003 Server product lines. He draws on a rich and varied background as a founding member of
a leading U.K. ISP, systems manager and IT consultant for an advertising agency and Internet
solutions group, technical specialist for an intercontinental ISP network, and database designer
and programmer—and as a self-confessed compulsive consumer of computing hardware and
software. In his formative pre-writing life, he spent 10 years designing and managing mixed
platform environments. As a result he has developed a rare talent of being able to convey the
benefits and intricacies of his subject with equal measures of enthusiasm, professionalism, indepth
knowledge, and insight. MC is currently a member of the MySQL Documentation Team.


Contents at a Glance
Acknowledgments
Introduction
Part I: Basics
Chapter 1: Using Geographical Information
Chapter 2: The Google Local Interface
Chapter 3: The Google Maps API
Chapter 4: The Google Web API
Chapter 5: Storing and Sharing Information
Part II: Instant Gratification
Chapter 6:Working with Existing Address Information
Chapter 7: Extending the Google API Examples
Chapter 8: Discovering Overlays and Mash-ups
Part III: Google Maps Hacks
Chapter 9: Using Overlays
Chapter 10: Overlaying Statistical Data
Chapter 11: Building a Community Site
Chapter 12: The Realtors and Archaeologists Toolkit
Chapter 13: I Need to Get To
Chapter 14: Merging with Flickr Photos
Part IV: Google Earth Hacks
Chapter 15: Introducing Google Earth
Chapter 16: Generating Google Earth Feeds
Chapter 17: History and Planning with Google Earth
Appendix: Resources
Index

Acknowledgments
I’d like to thank Chris Webb for giving me the opportunity to write this book, and Suzy
Thompson and Kelly Talbot, who kept me on the straight and narrow while writing the
chapters. The unseen members of Wiley’s development team for the book also had a serious
role to play in the process. I shouldn’t forget the vital roles played by my agent, Lynn Haller,
and the rest of the team at StudioB.

Helping me ensure the correct content and testing some of the applications were Chris
Herborth and the technical editor, Ben Hammersley. It should go without saying that the users
and developers of Google Maps applications and the rest of the Google Maps community have
served as an inspiration for some of the examples in this book.


Most importantly, I must thank my wife who survives not only my good days, but also my bad.


Introduction

Do you know where you are?
Do you know where you are going?
Could you find the nearest restaurant to your current location?
When you looked at your latest holiday photos, could you remember where you were?

It is just these sorts of questions that drove me to write this book. I’m interested in the answers
to all of these questions, and particularly in ways in which I can represent information about
my world, and the world we live in, in a way that relates that data to its location.

During the course of writing this book I visited New York (U.S.), Edinburgh (Scotland), and
Sorrento (Italy), in addition to many different places within a few miles of my home. 
In each case, Google Maps and Google Earth could be used to record information about where I had been, to look up information about where I was going, or simply to help me understand the
area I was visiting. All of these situations, and more, are documented and described within this book.

Who This Book Is For
This book is aimed at both amateur and professional programmers who want to make use of
either Google Maps or Google Earth in their own applications.To get the best out of this
book, you should have some basic programming experience and ideally be familiar with
HTML and JavaScript. It would also be beneficial to have experience with scripting languages
(particularly Perl) and SQL databases, such as MySQL.

Managers and other interested parties might also find sections of the book useful, because it
can help them understand how the applications work and also provide background knowledge
on what Google Maps and Google Earth are capable of.

How This Book Is Organized
The book is divided into four basic parts:
Part I covers the basics of the Google Maps interface, the fundamentals of the Google Maps
API, and how to organize and translate existing information into a format that can successfully
be used within Google Maps and Google Earth applications. The section should get you up to
speed on the core techniques and abilities you need to work with the rest of the book.
Part II shows you what the Google Maps system is capable of doing. In this section you’ll find
information on some excellent sample applications and how to create your own Google Maps
applications by extending the functionality of the core Google examples.
Part III is crammed full of examples of Google Maps applications, starting with basic markers
and overlays, moving through dynamically driven examples and on to methods of highlighting
key points and elements for archaeologists and Realtors. The section finishes up with an example
of a route description application. All of the examples demonstrated can be viewed online.
Part IV covers the Google Earth application. Google Earth is a standalone application, rather
than a web site solution like Google Maps, and offers a completely new set of methods for
describing information.

Conventions Used in This Book
In this book, you’ll find several notification icons—Note, Caution, and Tip—that point out
important information. Here’s what the three types of icons look like:
Notes provide you with additional information or resources.
A caution indicates that you should use extreme care to avoid a potential disaster.
A tip is advice that can save you time and energy.
Code lines are often longer than what will fit across a page. The symbol ; indicates that the
following code line is actually a continuation of the current line. For example,
var newlat = latpoints[0] + ((latpoints[latpoints.length-1] - ; latpoints[0])/2);
is really one line of code when you type it into your editor.
Code, functions, URLs, and so forth within the text of this book appear in a monospace
font, while content you will type appears either bold or monospaced.

What You Need to Use This Book
For the Google Maps examples in this book, you need access to a publicly available web site
where you can add and update pages, because the Google Maps API must be able to verify
your pages during use. Hosting these pages on your own machine is unlikely to work. 
Full details of requirements, including those for accessing the Google Maps API are provided in Chapter 3.
Google Maps applications are written using JavaScript and HTML, so you should be familiar
with these to be able to understand and adapt the examples. Many of the examples use a Perl
script for providing data, and although these operations could also be written in PHP or
Python, examples of these are not provided. Finally, some examples use a MySQL database to
store information. A similar database solution, such as MySQL, Derby, PostgreSQL, or others
will be required to duplicate some of the samples. All of the examples should work within the
major platforms (Windows, Linux/Unix, and Mac OS X).

All of the examples in this book make use of the version 1 sequence of the Google Maps API.
The API is under constant development and new versions might be released after the publication
of this book that supersede the version used in the examples. The availability of the new
version will not affect the operation of the examples, which are designed to work with the v1
sequence.
The Google Earth application is available for computers running Windows and Mac OS X.
However, new versions and editions for existing and new platforms could be released at any time.

What’s on the Companion Web Site
A companion site for the book is available at http://maps.mcslp.com.
The site includes the following:
Full source code for all the examples in the book.
Working examples of all the applications featured in the book.
Errata and corrections.
Regular follow-up articles and information on Google Maps, Google Earth, and the book contents.
The web site also includes a Weblog. 
Details of how to subscribe to the articles and comments
posted to the blog are available on the site.
As usual, all of the code and errata for the book are also available at http://www.wiley.com/go/extremetech.


Screenshot

e-books shop

Purchase Now !
Just with Paypal



Product details
 Price
 File Size
 11,549 KB
 Pages
 401 p
 File Type
 PDF format
 ISBN-13
 ISBN-10
 978-0-471-79009-9
 0-471-79009-5
 Copyright
 2006 by Wiley Publishing, Inc 

Table of Contents
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Part I: Basics 1
Chapter 1: Using Geographical Information . . . . . . . . . . . . . . . . . 3
Understanding Your Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Mapping a Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Defining a Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Moving to Another Location . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Thinking in Terms of Geographical Location . . . . . . . . . . . . . . . . . . . . . 6
To Find Places . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
To Identify Photo Subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
To Understand Statistical Data. . . . . . . . . . . . . . . . . . . . . . . . . . 9
To Generate Data from Maps . . . . . . . . . . . . . . . . . . . . . . . . . 10
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 2: The Google Local Interface . . . . . . . . . . . . . . . . . . . 13
System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Examining the Main Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Interacting with the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Moving the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Zooming In and Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Changing the View Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Conducting Searches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Understanding Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Pop-ups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Chapter 3: The Google Maps API . . . . . . . . . . . . . . . . . . . . . . 35
Using the API Key. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Browser Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Basic Components of a Google Maps Application . . . . . . . . . . . . . . . . . . 37
XHTML (Extensible HTML) . . . . . . . . . . . . . . . . . . . . . . . . . 37
VML (Vector Markup Language) . . . . . . . . . . . . . . . . . . . . . . . 38
Styles and Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
XML (Extensible Markup Language) . . . . . . . . . . . . . . . . . . . . . 39
JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Understanding API Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Information Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The Google Maps Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
GMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
GMarker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
GPolyline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
GIcon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
GEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
GXmlHttp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
GXml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
GXslt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
GPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
GSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
GBounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Chapter 4: The Google Web API . . . . . . . . . . . . . . . . . . . . . . . 53
Downloading the Google Web API . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Using the Google Web API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Conducting Searches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Comparing Language Samples . . . . . . . . . . . . . . . . . . . . . . . . . 60
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Chapter 5: Storing and Sharing Information. . . . . . . . . . . . . . . . . 65
Format Types and Uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Using Flat-Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Using XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Using an RDBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Parsing and Generating Text Files. . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Reading Delimited Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Writing Delimited Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Reading Fixed-Width Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Writing Fixed-Width Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Updating Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Generating and Parsing XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Generating XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Parsing XML with Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Parsing XML with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Working with SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Creating a Database Structure . . . . . . . . . . . . . . . . . . . . . . . . . 83
Interfacing to the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Populating the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Extracting Data from the Database . . . . . . . . . . . . . . . . . . . . . . . 89
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Part II: Instant Gratification 93
Chapter 6: Working with Existing Address Information . . . . . . . . . . 95
Looking Up Geocode Information . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Looking Up U.S. Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Looking Up Global Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Chapter 7: Extending the Google API Examples . . . . . . . . . . . . . . 103
Installing a Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Adding Controls to the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Moving about a Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Adding Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Adding a Single Marker . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Adding Multiple Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Adding Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Opening an Info Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Event Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Monitoring Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Adding Markers to Multiple Maps . . . . . . . . . . . . . . . . . . . . . . 125
Monitoring Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Chapter 8: Discovering Overlays and Mash-ups . . . . . . . . . . . . . 133
Traffic Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Toronto Transit Commission (TTC) Map . . . . . . . . . . . . . . . . . . 133
Toronto Traffic Cameras. . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
U.K. Speed Cameras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Trackers and Locators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Hurricanes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Satellites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Blackbirds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Part III: Google Maps Hacks 143
Chapter 9: Using Overlays . . . . . . . . . . . . . . . . . . . . . . . . . 145
Building in Multiple Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Extending the Source HTML. . . . . . . . . . . . . . . . . . . . . . . . . 145
Making the Generation Dynamic with a Script . . . . . . . . . . . . . . . . 148
Pulling the Data from a Database . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Creating a Suitable Database Structure . . . . . . . . . . . . . . . . . . . . 157
Generating XML from that Information . . . . . . . . . . . . . . . . . . . 159
Extending the Information Pane . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Formatting Information Panes. . . . . . . . . . . . . . . . . . . . . . . . . 161
Creating More Detailed Windows from XML and XSLT . . . . . . . . . . 163
Making Your Example Truly Dynamic. . . . . . . . . . . . . . . . . . . . . . . . 167
Dividing the Application into Components. . . . . . . . . . . . . . . . . . 168
The JavaScript Component . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Generating the XML on the Backend. . . . . . . . . . . . . . . . . . . . . 174
Using the New Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Extending the Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Chapter 10: Overlaying Statistical Data . . . . . . . . . . . . . . . . . . 181
Generating/Obtaining Statistical Information . . . . . . . . . . . . . . . . . . . . 181
The U.S. Census Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Converting the Source Data to XML . . . . . . . . . . . . . . . . . . . . . 182
Using Polylines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Basic Point Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Building an Internal Data Representation. . . . . . . . . . . . . . . . . . . 188
Adding a Bar Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Adding a Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Plotting Multiple Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Using Custom Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Building Your Own Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Putting the Icon on a Map . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Using Icon Size to Represent Data . . . . . . . . . . . . . . . . . . . . . . 203
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Chapter 11: Building a Community Site . . . . . . . . . . . . . . . . . . 207
Displaying Highlighted Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Adding More Data to the Output . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Storing and Creating the Data . . . . . . . . . . . . . . . . . . . . . . . . 209
Backend Database Interface . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Using Custom Icons to Highlight Different Attractions . . . . . . . . . . . . . . 213
Filtering Data through Layers of Information . . . . . . . . . . . . . . . . . . . . 215
HTML Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Global Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Entity Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Initial Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Loading a List of Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Moving the Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Removing Existing Markers . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Adding Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Loading Markers for a Type . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Recentering the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Closing HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Final Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Chapter 12: The Realtors and Archaeologists Toolkit . . . . . . . . . . . 227
Alternative Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
The TLabel Extension. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Building a TLabel Application . . . . . . . . . . . . . . . . . . . . . . . . 232
Overlaying Images and Drawings . . . . . . . . . . . . . . . . . . . . . . . . . . 239
The TPhoto Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Using TPhoto Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Identifying Elements from Click Locations . . . . . . . . . . . . . . . . . . . . . 244
Creating a Unique Map Object . . . . . . . . . . . . . . . . . . . . . . . . 244
Registering the Objects on the Map. . . . . . . . . . . . . . . . . . . . . . 245
Identifying the Click Location . . . . . . . . . . . . . . . . . . . . . . . . 246
Resetting the Map Location. . . . . . . . . . . . . . . . . . . . . . . . . . 246
Resetting the Object Opacity . . . . . . . . . . . . . . . . . . . . . . . . . 247
Final Overlay Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Chapter 13: I Need to Get To... . . . . . . . . . . . . . . . . . . . . . . . 251
Front-End Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
HTML Wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Enabling the Route Recording Process . . . . . . . . . . . . . . . . . . . . 254
Disabling the Route Recording Process . . . . . . . . . . . . . . . . . . . . 255
Clearing the Last Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Clearing the Current Route . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Initializing a New Route. . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Deleting a Route. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Saving a Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Loading a List of Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Loading a Single Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Adding Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Initializing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Recentering and Zooming the Map . . . . . . . . . . . . . . . . . . . . . . 265
Backend Database Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Database Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Basic Wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Message Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Listing Existing Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Saving a Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Deleting an Existing Route . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Obtaining a Single Route . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Calculating Distance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Using the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Chapter 14: Merging with Flickr Photos . . . . . . . . . . . . . . . . . . 279
Flickr and the Flickr API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
The Flickr API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Getting a Flickr API Key . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Adding Geographic Data to Your Flickr Photos . . . . . . . . . . . . . . . 280
Adding Flickr Photos to a Google Map . . . . . . . . . . . . . . . . . . . . . . . 281
A Flickr Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Searching Flickr for Photos . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Getting Individual Photo Data . . . . . . . . . . . . . . . . . . . . . . . . 284
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Part IV: Google Earth Hacks 291
Chapter 15: Introducing Google Earth . . . . . . . . . . . . . . . . . . . 293
Google Earth Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Obtaining the Application. . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Google Earth Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Extending Google Earth Information . . . . . . . . . . . . . . . . . . . . . . . . 304
Exporting Your Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Basic KML Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Chapter 16: Generating Google Earth Feeds. . . . . . . . . . . . . . . . 309
Showing Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Generating KML from Existing Data. . . . . . . . . . . . . . . . . . . . . 310
Generating KML Dynamically . . . . . . . . . . . . . . . . . . . . . . . . 315
Adding Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Chapter 17: History and Planning with Google Earth . . . . . . . . . . . 327
Location Photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Using a Photo for a Placemark . . . . . . . . . . . . . . . . . . . . . . . . 327
Scaling the Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Setting a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Adding Detail to a Placemark . . . . . . . . . . . . . . . . . . . . . . . . . 331
Final KML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Generating the Information in Google Earth . . . . . . . . . . . . . . . . . 334
Generating a KMZ File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Revisiting the Realtor’s Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Using an Overlay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Creating a 3D Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Wrapping Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Appendix: Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Google Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Google Maps API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Google Maps API Documentation . . . . . . . . . . . . . . . . . . . . . . 346
Google Maps API Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Google Web API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Google Maps Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Information Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Google Maps Mania. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Maplandia.com . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Google Maps on Wikipedia . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Google Sightseeing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Geocoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
MGeocoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Geocode America . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Geocoder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Google Maps Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
gMap it! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Mobile GMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
MapBuilder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
MapKi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Competitors and Alternatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
MapQuest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Virtual Earth. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Yahoo! Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
A9 Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Multimap.com . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Map24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

  ●▬▬▬▬▬❂❂❂▬▬▬▬▬●
●▬▬❂❂▬▬●
●▬❂▬●

═════ ═════

Loading...
DMCA.com Protection Status