Superfluid-mott insulator transition of spinor bose gases with external magnetic fields