1. 44
    Add Another Restaurant Attribute with a GeoJSON Property and Display it in a Leaflet Popup
    31s

Add Another Restaurant Attribute with a GeoJSON Property and Display it in a Leaflet Popup

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

When looking for restaurants, people like to know if the restaurant serves food to their dietary needs. Maybe they're vegan or lactose intolerant -- either way, we can add another data attribute that allows us to display that information.

Create a new data attribute in our the properties of each location in our GeoJSON file for another category like Dietary Restrictions and set up our popup to include that information!

Click here for exercise instructions

Instructor: [0:00] By looking at this restaurant, we can tell what they have there, but we can't tell if they're vegan-friendly or not. We can add another attribute inside of our locations file where we can create a new property called vegan. If this location is actually vegan, we can set that to true.

[0:11] Inside of our code, we're going to copy the delivery properties since that's similar with the true and false values. Where inside delivery, we're going to say vegan-friendly. We're going to destructure that vegan property and change that delivery variable to vegan.

[0:23] Now on our map, we can see that if we look at DC Pizza, it says that vegan-friendly is equals yes. Since on Pi Pizzeria, we didn't set that, it's not vegan-friendly.

egghead
egghead
~ 12 minutes ago

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

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

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!

Markdown supported.
Become a member to join the discussionEnroll Today