簡體   English   中英

如何在 angular 中將 geojson object 轉換為 KML

[英]How to convert geojson object to KML in angular

我需要在我的 angular 項目中將我的 geojson object 轉換為 kml 文件。 在一些研究中,我發現了這個 npm 庫geojson-to-kml 但是當我嘗試使用它時遇到的問題。 我收到一個錯誤

找不到模塊“geojson-to-kml”的聲明文件。

我嘗試使用npm i @types/geojson-to-kml安裝,但拋出錯誤 ERR 404 '@types/geojson-to-kml@*' 不在此注冊表中。

有什么方法可以在我的 angular 項目中使用這個庫。 或者有沒有其他方法可以幫助我將geojson object 轉換為 kml 文件。

任何建議都會有很大幫助。

嘗試以下操作:

import { Component, OnInit, VERSION } from '@angular/core';
import tokml = require('tokml');

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
  name = 'Angular ' + VERSION.major;
  geoObject = {
    type: 'Feature',
    geometry: {
      type: 'Point',
      coordinates: [125.6, 10.1],
    },
    properties: {
      name: 'Dinagat Islands',
    },
  };
  kmlObject = tokml(this.geoObject);

  ngOnInit() {
    console.log(this.kmlObject);
  }
}

這里是明星閃電戰

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM