我尝试使用开放层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);
});
错误:边界无效。