File tree 1 file changed +22
-13
lines changed
1 file changed +22
-13
lines changed Original file line number Diff line number Diff line change 86
86
87
87
damageLevels .sort ((a , b ) => a - b)
88
88
89
- if (! this .$el .querySelector (' .map-legend' ))
89
+ let buildingsLegendsElem = this .$el .querySelector (' .buildings-legends' )
90
+ let addLegends = function (legendsElem )
90
91
{
91
- const legend = window .L .control ({ position: ' bottomright' })
92
-
93
- legend .onAdd = map => {
94
-
95
- let div = window .L .DomUtil .create (' div' , ' map-legend buildings-legends' )
96
- let buildingsLegends = ' '
92
+ let buildingsLegends = ' '
97
93
98
- damageLevels .forEach (dLevel => {
99
- buildingsLegends +=
100
- ` <div class="buildings-legend">
94
+ damageLevels .forEach (dLevel => {
95
+ buildingsLegends +=
96
+ ` <div class="buildings-legend">
101
97
<span style="background: ${ buildingColor (dLevel)} "></span>
102
98
<span>d-${ dLevel} </span>
103
99
</div>`
104
- })
100
+ })
101
+
102
+ legendsElem .innerHTML = buildingsLegends
103
+ }
105
104
106
- div .innerHTML = buildingsLegends
107
- return div
105
+ if (buildingsLegendsElem)
106
+ {
107
+ addLegends (buildingsLegendsElem)
108
+ }
109
+ else
110
+ {
111
+ const legend = window .L .control ({ position: ' bottomright' })
112
+
113
+ legend .onAdd = map => {
114
+ let legendsElem = window .L .DomUtil .create (' div' , ' map-legend buildings-legends' )
115
+ addLegends (legendsElem)
116
+ return legendsElem
108
117
}
109
118
110
119
legend .addTo (this .map .object )
You can’t perform that action at this time.
0 commit comments