angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
314 stars 134 forks source link

Example for layer control with legends #293

Closed plattdl closed 8 years ago

plattdl commented 8 years ago

I am using the layer control and have noticed in the code that there is a legend toggle functionality for each layer. However I can not find any examples on how to supply legend data to each layer so that the control can toggle the legend.

Can someone provide some guidance on how to use this functionality?

elesdoar commented 8 years ago

Hi @plattdl

Just add legend attribute to layers, this should be a HTML string.

Example:

layers: {
 ...
  overlays: {
    layer1: {
      type: 'xyz',
      url: 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
      name: 'Positron',
      legend: '<h2>this is HTML string</h2>'
    }
  } 
}