In mid-March, 2014 Google announced that it added support for GeoJSON to the Google Maps API (v3). Although other mapping APIs, namely Leaflet, have supported GeoJSON data for quite some time, easy access to GeoJSON in Google Maps will simplify the coding lives of many developers who often use the Google Maps API.
In the past, we have used Jason Sanford’s very useful GeoJSON to Google Maps utility to take GeoJSON data from, say, a query to CartoDB and render it on top of Google Maps. This added some additional complication and overhead to the coding that is, thankfully, now unnecessary.
Adding GeoJSON data to Google using the new data layer in the Maps API is fairly straightforward and we show a quick example here using California’s State Plane Coordinate System Zones (sorry, not a very interesting variable!). The grid itself is meaningless, created for experimentation purposes in QGIS, but the color blocks reflect the true (approximate) boundaries of the zones. We included both the map and the full code below but you can also see it as a gist at GitHub or, more elegantly, at Mike Bostock’s, bl.ocks.org. Note that the magic happens at line 72. We also added a legend that includes a color toggle to show you that the colors are linked to an attribute in the GeoJSON.