This book explores the W3C Geolocation API, a specification that provides scripted access to geographical location information associated with a hosted device.[1] This API defines objects that can be used in JavaScript to ascertain the position of the device on which the code is executed.
The term geolocation may refer to the act of identifying a person’s position, or it may refer to the actual location itself.
The W3C Geolocation API brings incredible functionality to the browser. Previously, geolocation services were only made available by developers who were writing geolocation applications natively for a particular device. Now, developers have the freedom to write geolocation applications for the Web directly in the browser, and these applications have the advantage of the “write once, deploy everywhere” application model.
This book is intended for developers interested in using the W3C Geolocation API in their web applications. The first few chapters delve into what geolocation is, its history, and how it is currently being utilized today.
These first chapters of the book are a crash course in geolocation to provide a framework for understanding what the API is about. If you are already in the GIS industry and just want to know how to implement this new Application Programming Interface (API) in your applications, or already know all there is to know about geolocation, then skip ahead to Chapter 3 to see the API in action.
Developers should be particularly interested in Chapter 3 and Chapter 4, as they discuss the API with code and examples on usage. Hopefully even nonprogrammers will be able to follow along in these chapters and gain a better understanding of what the API does. Chapter 6 ties things up by exploring what the future of geolocation holds for us all, and discusses practical applications for development using the Geolocation API.
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant widthUsed for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width
boldShows commands or other text that should be typed literally by the user.
Constant width italicShows text that should be replaced with user-supplied values or by values determined by context.
This icon signifies a tip, suggestion, or general note.
This icon indicates a warning or caution.
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “HTML5 Geolocation by Anthony T. Holdener III (O’Reilly). Copyright 2011 Anthony T. Holdener, III, 978-1-449-30472-0.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com.
Safari® Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, download chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other time-saving features.
O’Reilly Media has uploaded this book to the Safari® Books Online service. To have full digital access to this book and others on similar topics from O’Reilly and other publishers, sign up for free at http://my.safaribooksonline.com.
Please address comments and questions concerning this book to the publisher:
| O’Reilly Media, Inc. |
| 1005 Gravenstein Highway North |
| Sebastopol, CA 95472 |
| 800-998-9938 (in the United States or Canada) |
| 707-829-0515 (international or local) |
| 707-829-0104 (fax) |
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:
| http://www.oreilly.com/catalog/9781449304720 |
To comment or ask technical questions about this book, send email to:
| bookquestions@oreilly.com |
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
First, a special thanks to my wife, Sarah, for not only taking care of things while I was busy writing (especially managing the kids), but also for putting on your editing hat and taking a red pen to the first draft of the book. I know you made this book more readable with your amazing writing skills. I am glad to have written something you were interested in reading!
I want to thank the reviewers who gave me suggestions, comments, and corrections; you made this a better book and I really appreciate it. Brian Dunn and John Jackson—thank you.
Also a big thank you to my editor, Simon St.Laurent, who not only continues to give me opportunities to write on topics I care about, but is also a great editor and a pleasure to work with. Thank you for having the confidence in me to allow me to put pen to paper once again for O’Reilly Media.
Finally, I want to thank everyone else who helped make this book happen. Thanks to O’Reilly Production Services for proofreading this work and to Adam Zaremba for all of the last minute production edits. To Karen, thank you for my cover animal. Thank you David for getting the book layout the way it needed to be. And Robert, thank you for interpreting my hand-drawn figures and creating the great illustrations that you did.
I am honored to have created a book about geolocation for the Web, and found it a pleasure to write, difficult though it was at times. I hope you enjoy it!
[1] Geolocation API Specification: W3C Candidate Recommendation 07 September 2010. Editor, Andrei Popescu, Google, Inc. http://www.w3.org/TR/geolocation-API/.