I am using the Bootleaf Template and have presented 5 polygons from GeoJSON successfully.
In trying to add simple labels from 'NAME' field to center of each polygon using L.circleMarker(layer.getBounds().getCenter()); I get "bindLabel is not a function" error.
Is there a functional way to do this?
Code below:
var districts = L.geoJson(null, {
style: function (feature) {
return {
color: "white",
fill: true,
weight: 2,
opacity: 0.8
};
},
onEachFeature: function (feature, layer) {
layer.on('mouseover', function () {
this.setStyle({
'fillColor': '#0000ff'
});
});
layer.on('mouseout', function () {
this.setStyle({
'fillColor': '#ff0000'
});
});
layer.on('click', function () {
window.location = feature.properties.URL;
});
var circleMarker = L.circleMarker(layer.getBounds().getCenter());
// e.g. using Leaflet.label plugin
circleMarker.bindLabel(feature.properties['NAME'], { noHide: true })
.circleMarker.addTo(map);
}
});
$.getJSON("data/districts.geojson", function (data) {
districts.addData(data);
});