v.leaflet + v.leaflet.draw - adding labels to drawn elements

Hi,

I am using v-leaflet with v-leaflet.draw to draw stands on market map. Its great addon but i dont know how to add labels to drawned elements (is it possible?). I want to achive smth like on attached image. Maybe some addStyleName() to drawnElement would help? I am out of ideas how to achive this effect.

Cheers Rafal.
17419.png

Hi,

You can do this with Marker and by using “DivIcon” for it. A commit tells more than thousand words?
https://github.com/mstahv/v-leaflet/commit/446ed55f22409b883cfefbb2db74e9debba9e621#diff-0

I agree, pretty hard to find that feature. I should really write a tutorial at some point for the add-on.

BTW. If you are not too long with your app, I’d also suggest to try the alternative drawing plugin:
L-Editable
. It is based an a new Leaflet JS plugin that has some more advanced features like real polygon editing (including holes) and touch device support. It is pretty new, but I’m very pleased with it in my hobby project.

cheers,
matti

thx Matti. Your solution works great. I will probably switch to L-Editable at next stage of this project :wink: