Hacking Google Maps and Google Earth (Extremetech)
Total Page:16
File Type:pdf, Size:1020Kb
01_790095 ffirs.qxp 6/12/06 1:27 PM Page iii Hacking Google® Maps and Google® Earth Martin C. Brown 01_790095 ffirs.qxp 6/12/06 1:27 PM Page i Hacking Google® Maps and Google® Earth 01_790095 ffirs.qxp 6/12/06 1:27 PM Page ii 01_790095 ffirs.qxp 6/12/06 1:27 PM Page iii Hacking Google® Maps and Google® Earth Martin C. Brown 01_790095 ffirs.qxp 6/12/06 1:27 PM Page iv Hacking Google® Maps and Google® Earth Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN-13: 978-0-471-79009-9 ISBN-10: 0-471-79009-5 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/QV/QX/QW/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. 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. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Library of Congress Cataloging-in-Publication Data Brown, Martin C. Hacking Google Maps and Google Earth / Martin C. Brown. p. cm. Includes index. ISBN-13: 978-0-471-79009-9 (paper/website) ISBN-10: 0-471-79009-5 (paper/website) 1. Geographic information systems. 2. Google Maps. 3. Google Earth. I. Title. G70.212.B765 2006 910.285--dc22 2006013971 Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Son, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. ExtremeTech and the ExtremeTech logo are trademarks of Ziff Davis Publishing Holdings, Inc. Used under license. All rights reserved. Google is a registered trademark of Google, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. 01_790095 ffirs.qxp 6/12/06 1:27 PM Page v To Darcy and Leon, the cats that understand everything and nothing, respectively. 01_790095 ffirs.qxp 6/12/06 1:27 PM Page vi 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, in- depth knowledge, and insight. MC is currently a member of the MySQL Documentation Team. 01_790095 ffirs.qxp 6/12/06 1:27 PM Page vii Credits Executive Editor Project Coordinator Chris Webb Ryan Steffen Development Editors Graphics and Production Specialists Kelly Talbot Jennifer Click Suzanna R. Thompson Denny Hager Stephanie Jumper Technical Editor Ben Hammersley Quality Control Technician John Greenough Production Editor Pamela Hanley Proofreading and Indexing Techbooks Copy Editor Kim Cofer Cover Design Anthony Bunyan Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B. Wikert 01_790095 ffirs.qxp 6/12/06 1:27 PM Page viii 02_790095 ftoc.qxp 6/12/06 1:27 PM Page ix Contents at a Glance Acknowledgments . xix Introduction . xxi Part I: Basics . 1 Chapter 1:Using Geographical Information . 3 Chapter 2:The Google Local Interface . 13 Chapter 3:The Google Maps API. 35 Chapter 4:The Google Web API . 53 Chapter 5:Storing and Sharing Information . 65 Part II: Instant Gratification . 93 Chapter 6:Working with Existing Address Information . 95 Chapter 7:Extending the Google API Examples . 103 Chapter 8:Discovering Overlays and Mash-ups . 133 Part III: Google Maps Hacks . 143 Chapter 9:Using Overlays . 145 Chapter 10:Overlaying Statistical Data . 181 Chapter 11:Building a Community Site . 207 Chapter 12:The Realtors and Archaeologists Toolkit . 227 Chapter 13:I Need to Get To.... 251 Chapter 14:Merging with Flickr Photos . 279 Part IV: Google Earth Hacks. 291 Chapter 15:Introducing Google Earth . 293 Chapter 16:Generating Google Earth Feeds. 309 Chapter 17:History and Planning with Google Earth . 327 Appendix: Resources . 345 Index . 351 02_790095 ftoc.qxp 6/12/06 1:27 PM Page x 02_790095 ftoc.qxp 6/12/06 1:27 PM Page xi 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 02_790095 ftoc.qxp 6/12/06 1:27 PM Page xii xii Contents 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 . ..