React-Leaflet React Component as Marker

I've recently gotten into React Leaflet and from what I've gathered from the docs, it is not possible to add a custom React Element (Component or pure functional) as a marker.

What I want to achieve is to be able to use my React Element which is an SVG icon as the marker. This would be useful because I'll need to display several different color icons and it's way more convenient to pass the color as props and let React create the marker.

Am I right in assuming this isn't possible?

Upvotes: 2

Views: 3026

Answers (1)

Evan Siroky
Evan Siroky

Reputation: 9438

You are incorrect! :) React-leaflet allows the creation of custom components. Also, you should check out react-leaflet-div-icon since it seems like it's exactly what you need.

Upvotes: 4

Related Questions