angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
315 stars 137 forks source link

[Question] How to use Tooltip property in ui-leaflet with leaflet.js 1.0.0 #284

Open hkcity1111 opened 8 years ago

hkcity1111 commented 8 years ago

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

vohzd commented 8 years ago

+1, also happened to me when reinstalling build as i was pointing to master branch

vohzd commented 8 years ago

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

ValentinH commented 7 years ago

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.