I've taken the basic leaflet-image example here: https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-image/
And modified it by adding a very simple geoJSON layer to the map:
var dataJson = JSON.parse(data);
var segLayer = L.geoJson(dataJson);
segLayer.addTo(map);
map.fitBounds(segLayer.getBounds());
https://jsfiddle.net/fexymjy3/10/
When I hit the "Take a snapshot" button, I get the following error:
Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)'
I've seen the leaflet-image readme: https://github.com/mapbox/leaflet-image/blob/gh-pages/README.md
Which states
You must set L_PREFER_CANVAS = true; so that vector layers are drawn in Canvas rather than SVG or VML.
But it doesn't say where to set that. I tried it setting it on my segLayer, on the map, and just globally but it doesn't fix the error. What am I doing wrong?