Leaflet.label
Leaflet.label copied to clipboard
Leaflet.label 0.2.4 is not compliant with leaflet 1.0.2
When we call showLabel as in the following example:
var p2 = L.polyline([
[-37.7612, 175.2756],
[-37.7612, 175.2950]
]).addTo(map);
var label = new LeafletLabel({
offset: [-12,-15],
});
label.setContent("20'-50'");
label.setLatLng(p2.getBounds().getCenter());
map.showLabel(label);
We get this following error:
leaflet-src-1.0.2.js:3602 Uncaught TypeError: Cannot read property 'call' of undefined
at NewClass.whenReady (leaflet-src-1.0.2.js:3602)
at NewClass.addLayer (leaflet-src-1.0.2.js:4018)
at NewClass.showLabel (leaflet.label-src.js:544)
at test.html:65
We change the declaration of Leaflet.label declared as a "L.Class" in line 28 in leaflet.label-src.js as:
var LeafletLabel = L.Layer.extend({ ... });
`
It fixed the problem for us...
But is anyone could confirm if this fix is really the correct one?
Just found this note somewhere... NOTE: starting with Leaflet 1.0, L.Label is added to Leaflet core as L.Tooltip and this plugin is deprecrated. Ok... I will use Tooltip !
Tooltips does not seem to work either... try to have this test working on leaflet 1.0.2 https://github.com/Leaflet/Leaflet/blob/master/debug/map/tooltip.html and... well... no tooltips... Same with leaflet 1.0.3 :-(