Skip to content

Commit d5c1d6e

Browse files
neveldoIndigo744
authored andcommitted
Prevent mapael from raising an error if the legend container doesn't exist (neveldo#335)
Prevent mapael from raising an error if the legend container doesn't exist
1 parent 58e2dc6 commit d5c1d6e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

js/jquery.mapael.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,11 +1898,9 @@
18981898

18991899
self.legends[legendType] = {};
19001900
for (var j = 0; j < legendsOptions.length; ++j) {
1901-
// Check for class existence
1902-
if (legendsOptions[j].cssClass === "" || $("." + legendsOptions[j].cssClass, self.$container).length === 0) {
1903-
throw new Error("The legend class `" + legendsOptions[j].cssClass + "` doesn't exists.");
1904-
}
1905-
if (legendsOptions[j].display === true && $.isArray(legendsOptions[j].slices) && legendsOptions[j].slices.length > 0) {
1901+
if (legendsOptions[j].display === true && $.isArray(legendsOptions[j].slices) && legendsOptions[j].slices.length > 0 &&
1902+
legendsOptions[j].cssClass !== "" && $("." + legendsOptions[j].cssClass, self.$container).length !== 0
1903+
) {
19061904
self.legends[legendType][j] = self.drawLegend(legendsOptions[j], legendType, elems, scale, j);
19071905
}
19081906
}

0 commit comments

Comments
 (0)