园林绿化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1002 B

  1. # kml-geojson (kgUtil)
  2. kml或kmz格式 与 GeoJSON格式 互相转换工具类(kgUtil)
  3. 地址:https://github.com/muyao1987/kml-geojson
  4. ## 运行命令
  5. ### 首次运行前安装依赖
  6. `npm install``cnpm install`
  7. ### 打包编译项目
  8. 运行`npm run build`来构建项目。
  9. ## 使用示例
  10. ### KML转GeoJSON示例:
  11. ```js
  12. //直接加载url
  13. kgUtil.toGeoJSON('//data.mars3d.cn/file/kml/NAVWARN.kmz').then((geojoson) => {
  14. console.log(geojoson)
  15. })
  16. //加载input文件控件的二进制流
  17. kgUtil.toGeoJSON(e.target.files[0]).then((geojoson) => {
  18. console.log(geojoson)
  19. })
  20. //加载kml文档对象
  21. $.ajax('//data.mars3d.cn/file/kml/dg8.kml').done(function (xml) {
  22. kgUtil.toGeoJSON(xml).then((geojoson) => {
  23. console.log(geojoson)
  24. })
  25. })
  26. ```
  27. ### GeoJSON转KML示例
  28. ```js
  29. var kml = kgUtil.tokml(geojsonObject, {
  30. name: 'Mars3D标绘数据',
  31. documentName: 'Mars3D标绘数据文件',
  32. documentDescription: '标绘数据 by mars3d.cn',
  33. simplestyle: true,
  34. })
  35. ```