parseKml($content)){ $geojson = $kml->createGeoJSON(); echo $geojson; }else{ echo("{}"); } } if(preg_match('/.(json|geojson)$/', $_FILES['kml']['name'])) { //set dummy style attributes if not exits!!! $jsonStyle = new geojson_style(); $content = $jsonStyle->addDefaultStyles($content); header("Content-Type: text/plain"); echo $content; } if(preg_match('/.(xml|gpx)$/', $_FILES['kml']['name'])) { header("Content-Type: text/plain"); echo $content; } } catch (Exception $e) { echo($e); die; } ?>