Beginning Google Maps Applications with PHP and Ajax 105
Michael J. Ross writes "Just as PHP and other Web scripting languages have made it possible to create dynamic Web pages, online mapping services are making it possible to create dynamic maps that can be customized by a Web site owner, or made customizable by a site visitor. In the case of Google Maps, this is done using the built-in application programming interface (API), which is described in a new book, Beginning Google Maps Applications with PHP and Ajax: From Novice to Professional." Read on for the rest of Michael's review.
Beginning Google Maps Applications with PHP and Ajax | |
author | Michael Purvis, Jeffrey Sambells, and Cameron Turner |
pages | 384 |
publisher | Apress |
rating | 8 |
reviewer | Michael J. Ross |
ISBN | 1590597079 |
summary | How to use the Google Maps API to make dynamic online maps. |
But first, a brief background: During the mid-1990s, the only generally available mapping applications were desktop programs with location data limited to major cities within the United States. Yet less than one decade later, those programs were obsolete, replaced by Web-based mapping services such as MapBlast, MapQuest, and Yahoo Maps. In early 2005, Google raised the bar, with its own Web-based mapping service that was far more attractive than the others. For countless Internet users, it was their first glimpse of the power of AJAX, a new combination of technologies that allows Web pages to be refreshed asynchronously, providing a faster user interface. But Google Maps later packed another feature, an API that allows Web developers to leverage the service's capabilities in previously unimagined ways.
The authors of Beginning Google Maps Applications with PHP and Ajax — Michael Purvis, Jeffrey Sambells, and Cameron Turner — are based in Waterloo, Ontario, Canada. The book was published in August of 2006, by Apress, under the ISBN of 1590597079. The publisher maintains a Web page devoted to the title, where visitors can find an online table of contents, a sample chapter (Chapter 3, "Interacting with the User and the Server") as a PDF file, and a link for submitting errata (none of which, as of this writing, appear to have been reported — assuming there are any). In addition, the authors have a Web site for the book, where they offer a sample chapter (Chapter 4, "Geocoding Addresses") in PDF format, links to raw data sources, and brief entries describing a variety of related topics, including geocoding services, Google Maps Mobile (GMM), Keyhole Markup Language (KML), and building your own geocoding using Perl.
The book's material is organized into 11 chapters, grouped into three parts. The fourth and final part contains the appendices. The three primary parts can roughly be thought of as presenting the beginning, intermediate, and advanced information. Part 1, "Your First Google Maps," whets the reader's appetite by showing how to easily create some simple maps (discussed below). In addition, it contains a chapter explaining how a Google Maps mashup interacts with the user as well as the server. The final chapter in this part discusses geocoding addresses. Part 2, "Beyond the Basics," explains how to work with third-party data, how to enhance the user interface, how to optimize and scale for large data sets, and finally what possible future directions Google may take with this API. Part 3, "Advanced Map Features and Methods," presents exactly that, covering such topics as creating custom controls and info windows, adding geometric shapes to maps, and getting the most out of geocoding, including how to work with postal codes.
The authors begin Part 1 ("Your First Google Maps") by introducing Google Maps with the two most simple examples possible: Keyhole Markup Language (KML) is an XML-like formatting language that allows one to specify the names, coordinates, and descriptions of one or more locations ("placemarks") in a single file. For anyone who wishes to avoid writing the code themselves, Wayfaring is a Web site that allows one to create and share custom Google Maps by point and click. Even though the introduction to KML is properly brief, instead of only stating that the sample coordinates were discovered manually, the authors should mention at least one simple way to find those coordinates (such as the "Link to this page" link in Satellite view in Google Maps). Nonetheless, it was wise of the authors to use simple examples to get the reader's feet wet as quickly as possible — especially for prospective readers who might skim through the rest of the book and become intimidated by the technical diagrams, JavaScript and PHP code, MySQL queries, XML markup, and mathematical formulas.
There is much to like about this book. The explanations are straightforward, the code is readable, the examples are relevant, and the writing style is approachable. The illustrations, all of which are in black and white, are well-chosen, and not overwhelming in number. In addition to showing the expected results of the sample code, they also provide enough visual incentive to encourage the reader to give the sample code a try, and perhaps develop it further into their own mapping applications.
The book is not too lengthy, clocking in at 384 pages according to the publisher (though, oddly, Amazon.com reports only 350 pages, even though the last page of the appendix reads "358"). The authors resisted the increasingly common temptation to pad the book with superfluous appendices. Instead there are only two. The first explains how and where to find location data, such as addresses and latitude/longitude points. The second appendix presents the details of all of the classes, methods, properties, constants and events defined within the Google Maps API. For some reason the authors mention "objects" instead of properties and events, but I was unable to find any pre-instantiated objects mentioned in that appendix., and I am not sure such are even possible in the API.
Fortunately, the weakest section of the book, its foreword, has the least impact upon the value of the book. It fails to perform the most basic functions of a foreword, such as explaining to prospective readers why they should become actual readers, as well as what the book covers, and how the authors are qualified to provide that coverage. Instead, its author mostly discusses his personal Google Maps Mania site, and even wedges in mention of his appearance on an NPR radio show, which has little to do with the book. He also lists his first five posts to his Mania site, the first of which contains a misspelling, which should have been caught by the book's editors, or at least indicated with a "[sic]." The best part of the foreword is the first few paragraphs, which provide a brief history of Google Maps and the hacking thereof.
Like most if not all of its titles, Apress helpfully starts this book with two versions of the table of contents — the first one serving as a high-level overview, and the second providing far more detail, listing not only sections but subsections. This is a nice touch, and should be employed by all technical publishers. On the other hand, this book does not have a lay-flat binding, which is a shame, as it makes it far more difficult to read the book with both hands free for keyboarding. With the introduction of lay-flat bindings years ago, it is inconceivable to me why it has not been universally adopted, particularly by technical publishers.
Overall, Beginning Google Maps Applications with PHP and Ajax is an excellent introduction to extending the power of Google Maps on the Web, and provides enough detail to both help and entice readers to build their own Google Maps mashups.
Michael J. Ross is a freelance writer, computer consultant, and the editor of the free newsletter of PristinePlanet.com."
You can purchase Beginning Google Maps Applications with PHP and Ajax: From Novice to Professional from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Let me be the first to ask... (Score:3, Insightful)
Re: (Score:2, Troll)
In other news, the reviewer wrote the best definition of the AJAX technology:
Re: (Score:1, Redundant)
Well aren't we aggressive today. In fact I am working on a "Where to refill your bike's water bottle in San Francisco" mashup as I type. I haven't found that I need 11 chapters to get as far as I have.
But then again, you already know how easy I think they are so I'll probably not get very far anyway, since I obviously think they're easy and I am obviously mistaken, dick.
AJAX, a new combination of technologies that allows We
Re: (Score:2, Interesting)
And yes, it's quite easy for anyone with a education in CS I'd say. If you can read a manual you can implement google maps.
Re: (Score:1, Flamebait)
One so far. I began with zero experience with either AJAX or the Google Maps API. I had a working map in an hour, using only the online reference material provided by Google as a guide. In another hour I had added markers with custom icons pop-up information boxes.
Actually it was far, far easier than I thought. If you need a 350-page book to spoon-feed it to you in small bites, you may have chosen the wrong career path
Re: (Score:1)
[opinion]5. Yes they are.[/opinion]
Agreed that definition is not bad for as short as it is.
It is good that books like this are put out there for those who need that extra boost up the ladder, but for the could-be reader...Google Maps API [google.com].
Read that and if you still can't get it, consider the book. If you have spend any time cross scripting (PHP to Javascript to Static HTML)
Re: (Score:2)
Dude, they are easy. Much easier than I expected them to be.
If Google didnt charge so much for the commercial licence, there would be an explosion of these apps.
Re: (Score:2, Insightful)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2, Insightful)
Maybe the first 300 pages or so are simply the search results for "google maps api" [google.com]
Re: (Score:3, Insightful)
Basic maps are indeed simple and are covered in depth in the first 3 chapters, but this book goes on to cover dealing with hundreds of thousands of data points where the plain API chokes before 200.
Sure, much of this ma
Re: (Score:1)
Re: (Score:1)
My thoughts exactly. The Google Maps API documentation and a little Googling is about all you need. 358 pages? How in the hell did they fill up that many pages on this topic???
Re: (Score:1)
good mapping sites (Score:4, Informative)
Re: (Score:3, Informative)
Re: (Score:1)
Re: (Score:1)
It displays slightly delayed actual flight data on a google earth sphere, with altitude. I do believe the Earth code is similar to the Maps API, with all the references to the third dimension for a GPoint that I noticed, but I'm not a programmer, so I don't know exactly.
Re: (Score:1)
Re: (Score:2)
I'm working on mapix.co.uk [mapix.co.uk] at the moments. It's a project to build up a photographic map of the UK.
Still being tested and developed but have a look round.
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
This thing works great for dumping stuff from my garmin etrex. He has options for google and several other mapping services. Way cool. Now if only he'd support kismet files natively for war driving.
Re: (Score:1)
Re: (Score:1)
http://www.bigelowaerospace.com/out_there/seen_gen esis1.php [bigelowaerospace.com]
Re: (Score:1)
unless (unlikely) there are no sex offenders
in the Bay Area.
TRY THESE SITES before you "link to them" mindlessly.
Thank you.
Renee
Re: (Score:2)
WHO cares ? (Score:5, Insightful)
Almost 80% of the web development market is comprised of small businesses or individual investors, who do not care the slightest for ajax widgets, mumbo jumbo or the such when they start an online presence. Their problem is, selling their wares, or services via a secure, easy and clock-like working site.
Much hype was done around this ajax, yet we as web developers still are not seeing any demands on ajax stuff in contracts. And the ones that there are negligible when proportioned to the whole.
Im increasingly starting to see this ajax thing as a new "techno trend" that is pumped up and put forth by genius-tech-wizz kids (net celebrities) who did big business with similar things in the past.
The catch is, market does not need it.
Re: (Score:2)
Re:WHO cares ? (Score:4, Informative)
Re: (Score:1)
Re: (Score:2)
Re: (Score:1)
Once the user releases the mouse, Ajax sends the new location info back to the server, which persists it. And the info can be sent back in an XML document, though any defined data format could be used.
Re: (Score:2)
It is much better to altogether let go of javascript and activex.
Re: (Score:2)
Do you still drive a ford Pinto?
And of course, well designed web applications will degrade gracefully, just for you few stragglers that refuse to allow the internet to be anything more than a text reader. Well, actually, not for you. But for the few that have _legitimate_ reasons.
BTW, low bandwidth is NOT a good reason to diss things like AJAX. Case in point, I recently upgraded one of our core web features that almost all of our low bandwidth customers were having prob
Re: (Score:2)
Leaving that aside, you are wrong in your point. Bandwidth is now much more important than it has ever been, because of the disgusting laws that the at&t and other telcos are pushing.
Re: (Score:2)
As for bandwidth, I was stating that proper use of AJAX can REDUCE bandwidth useage, sheesh.
Re: (Score:1)
Because you are the arbiter of what the market does, or does not, need. I wish to subscribe to your newsletter.
Re:WHO cares ? (Score:5, Insightful)
Re:WHO cares ? (Score:4, Insightful)
I do. (Score:3, Interesting)
There are many applications that are just fine as "web applications". Blogs for example. Most shopping cart type applications. There may be an occasional place where sprinkling a bit of ajax fairy dust makes the application a bit nicer (altough often less nice if you are vision impaired).
There are other applications that suck as "web applications". They are now what we used
Re: (Score:2)
Considering it is the small to medium businesses, and individuals who are fueling the internet in its majority, and very big companies like google, aol or the like having their own development teams, that only leaves a small fraction of medium to big capita to ever think of sailing such seas, and natually a fraction of it would be
Re: (Score:2)
World Wind is a bad example. Ironically, the standard "store finder" application for your large company doesn't really require GIS either.
But, there are actually a large number of organizations ranging from small to large that can use geographic applications. They are, as you say, a niche, but that doesn't mean that the niche is sm
Re: (Score:2)
The catch is, most will continue to be unaware, and noone is going to make a campaign to make them aware, and many of the ones that became unaware could be uninterested.
Re: (Score:2)
The catch is, most will continue to be unaware, and noone is going to make a campaign to make them aware, and many of the ones that became unaware could be uninterested.
OT, but did you go to the same school as Don Rumsfeld
Re: (Score:3, Interesting)
On the one side is the financial take. Assuming your numbers are correct, how much money is behind the 20% of 'big business' sites do you think?
Are you truly suggesting that rich web applications are something that doesn't make these companies money?
Is it impossible for widgets and templates to be wrapped up in a nice customizable package and sold to smaller businesses for very a
Re: (Score:2)
Re: (Score:2)
Google Geocode API inaccurate. (Score:4, Informative)
Re: (Score:1)
Re: (Score:2)
http://search.cpan.org/~sderle/Geo-Coder-US-1.00/
It rocks. I've been using it with my voter lists for Door to door.
Re: (Score:1)
Re: (Score:1)
An idea need not be "definitive" in order to be useful for, say, 250 million Americans.
Re: (Score:1)
Re: (Score:1)
At which point did it become necessary to pick on people who use a solution that happens to be nation-specific? Or were you just being a dick?
Re: (Score:1)
I wasn't picking on anyone, and it's really not neccesary to start being a neandrathral just because you are getting all patriotic.
Re: (Score:1)
An American (or a Bolivian or a Lower Slobovian) doesn't NEED to care or wish to do anything outside their own boundaries. Everybody is responsible to take care of their own problems. This person (who we can assume is an American, if we're going to start making assumptions) shared a solution that works for him, and perhaps for some other people, and felt the desire to share it. You're the one
Re: (Score:1)
And, grow up, discussions don't all have to end with calling people names.
Re: (Score:1)
ALL discussions don't have to end with calling people names. This one did, however. Prick.
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
I've had good luck with Yahoo's geocoding services. At the time I mucked with this stuff, Google had not yet put up their geocoding service.
The big problem I have with Google maps is the API uses TeleAtlas in my area which is verging on 10 years out of date, but going to maps.google.com, my area is using NAVTEQ data, which is fairly current. It's possibly a licensing issue, but it's damned annoying to have whole major highways missing in my app.
Your mileage, of course, may vary.
Re: (Score:1)
Re: (Score:1)
Normalize everything. (Score:1, Offtopic)
Re: (Score:2)
Ooh! (Score:2)
Re: (Score:1)
A bit early for a book? (Score:4, Insightful)
Re: (Score:2, Informative)
http://googlemapsbook.com/ [googlemapsbook.com] if you're interested.
Re: (Score:1)
Re: (Score:1)
Re: (Score:1)
The purpose of books like this is to make money for the publisher. That is the "need".
how about www.mapki.com (Score:4, Informative)
Other books, OpenLayers.org and more (Score:2)
Anyone whom have interest in Google Maps API must take a look at the numerous alternatives. Which includes OpenLayers.org [openlayers.org] (which just released v2.0 [narx.net]). There are various other alternatives, all with different levels of interoperability and compatibility with OGC standards [opengeospatial.org]. On the subject, see slashgeo's web mapping section [slashgeo.org].
.
Re: (Score:2)
Data is the next Intel Inside (Score:2)
Google's $10,000 fee isnt helping growth. (Score:2)
Sure, they have the right to charge whatever they want, but damm, who is going to adopt it at that rate just to add some coo
Re: (Score:2)
The laternative might be to use Yahoo Maps' new API. I haven't played with it much yet, because I don't want to install any plugins to use it. But lots of folks probably will. This book would be better if it was more even-handed and presented info on yahoo as well.
Still, I'll probably buy it. But not on dead tree, but wh
Re: (Score:2)
The fee is required for sites that want to do more than 50,000 hits a day (to the map server) or want to put the map somewhere that is not publicly accessible (as the current API requires).
Ian (from http://mapki.com/ [mapki.com]
Re: (Score:2)
KISS (Score:1)
Another PHP and AJAX book which one is better? (Score:2)
Re: (Score:2)
OK, I'll make it _real_ simple for you, one question is all I need answered:
Are you interested in learning mapping using google maps API, or are you interested in learning AJAX with PHP?
Given the answer to that question, I sure do hope you can figure out the rest on your own. If not, I highly suggest neither.
Mike Purvis is my classmate! (Score:1)