Index: /issm/trunk-jpl/src/m/plot/kmlgroundoverlay.m
===================================================================
--- /issm/trunk-jpl/src/m/plot/kmlgroundoverlay.m	(revision 21781)
+++ /issm/trunk-jpl/src/m/plot/kmlgroundoverlay.m	(revision 21782)
@@ -28,11 +28,22 @@
 
 %figure out  min and max for lat and long of this image:
-west=min(md.mesh.long);
-east=max(md.mesh.long);
-south=min(md.mesh.lat);
-north=max(md.mesh.lat);
+if strcmpi(getfieldvalue(options,'coord',''),'latlon'),
+	%need to plot with option 'coord','latlon'
+	XLIM=xlim();
+	YLIM=ylim();
+	west=XLIM(1);
+	east=XLIM(2);
+	south=YLIM(1);
+	north=YLIM(2);
+else
+	west=min(md.mesh.long);
+	east=max(md.mesh.long);
+	south=min(md.mesh.lat);
+	north=max(md.mesh.lat);
+end
 
 %print image at high resolution
-export_fig([kmlroot '/' kmlimagename],'-transparent','-zbuffer'); %zbuffer to avoid "Bad data returned by HARDCOPY. Not calling IMWRITE"
+%export_fig([kmlroot '/' kmlimagename],'-transparent','-zbuffer'); %zbuffer to avoid "Bad data returned by HARDCOPY. Not calling IMWRITE"
+export_fig([kmlroot '/' kmlimagename],'-transparent');
 %printmodel([kmlroot '/' kmlimagename],kmlimagetype,'trim','on','resolution',kmlresolution,'margin','off','frame','off');
 
@@ -61,2 +72,12 @@
 
 fclose(fid);
+
+if strcmpi(getfieldvalue(options,'kmz','on'),'on')
+	disp('Converting to kmz...');
+	system(['cat ' kmlroot '/' kmlfilename '| sed -e "s/' kmlimagename '\.png/files\/' kmlimagename '.png/g" > doc.kml']);
+	system('mkdir files');
+	system(['mv ' kmlroot '/' kmlimagename  '.png files/']);
+	system(['zip -r  ' kmlfilename '.zip  files doc.kml']);
+	system(['mv ' kmlfilename '.zip ' kmlfilename]);
+	system(['rm -rf  files doc.kml']);
+end
