Reputation: 311
OK, I have a GeoJSON point file, that I'm reading into Leaflet. I noticed that the bindPopup reads the record number (feature.properties.Record / Label) however I can not get the bindLabel to read it. If I remove feature.properties.Record and replace it with "Demo" then I get a label.
onEachFeature: function (feature, layer) {
layer.bindPopup("<p>Record: " + feature.properties.Record + "</p>"), //works
//layer.bindLabel(feature.properties['Record'], { noHide:true, className: 'text-labels' }), //Doesn't work
//layer.bindLabel(feature.properties.Record, { noHide:true, className: 'text-labels' }), //Doesn't work
layer.bindLabel('Hello', { noHide:true, className: 'text-labels' }), //works but I don't want to manually label each one.
layer.addTo(map).
layer.showLabel();
Any ideas? I've tried the tooltip option but I get bindtooltip is not a function.
Upvotes: 0
Views: 248
Reputation: 311
Ok simple stupid mistake.
feature.properties['Record'] should be feature.properties['Record'].toString()
It appears, labels have to be strings and in my data I was trying to put an integer as a label. So I got a blank label.
Upvotes: 1