Leaflet.draw icon indicating copy to clipboard operation
Leaflet.draw copied to clipboard

Adding dynamic tooltip text

Open houssemFat opened this issue 9 years ago • 2 comments

Hi, i use leaflet.draw plugin to add some shapes to map, but i need to change the information (static text) of the tooltip when the user move the cursor (mousemove) on edit mode or on adding some vertex. How can i intercept this event, something like

map.on('draw:cursor-move', function (e, latlng, options) { .... })

Also, I tried to extend the update text function and update position, but i need also the mousemove event, action or shape type and the latlng position.

houssemFat avatar Jul 21 '16 17:07 houssemFat

Looks like those strings are defined here, so you could update them with e.g.

L.drawLocal.draw.handlers.polygon.tooltip.start = "<your text here>";

drawLocal is documented -- though not it's entire structure -- so it seems to me there's a chance this could break in a future release.

RickMohr avatar Feb 21 '17 21:02 RickMohr

Polyline errors allow us to add HTML content, which is unfortunately not the case with tooltips:

polyline: {
  error: '<strong>Error:</strong> shape edges cannot cross!',
  tooltip: {
	start: 'Click to start drawing line.',
	cont: 'Click to continue drawing line.',
	end: 'Click last point to finish line.'
  }
},

khashashin avatar Apr 04 '24 10:04 khashashin