Compact and Noncompact Gauged Maximal Supergravities in Three Dimensions