Exploring GeoJSON

GeoJSON is a JSON format that encodes geometries. GeoJSON can encode points, line strings, and polygons. It also allows for multipart geometries. You can encode multipoints, multiline strings, and multipolygons. These should sound familiar because they are pretty close to the geometries you learned to draw in Chapter 1, Creating Maps with Leaflet. The following GeoJSON code shows you two points in a feature collection:

{"type":"FeatureCollection", "features":[ {"type":"Feature", "geometry":{ "type":"Point", "coordinates":[-106.62987,35.10418] }, "properties":{ "name":"My Point", "title":"A point at the Big I" } }, {"type":"Feature", "geometry":{ "type":"Point", "coordinates":[-106,35] }, "properties":{ "name":"MyOther Point", ...

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.