load($url); try { if(preg_match('/.kml$/', $url)) { header("Content-Type: text/plain"); if($kml->parseKml($content)){ $geojson = $kml->createGeoJSON(); echo $geojson; }else{ echo("{}"); } } if(preg_match('/.(json|geojson)$/', $url)) { //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)$/', $url)) { header("Content-Type: text/plain"); echo $content; } } catch (Exception $e) { echo($e); die; } ?>