ui-leaflet
ui-leaflet copied to clipboard
[Question] How to use Tooltip property in ui-leaflet with leaflet.js 1.0.0
Dear all,
I recently use leafletjs 1.0.0-rc1 with ui-leaflet (1.0.0 Aug 22 version) and find that leaflet.label doesn't work and many error in console. And then I go to Leaflet.label site and say that new feature implementated as follow.
NOTE: starting with Leaflet 1.0, L.Label is added to Leaflet core as L.Tooltip and this plugin is deprecrated.
Do anyone know how to L.Tooltip property in ui-leaflet? Thanks for your advice.
Regards, Kenneth
+1, also happened to me when reinstalling build as i was pointing to master branch
i was using jspm to grab dependencies from the web and resolved the issue by overwriting the newer version with this older one:
https://github.com/Leaflet/Leaflet.label/tree/0bb8fdab99915705428a440454f6750ef0841c5e
I wanted to use the Tooltip as well, and I ended up directly patching this library which does not seem to be maintained anymore.
It's quite easy, just need to use the same logic as the Popup one (in the _addMarkers function):
// Bind tooltip
if (isDefined(model.tooltip)) {
marker.bindTooltip(model.tooltip.text, model.tooltip.options);
}
// -> this is the existing code: Bind message
if (isDefined(model.message)) {
marker.bindPopup(model.message, model.popupOptions);
}
This part just handles first the definition of markers. If they are dynamically added/removed/updated, you need to update the _updateMarker
method of the leafletMarkersHelpers
.