So I have a geojson layer in leaflet, and I can add geojson objects to this layer for display on the resulting map.
Now I'd like to add a text label to display near the object.
This example shows use of a custom L.control() object to display additional info on the map. Which seems close to what I want to do.
Given this example, I'd like to add State initial text labels (i.e. "TX", "FL") positioned over each state. Can L.control() be used to do this, or is there another way?
http://leaflet.cloudmade.com/examples/choropleth.html
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
this._div.innerHTML = '<h4>US Population Density</h4>' + (props ?
'<b>' + props.name + '</b><br />' + props.density + ' people / mi<sup>2</sup>'
: 'Hover over a state');
};
info.addTo(map);