GeoJSON is a JSON based format for encoding geospatial data. It supports several geometry types including points, line strings, and polygons. Since it is JSON, it is well suited for use with JavaScript and Leaflet has built in support for rendering data in this format.

You'll find lots of data out in the wild formatted in GeoJSON. It is a common format and much of the GIS software and databases used by Government can export data this way. See the resources section below for some examples.




Let's take a look at the result here.

map.js - popups

Now that we can simply hand off the file to Leaflet to add to the map, we have no place to do any processing of the individual items in the list (to bind a popup for example). To add popups for each county, we'll need to put some logic into a onEachFeature JavaScript function and pass it into Leaflet.


Further Reading

Previous Next