How to add a marker icon to a leaflet?
Edit: Use the code below to add a marker icon and just replace the link to the one with the color of your choice. (i.e. marker-icon-2x-green.png to some other image) Leaflet Markers are stored as files unlike other objects (like Polylines, etc.) If you want your own markers, you can find The official Leaflet Tutorial that explains how to do it.
Can you add colored icons to leaflet R?
A less cumbersome solution could to combine the second solution with addCircleMarkers : these are not colored icons, bu icons over different colors. You should get something like this : not colored icons, but something understandable enough.
Where can I find a leaflet marker SVG?
Leaflet Markers are stored as files unlike other objects (like Polylines, etc.) If you want your own markers, you can find The official Leaflet Tutorial that explains how to do it. After reading this conversation with the main developer I searched for the marker SVG and here it is.
How to change color of marker in HTML?
The solution I came up with was to use Leaflet.DivIcon html attribute, it allows you to pass a string which is evaluated into a DOM element. So for example I created a marker style follows: Change background-color in markerHtmlStyles to your custom colour and you’re good to go. Bind in the icons from this site!
Is the marker defined at the time of the event handler?
In the code snippet above, marker is not defined at the time the event handler is added. Try the following where the dragend listener is added immediately following the creation of the Marker:
How to set marker on click, update position on Stack Overflow?
You were also missing a bracket at the end of your new L.Marker () line. You also put position into an array in the call to setLatLng but it is already a LatLng object. Thanks for contributing an answer to Stack Overflow!