Chapter 2. Mapping GeoJSON Data

In Chapter 1, Creating Maps with Leaflet, all of the geometry elements—points, lines, and polygons—were created one at a time. You learned how to create groups of features using layer and feature groups and also multipolyline and multipolygon classes. In this chapter, you will learn how to add GeoJSON data to your map. The data will be comprised of multiple geometries and will have descriptive data associated with it.

In this chapter, we will cover the following topics:

  • What is GeoJSON?
  • How to add it to your map
  • How to style it
  • Iterating through features
  • How to call GeoJSON from external sources

Understanding the roots of GeoJSON

Before GeoJSON, there was JavaScript Object Notation (JSON), and before JSON, there was Extensible ...

Get Leaflet.js Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.