The Google Maps JavaScript API makes it easy to pull in geospatial data from KML files, which works great with our KML export functionality for geospatial datasets. This sample will walk you through the process of using Socrata’s KML support to display polygon boundaries on a Google Map. If you’d like to follow along at home, you can fork this jsFiddle sample project.
This example would go great with our Google Maps Mashup tutorial, allowing you to map points and boundaries together.
This example pulls data live from this LA Comptroller dataset of district boundaries.
To start, we’ll need our KML URL. We got this by right-clicking and selecting “Copy Link Address” on the KML
link in the Export sidebar: post
Then we initialize our map and center it on Los Angeles:
Then we’ll add our KML layer:
The whole thing then get’s wrapped in jQuery’s $(window).load
function so that it gets run when the DOM is done loading. The full code listing is below:
There you go! If you’ve got a walk-through of your own that you’d like to share, we’ll gladly accept your contribution.