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 4 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