Wednesday, March 19, 2014

New Data Layer for the Google Maps API


The Google Maps API now has a new Data Layer which makes it very easy to add GeoJSON to your Google Map creations.

Using the new Data Layer with just one line of code you can add a GeoJSON file to your map. The specific line of code looks like this:

map.data.loadGeoJSON(‘filename.json’);

With that one line of code you can load data onto your Google Map. You can then use the new

Data.setStyle()

feature to style how the data looks on the map. The style feature allows you to use custom markers, fill colors and opacity levels for polygons, and line color and line weighting with polylines.

The new Data Layer also allows you to add data event handlers to your data. The event handlers include mouse-over and mouse click events.

You can learn more about the new Data Layer in the Google Maps Javascript Documentation, with demo maps for each of the new features.

No comments: