With our data, we'll need a way to present it. Luckily, Leaflet's GeoJSON instance provides ways for us to customize our data on the map so that we can visualize it and communicate more effectively.
Colby Fayock: [0:00] Now that we have the data for each location, let's add a popup to each marker. We're going to use a custom option for the GeoJSON instance. We're going to set a property called onEachFeature , which we're going to set equal to a new function.
[0:09] In that function, we have two arguments. We have feature which we're going to set by default to an empty object. We also have layer. Our feature is going to be from our location data. We can destructure those properties straight from that feature. Since each location has a name property, we can destructure that out too.
[0:23] To test that, we can console.log out each of those names. We can see each of our name show up. We want to create a popup, so we're going to create a new constant called popup. We're going to set that equal to a new Leaflet popup. Using that popup, we're going to set its content to the name.
[0:35] Finally, we're going to use the layer which is a Leaflet layer. We're on the layer. We're going to run-bind popup, and pass in our popup. When we reload the page, we can click the marker, and we can see each of those names.