Generating a custom marker with canvas is handy when you want to change the marker size/color dynamically.
The following code snippet contains a 'createMarker' function that creates a canvas, draws the marker graphics and returns back the Data URL encoded version of that canvas which can be used as an input at the marker creation.
See the example below.