\nKML Circle Generator Output\n1\n\ncircle\n1\n\n\n\n"); // loop through the array and write path linestrings for($i=0; $i<=360; $i++) { $radial = deg2rad($i); $lat_rad = asin(sin($lat1)*cos($d_rad) + cos($lat1)*sin($d_rad)*cos($radial)); $dlon_rad = atan2(sin($radial)*sin($d_rad)*cos($lat1), cos($d_rad)-sin($lat1)*sin($lat_rad)); $lon_rad = fmod(($long1+$dlon_rad + M_PI), 2*M_PI) - M_PI; fwrite( $fileappend, rad2deg($lon_rad).",".rad2deg($lat_rad).",0 "); } // write everything else and clean up fwrite( $fileappend, "\n\n\n"); fclose( $fileappend ); if(file_exists($filename)) { echo ("

Your circle is right here.

"); } else { echo( "If you can see this, something is wrong..." ); } ?>