【发布时间】:2019-08-03 08:47:23
【问题描述】:
我正在尝试在我的 Angular 7 项目中使用 Leaflet.Illustrate。我试图在 HTML 中加载它,但是,即使它确实加载了,也不清楚如何调用
new L.Illustrate.Control({
edit: { featureGroup: drawnItems }
}).addTo(map);
将其添加到现有调用以构建我拥有的工具栏:
addDraw() {
if (this.map !== undefined) {
const leaflet = this.map.leafletMap();
leaflet.setZoom(3);
const drawnItems = new L.FeatureGroup();
leaflet.addLayer(drawnItems);
const drawControl = new L.Control.Draw({
position: 'bottomright',
draw: {
polygon: {
allowIntersection: false,
showArea: true
}
},
edit: {
featureGroup: drawnItems
}
});
leaflet.addControl(drawControl);
leaflet.on(L.Draw.Event.CREATED, function (event: any) {
drawnItems.addLayer(event.layer);
});
}
}
我一直在寻找@types/leaflet-illustrate,但没有运气,我什至打算尝试编写一个 index.d.ts 来涵盖 JavaScript 库。有没有其他人运气好,或者找到如何编写 index.d.ts 的好方法?
【问题讨论】:
标签: angular typescript leaflet typescript-typings leaflet.draw