title: Leaflet.Draw - geoJSON to Kml
body: <p>I have made a map using the Leaflet Draw plugin which allows the user to download their drawn items. These drawn items are exported as GeoJSON using the following code from <a href="https://bl.ocks.org/danswick/d30c44b081be31aea483" rel="nofollow noreferrer">here</a>:</p>
  
  <pre><code>document.getElementById('export').onclick = function(e) {
          // Extract GeoJson from featureGroup
          var data = featureGroup.toGeoJSON();
  
          // Stringify the GeoJson
          var convertedData = 'text/json;charset=utf-8,' + 
          encodeURIComponent(JSON.stringify(data));
  
          // Create export
          document.getElementById('export').setAttribute('href', 'data:' + 
          convertedData);      
         document.getElementById('export').setAttribute('download','data.geojson');
  }
  </code></pre>
  
  <p>This works perfectly, but it would be even more ideal if the GeoJSON was converted to .kml before being exported. I am aware of the <a href="https://github.com/mapbox/tokml" rel="nofollow noreferrer">toKml</a> plugin but I am struggling to get it to work (I am still quite new to all of this). Where would I add:</p>
  
  <pre><code>var kml = tokml(geojsonObject);
  </code></pre>