1. 52
    Recreate React Leaflet Markers with the GeoJSON pointToLayer Configuration Set
    35s

Recreate React Leaflet Markers with the GeoJSON pointToLayer Configuration Set

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

Before we create a completely custom icon, we need to set up our GeoJSON configuration to allow us to manually create markers in the first place. We'll start by recreating our current markers.

Click here for exercise instructions

Instructor: [0:00] We have our markers, but that image doesn't necessarily represent what those locations are. Instead, I created this utensils marker, so it shows that it's a restaurant.

[0:07] To use a custom image, we're going to set a new property on our GeoJSON instance. This property is going to be point to a layer, which we're going to set it equal to a function where the first argument is a feature. Our second argument is a lat, long. We want to make sure we include that comma after the property, so it's proper JavaScript.

[0:21] At this point, we're not returning anything. If we look at our map, we actually have no markers. To recreate our markers, we're going to return a Leaflet marker instance, we're going to take our lat, long and we're going to pass it in as an argument. Now, if we look back at our map, we can see that we've recreated our markers

egghead
egghead
~ 13 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