当前位置: 首页 > 工具软件 > GeoJSON > 使用案例 >

GeoJson ======>KML

宫晟
2023-12-01

GeoJson转KML``

npm install --save tokml 
import otkml from 'tokml' //在要使用的地方加入
//准备你的geojson
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          [
            [
              119.101111,
              19.119722
            ],
            [
              119.129167,
              19.568611
            ],
            [
              118.080556,
              19.624167
            ],
            [
              118.080556,
              19.175
            ],
            [
              119.101111,
              19.119722
            ]
          ]
        ],
        "type": "Polygon"
      },
      "type": "Feature",
      "properties": {}
    },
    {
      "geometry": {
        "coordinates": [
          [
            [
              124.003611,
              18.754722
            ],
            [
              124.045833,
              19.2025
            ],
            [
              122.621944,
              19.3175
            ],
            [
              122.583611,
              18.869167
            ],
            [
              124.003611,
              18.754722
            ]
          ]
        ],
        "type": "Polygon"
      },
      "type": "Feature",
      "properties": {}
    },
    {
      "geometry": {
        "coordinates": [
          [
            [
              148.946667,
              14.414167
            ],
            [
              149.156389,
              15.290556
            ],
            [
              146.971667,
              15.7675
            ],
            [
              146.770556,
              14.889444
            ],
            [
              148.946667,
              14.414167
            ]
          ]
        ],
        "type": "Polygon"
      },
      "type": "Feature",
      "properties": {}
    }
  ],
  "type": "FeatureCollection"
}
//  kml 是一串 KML 数据,geojsonObject 是一个 JavaScript 对象
//  GeoJSON 数据
var  kml  = tokml ( geojsonObject ) ; 

api ====> 走你

 类似资料: