, , L.mapbox.legendControl, , , ,
map.legendControl._legends - , , , map.legendControl.addLegend, map.legendControl.removeLegend ,
.
map.legendControl.addLegend('<span>hello world</span>')
map.legendControl.addLegend('random string')
map.legendControl.addLegend('random string')
map.legendControl.removeLegend('random string')
, , , , ( , addLegend removeLegend _update
_legend, <div class="map-legend wax-legend"></div> ( _legend[some key] , ).
: html ,
<div class="map-legend wax-legend"><span>hello world</span></div>
<div class="map-legend wax-legend">random string</div>
.map-legends
<div class="map-legends wax-legends leaflet-control">
<div class="map-legend wax-legend"><span>hello world</span></div>
<div class="map-legend wax-legend">random string</div>
</div>
, var previousLegend = $('.map-legends').html(), , , , <div class="map-legend">,
, $('.map-legends').html(), html, ,
var previousLegend;
function changeLegend() {
if (previousLegend) map.legendControl.removeLegend(previousLegend)
var newLegend = getLegendHTML();
map.legendControl.addLegend(newLegend);
previousLegend = newLegend;
}
source
share