Monday, July 13, 2009

Beginning Google Maps Applications with PHP and Ajax

In the history of the Internet, 2005–2006 will be remembered as the year when online mapping finally came of age. Prior to 2005, MapQuest and other mapping services allowed you to look up directions, search for locations, and map businesses, but these searches were limited, usu- ally to the companies the services had partnered with, so you couldn’t search for any location. On February 8, 2005, Google changed all that. As it does with many of its services, Google qui- etly released the beta of Google Maps to its Labs incubator (http://labs.google.com) and let word-of-mouth marketing promote the new service.
By all accounts, Google Maps was an instant hit. It was the first free mapping service to provide satellite map views of any location on the earth, allowing anyone to look for familiar places. This started the “I can see my house from here” trend, and set the blogosphere abuzz with links to Google Maps locations around the world.
Like other mapping services, Google Maps offered directions, city and town mapping, and local business searches. However, what the Google Maps engineers buried within its code was something that quickly set it apart from the rest. Although unannounced and pos- sibly unplanned, they provided the means to manipulate the code of Google Maps to plot your own locations. Moreover, you could combine this base mapping technology with an external data source to instantly map many location-based points of information. And all of this could be done on privately owned domains, seemingly independent of Google itself.
At first, mapping “hackers” unlocked this functionality, just as video gamers hack into games by entering simple cheat codes. They created their own mapping services using Google Maps and other sources. One of the first these was Housingmaps.com, which combined the craigslist.org housing listings with a searchable Google Maps interface. Next came Adrian Holovaty’s chicagocrime.org, which offered a compelling way to view crime data logged by the Chicago Police Department. These home-brewed mapping applications were dubbed “hacks,” since Google had not sanctioned the use of its code in external domains on the Web.
The major change came in June 2005, when Google officially introduced the Google Maps API, which is the foundation for this book. By releasing this API, Google allowed programmers the opportunity to build an endless array of applications on top of Google Maps. Hundreds of API keys were registered immediately after the announcement, and many sites integrating Google Maps appeared within days. The map mashup was born.

The Birth of the Google Maps Mania Blog
The Google Maps labs beta site had been public for barely a month when I tried it for the first time. I was fascinated. While combing through the blogosphere looking for more information, I started to see a trend toward Google Maps hacks, how-to sites, Firefox extensions, and web-
sites indexing specific satellite images. I thought that others could benefit from an aggregation
of all of these ideas into one themed blog. Thus, my Google Maps Mania blog was born.

Google Maps Mania is more accurately described as a “meta-site,” as host Leo Laporte pointed out when I was a guest on his NPR G4techTV radio show in November 2005.
April 13, 2005, saw these as my first posts:

Title: Google Maps Mania

If you’re like me you were absolutely floored when Google came out with the Google Maps service. Sure, it’s just another mapping service. Until you realize it’s full potential. The ability to toggle between regular street/road maps and a satellite view is unreal. I’ve started to see a lot of buzz around the blogging community about Google Maps so I’ve decided to help you keep up with the Google Maps related sites, blogs and tools that are cropping up. Stay tuned.

Title: Google Sightseeing

The first Google Maps related site of note is Google Sightseeing. This blog tracks interest- ing satellite shots as submitted by its visitors, then organizes them by interest area like buildings, natural landmarks and stadiums. It’s a pretty nifty site. Google Sightseeing even posted my suggestion of Toronto’s Rogers Centre (Skydome) and the CN Tower!

Title: Flickr Memory Maps

Here’s a Flickr group that took off fast. Memory Maps is a Flickr group that contains maps with captions describing memories they have of those areas or specific notes about differ- ent areas. Kind of cool.

Title: Make your own multimedia Google map

Google Blogoscoped tipped me off on this link. Seems Engadget has a page which gives some pretty good directions on how to create your own annotated multimedia Google map. There is some pretty serious direction here which includes inserting pictures and movies from the annotations. I’d like to see an example of this.

Title: My GMaps

myGmaps enables you to create, save and host custom data files and display them with Google Maps. Create push-pin spots on any map of your choice. Mark your house, where an event will be held, or the route of a fun-run as a few examples. Then you can publish the map that you’ve created to your own website.

These postings represented an interesting cross-section of the ideas, concepts, and web- sites that I had come across in the two short months since Google Maps came to the Web. In the year between the start of Google Maps Mania and the release of the second-generation API
(which this book is based on) in April 2006, I have made over 900 posts and attracted more than
6,000 daily readers to the blog, including the architects of the API itself. I’ve been Slashdotted, Dug (at Digg), and linked to from the New York Times site, as well as the sites of hundreds of other mainstream papers and magazines. In June 2006, Google arranged for my entire family to travel across the country so I could speak at the Google Geo Developer Day in advance of the Where 2.0 conference.

So many interesting mashups have been created using the Google Maps API that it’s becoming impossible to keep up with all of them. I liken this to the early days of the Web when search directories began to manually catalog new web pages as they came online. The volume of new sites quickly became too huge to handle manually, and Google itself was born.
You can see why the Google Maps API offers the key for the next killer apps on the Web. It has been the missing link to take the Web to the next level.
This book will provide you the means to take part in this evolution of the Web. I hope to be posting about the interesting and unique map creations that you build after reading this book. Your creations will inspire others to do similar things, and together, we will continue to grow the Internet, one mapping application at a time. Let me know if you build something cool!

MICHAEL PURVIS is a Mechatronics Engineering student at the University of Waterloo, in Ontario. He is a mostly self-taught pro- grammer. Prior to discovering PHP, he was busy making a LEGO® Mindstorms kit play Connect 4. Currently, he maintains an active community site for classmates, built mostly from home-brewed extensions to PunBB and MediaWiki.
He has written about CSS for Position Is Everything, and occa- sionally participates in the css-discuss mailing list. He particularly enjoys those clever layouts that mix negative margins, relative posi- tioning, and bizarre float tricks to create fiendish, cross-browser, flexible-width concoctions. These and other nontechnical topics
are discussed on his weblog at uwmike.com.
Offline, he enjoys cooking, cycling, and social dancing. He has worked with We-Create, Inc. on a number of PHP-based projects, and has a strong interest in independent web standards.

JEFFREY SAMBELLS is a graphic designer and self-taught web appli- cations developer best known for his unique ability to merge the visual world of graphics with the mental realm of code. With a Bachelor of Technology degree in Graphic Communications Man- agement along with a minor in Multimedia, Jeffrey was originally trained for the traditional paper-and-ink printing industry, but he soon realized the world of pixels and code was where his ideas would prosper. In late 1999, he cofounded We-Create, Inc., an Inter- net software company based in Waterloo, Ontario, which began many long nights of challenging and creative innovation. Currently, as Director of Research and Development for We-Create, Jeffrey is
responsible for investigating new and emerging Internet technologies and integrating them using web standards-compliant methods. In late 2005, he also became a Zend Certified Engineer.
When not playing at the office, Jeffrey enjoys a variety of hobbies from photography to woodworking. When the opportunity arises, he also enjoys floating in a canoe on the lakes of Algonquin Provincial Park or going on an adventurous, map-free, drive with his wife. Jeffrey also maintains a personal website at JeffreySambells.com, where he shares thoughts, ideas, and opinions about web technologies, photography, design, and more. He lives in Ontario,
Canada, eh, with his wife, Stephanie, and their little dog, Milo.

CAMERON TURNER has been programming computers since his first
VIC 20 at age 7. He has been developing interactive websites since
1994. In 1999, he cofounded We-Create, Inc., which specializes in Internet software development. He is now the company’s Chief Technology Officer. Cam obtained his Honors degree in Computer Science from the University of Waterloo with specialization in applied cryptography, database design, and computer security.
Cam lives in Canada’s technology capital of Waterloo, Ontario, with his wife, Tanya, son Owen, and dog Katie. His hobbies include biking, hiking, water skiing, and painting. He maintains a personal blog at CamTurner.com, discussing nontechnical topics, thoughts, theories, and family life.

0 comments: