Leaflet maps use either an SVG or Canvas renderer.

How do I figure out which one a created leaflat map is using?


My understanding is that, for most Leaflet objects, the options object given by the user gets merged with the class's defaults, overriding them. Then the class decides what to do with the result on initialisation, using some logic like this._myopt = this.options.myopt. So if you haven't provided a Renderer option, there isn't going to be one at my_map.options.renderer (there isn't for me either, and I didn't override the default).

However, my_map._renderer seems to be populated. You can check it against the renderer types using the instanceof operator:

mymap._renderer instanceof L.SVG
// true

mymap._renderer instanceof L.Canvas
// false

You can also inspect your map panes (e.g. <div class="leaflet-pane">) and see if their children include <svg> or <canvas>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.