%GUIpremakemap
% Copyright by Jasmine S Nahorniak, Oregon State University.
% June 20 2000

function [coast,M,l2lat,l2lon]=GUIpremakemap(data,mins,maxs,coast,region,filetype,l2lat,l2lon);

GUIbutton('Pushbutton6','PLOTTING','on');

% find the figure number
choice=get(findobj('Tag','PopupMenu1'),'Value');
figs=get(findobj('Tag','PopupMenu1'),'String');
mapfig=figs{choice};

if mapfig(1)=='n',  % new figure

  % find the filetype
  choice=get(findobj('Tag','Listbox1'),'Value');
  ftype=char(filetype{choice});

  if ftype(1:7)=='level 2',
    [coast,M]=GUIlevel2plot(data,mins,maxs,coast,region,filetype,l2lat,l2lon);
    l2lat=[];
    l2lon=[];
  else
    [coast,M]=GUImakemap(data,mins,maxs,coast,region,filetype); 
  end

else

  % check is still an existing figure
  mapfigs=[findobj('Tag','Mapfigure')' findobj('Tag','Level2figure')'];
  mapfig=intersect(str2num(mapfig),mapfigs);

  if ~isempty(mapfig),

    figname=get(mapfig,'Tag');
    if figname(1:4)=='Mapf',
       GUIeditmap(mapfig);
    else % is a level 2 map
       GUIeditl2map(mapfig);
       l2lat=[];
       l2lon=[];
    end

  end
  M=[];

end

GUIbutton('Pushbutton6','GO','off');
