Now that we're setting our delivery radius, let's use it! We'll use that value to create a new Circle shape on the map.
Colby Fayock: [0:00] Now that we have our delivery-radius's, we want to actually see them on the map. We're going to add a shaded circle, but we only want to add it if they actually deliver. I'm going to create a new let variable called deliveries-on-circle. If they can deliver, we're going to set that value equal to a new Leaflet circle. The Leaflet circle takes coordinates.
[0:14] We're going to de-structure our geometry with an empty object by default. Next, we want to also de-structure these coordinates from that geometry. We can take those coordinates and pass it into our circle. Similar to markers, we're going to take that deliveries-on-circle, and we're going to add it to our map.
[0:28] If we look at our map, we don't actually see that circle. If you zoom all the way out, you can actually see that our circle is down in Antarctica. The coordinates are stored in GeoJSON backwards to what Leaflet actually expects.
[0:37] Because that's a simple array, we can run the reverse method right on that array. While the circles are small, we can see them on the map at their default size. Next, to actually set the radius, we can pass a new configuration object where we're going to specify our radius property and set it to our delivery-radius.
[0:51] Now, if we look at a map, we can see all of our markers with the delivery zone with the circle around it.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!