Book Review: Google Maps JavaScript API Cookbook

Google Maps JavaScript API Cookbook by Alper Dincer & Balkan Uraz  (buy from Packt) is a good introduction to the Google Maps JavaScript API in its current incarnation. Although it glosses over some of the potential weaknesses, it provides good working examples of everything from simple map features through to more sophisticated topics such as data imports and external map servers.

 

 


 

 

This book follows the familiar Packt Cookbook pattern of dividing each recipe into sub-sections of Introduction, Getting Ready, How to do it, How it works, There’s more, and See also. This pattern has worked well in the past, and works especially well here. The recipe’s concept is introduced, the code is provided, it is then explained before finishing with potential expansions, caveats, and further reading. In common with most Packt Cookbooks, the first chapters are relatively simple and are used as a basis for later chapters and concepts.

The chapters are:

  • Google Maps JavaScript API Basics – simple maps, mobile devices, map properties
  • Adding Raster Layers – tile base maps, overlays, heat maps, additional Google layers such as traffic and cycling
  • Adding Vector Layers – markers, popups, lines, polygons, animation, KML, GeoJSON, WKT
  • Working with Controls – Adding, removing, position, custom
  • Understanding Google Maps JavaScript API Events – Mouse coordinates, context menus, custom events
  • Google Maps JavaScript Libraries – Shapes, sizes, nearby places, drag-zoom, custom infoboxes
  • Working with Services – Geocoding, elevations, directions, Street View
  • Mastering the Google Maps JavaScript API through Advanced Recipes – WMS Layers, Fusion Tables, CartoDB, ArcGIS, GeoServer

Note that many of these recipes do not rely on built-in API functionality. For example, a simple WKT parser is introduced in order to plot WKT data.

There are some quibbles with small parts of the text. Some of these are pretty trivial. For example, no mention is made that Google Maps does not support all of the KML standard. This is a common assumption and is wrong: Google Earth is the only application that supports all of the KML standard. As I say this is fairly trivial.

A more significant omission concerns map projections. Google uses a Mercator projection based on a spherical Earth model. No mention is made of the spherical Earth model although it might pose problems when plotting GPS-derived data (which is typically WGS84). The area-distorting properties of the Mercator projection are mentioned, but no mention is made of why this is bad for many map projections. Basically the distortions make the Mercator projection unsuitable for regional and global geo-statistical maps (including the global earthquake example given in the book). Such applications should use an equal area projection such as the Mollweide or Cylindrical Equal Area projections. The online mapping revolution of the past decade has made it very easy to make high quality maps with services such as Google Maps or Bing Maps. Unfortunately it also makes it easier to make accidental mistakes of this kind.

Some reviews have noted that the bulk of the information in this book can be found in the official documentation. To an extent this is true, however the documentation tends to only have a limited set of working examples and the rest is in the form of reference material. This book provides a good set of working examples that cover a wider range of functionality, including a number of advanced topics and customizations. As such, a beginner or intermediate user of the Google Maps JavaScript API will find this book to be a useful companion to the official reference documentation.

Leave a Reply