【发布时间】:2018-05-03 07:40:06
【问题描述】:
我使用 Leaflet Draw 插件制作了一张地图,该插件允许用户下载他们绘制的项目。这些绘制的项目使用来自here 的以下代码导出为 GeoJSON:
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');
}
这很完美,但如果在导出之前将 GeoJSON 转换为 .kml 会更理想。我知道toKml 插件,但我很难让它工作(我对这一切还是很陌生)。我会在哪里添加:
var kml = tokml(geojsonObject);
【问题讨论】:
标签: javascript leaflet kml geojson leaflet.draw