{"id":372,"date":"2006-09-12T20:04:25","date_gmt":"2006-09-13T02:04:25","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=372"},"modified":"2008-04-23T07:36:03","modified_gmt":"2008-04-23T13:36:03","slug":"book-review-google-maps-api-v2","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/372","title":{"rendered":"Book Review: Google Maps API V2"},"content":{"rendered":"<p>Seven months ago, I wrote about <a href=\"http:\/\/www.mooreds.com\/weblog\/?p=314\">Google Maps   Gotchas<\/a>.  I mentioned Scott Davis&#8217; <a href=\"http:\/\/www.pragmaticprogrammer.com\/titles\/sdgmapi2\/index.html\">Google Maps API<\/a>   Pragmatic Friday article, published by the <a href=\"http:\/\/www.pragmaticprogrammer.com\/\">Pragmatic   Programmer folks<\/a>.  Well, a few things have happened since then.  In April, <a href=\"http:\/\/googlemapsapi.blogspot.com\/2006\/04\/google-maps-api-version-2.html\">Google   released version two of their maps API<\/a> (though <a href=\"http:\/\/groups.google.com\/group\/Google-Maps-API\/browse_thread\/thread\/b46d712a1dc2888f\/98862d119547eefb\">they still haven&#8217;t set a date   when version one will no longer be supported<\/a>), Scott <a href=\"http:\/\/www.davisworld.org\/blojsom\/blog\/default\/Maps\/?permalink=New-Google-Maps-API-Released.html\">revised his article<\/a> and I spent a tax deductible $8.50 to give it a   read.  What you&#8217;ll find below is my take on his article.<\/p>\n<p>The good:  first, the ordering was easy, and I received my custom PDF (complete with &#8220;Prepared Exclusively for Daniel Scott Moore&#8221; as a footer on every page) in less than 20 minutes.  Scott explains in a very easy to understand fashion how to create a map.  He also covers each of the API&#8217;s javascript objects and how to use them.  In particular, I thought the list of events and objects that fire them (in the &#8216;Events&#8217; chapter) was a good reference.  Now, Google provides a <a href=\"http:\/\/www.google.com\/apis\/maps\/documentation\/reference.html\">class reference<\/a>, but Scott&#8217;s are a bit easier to understand here&#8217;s a comparison, for the Gmarker class:<\/p>\n<p>Google API:<\/p>\n<blockquote><p>A GMarker marks a position on the map. It implements the GOverlay   interface andthus is added to the map using the GMap2.addOverlay()  method.A marker object has a point, which is the geographical position where the marker is   anchored on the map, and an icon. If the icon is not set in the constructor, the default   icon G_DEFAULT_ICON is used.<\/p>\n<p>After it is added to a map, the info window of that map can be opened through the marker. The marker object will fire mouse events and infowindow events.<\/p><\/blockquote>\n<p>Davis&#8217; Book:<\/p>\n<blockquote><p>In the Core Objects section, we introduced the GLatLng. A GLatLng stores a Latitude \/ Longitude coordinate, but it doesn&#8217;t offer you a way to visualize it on a map. A GMarker is the way to add GLatLngs GMarker to the map for display purposes. The GMarker constructor takes a GLatLng as the only required argument.Once we have the marker, we need to tell the map to display it; map.addOverlay(myMarker) should do the trick. (Objects that you superimpose over the map are called Overlays.) You can remove the Overlays marker using map.removeOverlay(myMarker). To remove all overlays, use map.clearOverlays( ).<\/p>\n<p><code>var myPoint = new GLatLng(38.898748, -77.037684); <\/code><br \/>\n<code>var myMarker = new GMarker(myPoint); <\/code><br \/>\n<code>map.addOverlay(myMarker);<\/code><\/p>\n<p>Theoretically a map can support an unlimited number of markers, but anecdotal evidence suggests that performance starts to slow down significantly after a hundred or so markers. (File under, &#8220;Doc, it hurts when I do this.&#8221;)<\/p><\/blockquote>\n<p>I liked the real world examples&#8211;the fact that you could click through and see the code   Scott was writing about in action on his website is a real plus.  In addition, he builds a decently complex example in Chapter 7 where the user can add and delete cities.  He also gives a good warning about examples that use Gmap, rather than Gmap2.<\/p>\n<p>However, there were some issues.  Scott&#8217;s coverage of the upgrade to version two of the API is, unfortunately, rather   spotty.  In his blog, <a href=\"http:\/\/www.davisworld.org\/blojsom\/blog\/default\/Maps\/?permalink=New-Google-Maps-API-Released.html%3Ehe%20covers%20some%20of%20the%20specific%20things%20he%20had%20to%20do%20to%20update%20the%20book%3C\/a%3E,%20but%20a%20section%20on%20upgrading%20would%20have%20been%20nice.%20%20Buyers%20should%20be%20aware%20that%20he%20doesn\" \/><a href=\"http:\/\/googlemapsapi.blogspot.com\/2006\/06\/geocoding-at-last.html\">the June release   of that feature<\/a>, and the April revision of the book).  He also doesn&#8217;t cover <code>GDownloadURL<\/code>, a convenience method for XMLHttpRequest processing, or the <code>GUnload<\/code> methods.  I&#8217;ll freely admit that the maps API is a moving target, and some of the omissions above may be due to that.<\/p>\n<p>However, there are other problems.  Though billed as a beginner book, he omits what I consider to be one of the fundamental challenges of Google Maps development&#8211;the performance obstacles large numbers of database driven markers (other than the comment mentioned above in the GMarker reference).  In addition, he doesn&#8217;t cover design options, nor cross browser issues (like the <a href=\"http:\/\/www.alistapart.com\/stories\/pngopacity\/\">transparent PNG in IE issue<\/a>).<\/p>\n<p>In the last chapter, he mentions good examples of mapping websites, but Scott omits references to useful websites&#8211;something that even dead tree books do.  In particular, he doesn&#8217;t mention <a href=\"http:\/\/www.mapki.com\/\">mapki.com<\/a> (a wiki full of useful user provided data) nor the <a href=\"http:\/\/groups.google.com\/group\/Google-Maps-API\/\">Google Maps group<\/a> (which <a href=\"http:\/\/groups.google.com\/group\/Google-Maps-API\/browse_thread\/thread\/79191c907a4ae313\/2121c6ffd441acfd#e6b9d6ef9a6b95b9\">some users consider a primary differentiator between Google and Yahoo Maps<\/a>).<\/p>\n<p>One final gripe is that the 75 pages of content that I expected were really only 45&#8211;text only filled about 60% of the column width.  I expect that in articles I read for free on the web, but in books that I pay for, I like a bit higher content to page ratio.<\/p>\n<p>In short, this ebook is a good choice for the first time Google Maps builder.  This is due to the tutorial nature of much of the book, the examples, and the explanation of typical good javascript code, such as using anonymous functions for the event handlers.  It is not entirely adequate in covering version 2 of the API, possibly due to API changes, and it ignored some of the more complex aspects of the API.<\/p>\n<p>If you&#8217;re looking for a folksy introduction to Google Maps api, it&#8217;s worth the $8.50 to have a coherent guide. If you&#8217;ve muddled through one google maps project, piecing together things from the API docs and various blogs, it becomes less worthwhile.  But if you want some kind of discussion about complex Google Maps issues this document is not the right place to look.<\/p>\n<p>[tags]Scott Davis, Google Maps, Pragmatic Fridays[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Seven months ago, I wrote about Google Maps Gotchas. I mentioned Scott Davis&#8217; Google Maps API Pragmatic Friday article, published by the Pragmatic Programmer folks. Well, a few things have [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10,11,6],"tags":[],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-books","category-dynamic-languages","category-google-maps","category-programming"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}