function draw_map(map)

num_m = length(map.submap);

colors = prism(num_m);
colors = rand(num_m,3);
held = ishold; 
Xr = zeros(3,num_m);
for i=1:num_m
   lm = map.submap(i);
   L = extract_landmarks(lm.X,lm.P,lm.L_sig);
   Lg = transfer_lines(map.Trans{i,i},L);
   Xt = mul_config(map.Trans{i,i},map.submap(i).track);
   
   if length(Lg)
      draw_landmarks(Lg(1:6,:), colors(i,:));
      hold on;
   end
   plot(Xt(1,:),Xt(2,:), 'color', colors(i,:), 'LineStyle', ':');
   hold on;
   
   Xr(:,i) = mul_config(map.Trans{i,i},lm.X(1:3));
   Xr(:,i) = map.Trans{i,i};
   draw_robot(Xr(:,i),map.TCov{i,i});
   text(Xr(1,i),Xr(2,i), num2str(i), 'color',colors(i,:));
   
   j = find(map.Adj(i,:));
   nj = length(j);
   X = zeros(3,2*nj);
   X(:,2:2:end) = cat(2,map.Trans{i,j});
   X = mul_config(map.Trans{i,i},X);
   plot(X(1,:),X(2,:), 'color', colors(i,:));
   
end

%gplot(map.Adj, Xr(1:2,:)', 'k');

axis equal
if (~held) hold off; end