Leaflet 如何获得精确的kml文件路径?

Leaflet 如何获得精确的kml文件路径?,leaflet,kml,Leaflet,Kml,我试着用OpenLayersV3显示kml文件,但我没有得到正确的路径,我试着用传单来显示kml文件,我下载了传单示例的相同代码 const map = new L.Map('map', { center: new L.LatLng(23.8086,78.6188), zoom: 6 }); const osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');

我试着用OpenLayersV3显示kml文件,但我没有得到正确的路径,我试着用传单来显示kml文件,我下载了传单示例的相同代码

  const map = new L.Map('map', { center: new L.LatLng(23.8086,78.6188), zoom: 6 });
            const osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');

            map.addLayer(osm);

            // Load kml file
            fetch('../kml/2018.kml')
                .then(res => res.text())
                .then(kmltext => {
                    // Create new kml overlay
                    const parser = new DOMParser();
                    const kml = parser.parseFromString(kmltext, 'text/xml');
                    const track = new L.KML(kml);
                    map.addLayer(track);

                    // Adjust map to show the kml
                    const bounds = track.getBounds();
                    map.fitBounds(bounds);
                });

错误:边界无效。

TypeError:L.KML不是构造函数您是否加载了KML插件?这是我使用的在线资源。所以你还没有加载插件。下面的例子中,我使用了相同的代码,但我被困在哪里放置这个文件,js文件和所有都是确定的,但资产文件夹呢?