如何获取确切的kml文件路径?

我尝试使用开放层v3显示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);
                });

错误:边界无效。

lyx123hsh 回答:如何获取确切的kml文件路径?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3161888.html

大家都在问