fixed nullpointer in legend module if layer is not available